# Getting Workflow Objects Treasure Data provides an API that you can use to view the details of a particular workflow outside of the Treasure Data Console. Figure 1 below shows an example of a workflow object returned by the API. Schedule information for the workflow, including start and end dates, is shown in lines 16-20. You can get a list of the workflow objects that are in Treasure Data by calling this RESTful endpoint: `https://api.treasuredata.com/api/workflows` The workflow objects that are returned by this call contain both the ID of a workflow and the schedule information for the workflow (see Figure 1). You can call this endpoint with the following parameters: * No parameters–This will return 200 workflow objects starting with the lowest numbered ID. This is only a good option if you have few workflows defined in the system. * count--This limits the results returned to a specified number. While this overcomes the default limitation of 200 workflow objects, specifying a large count can significantly delay the response and require additional time to parse the results. count is defined as an int32 so you can specify over 2 million objects. * last_id–This limits the results to the first 200 workflow objects whose IDs are greater than the specified number. This can be useful if you have a general idea of how what your workflow ID numbers are. For example, if your current workflow IDs look something like this 3456, you could set last_id to approximately 3400 to limit the results of the call. * name_pattern–This will limit the results to workflow objects whose names match the pattern you specify. If you follow a workflow object naming convention, or if you have an idea of what a workflow was named, this is the most efficient way of displaying workflow objects. The format of the response is unformatted JSON. However, for the sake of readability, the responses in the examples below are piped through a JSON formatting tool. ## Example of Calling the API with count ```bash $ curl -H 'Authorization: TD1 ${TD_API_KEY}' \ 'https://api.treasuredata.com/api/workflows/?count=2000' | python -m json.tool ``` ```json { "workflows": [ { "id": "334", "name": "myredshift", "project": { "id": "14", "name": "myredshift" }, "revision": "a56dfb4e8eca3214ad520b45b2c2d1ea", "timezone": "UTC", "config": { "_export": { "user": "awsuser", "host": "td.ckw8m7vbvvvn.us-east-1.td.amazonaws.com", "database": "digdag_test", "table": "td_wf_prod_test" }, "+prepare_table": { "redshift>": "queries/create_table.sql" }, "+load_data": { "redshift_load>": null, "from": "s3://digdag-test/td-workflow-test/testdata.csv.gz", "delimiter": ",", "gzip": true }, "+increament_count": { "redshift>": "queries/increment_count.sql" }, "+unload_data": { "redshift_unload>": null, "query": "select * from ${table}", "to": "s3://digdag-test/td-workflow-test/testdata.csv.gz", "allowoverwrite": true, "delimiter": ",", "gzip": true } } }, { "id": "349", "name": "simple_workflow", "project": { "id": "123", "name": "TestUI" }, . . . ``` ## Example Calling the API with last_id ```bash curl -H 'Authorization: TD1 1/123456789abcdef0123456789abcdef012345678' 'https://api.treasuredata.com/api/workflows/?last_id=7828860' | python -m json.tool ``` ```json { "workflows": [ { "id": "7828866", "name": "wtt_workflow", "project": { "id": "234567", "name": "wtt_workflow" }, "revision": "ce2a35ae71a442b6abb3274551fe1692", "timezone": "UTC", "config": { "_export": { "td": { "database": "dbname.table" } }, "schedule": { "start": "2022-04-27", "minutes_interval>": 30, "end": "2022-04-30" }, "+task1": { "td_load>": "my_transfer_unique_id" }, "+task2": { "td_run>": "my_saved_query" } } }, { "id": "7829021", "name": "syndication", "project": { "id": "263789", "name": "journey_6543" }, . . . ``` ## Example Calling the API with name_pattern ```bash $ curl -H 'Authorization: TD1 ${TD_API_KEY}' \ 'https://api.treasuredata.com/api/workflows/?name_pattern=wtt' | python -m json.tool ``` ```json { "workflows": [ { "id": "7828866", "name": "wtt_workflow", "project": { "id": "234567", "name": "wtt_workflow" }, "revision": "ce2a35ae71a442b6abb3274551fe1692", "timezone": "UTC", "config": { "_export": { "td": { "database": "dbname.table" } }, "schedule": { "start": "2022-04-27", "minutes_interval>": 30, "end": "2022-04-30" }, "+task1": { "td_load>": "my_transfer_unique_id" }, "+task2": { "td_run>": "my_saved_query" } } } ] } ``` ## Getting Workflow Objects by ID If you want the API to just return one workflow object, you can call the API using a workflow object ID. All of the examples provided above return the ID of the workflow objects. However you can also determine a workflow ID using the TD Console: 1. In the TD Console navigate to Workflows. 2. Scroll through the list, or search the list, for your workflow and select it. The ID of the workflow appears in the URL of the browser. In the example below, the workflow ID for the wtt_workflow is 7828866. ![](/assets/workflowid2.7f2d10aafae23fe040ff052cbc606e5fed4651a3def7bae6b3c20b4b26c1ba31.2e4f387b.png) After you have the ID for the workflow, you can make the API call like this: ```bash curl -H 'Authorization: TD1 ${TD_API_KEY}' \ 'https://api.treasuredata.com/api/workflows/7828866' | python -m json.tool ``` ```json { "id": "7828866", "name": "wtt_workflow", "project": { "id": "234567", "name": "wtt_workflow" }, "revision": "ce2a35ae71a442b6abb3274551fe1692", "timezone": "UTC", "config": { "_export": { "td": { "database": "dbname.table" } }, "schedule": { "start": "2022-04-27", "minutes_interval>": 30, "end": "2022-04-30" }, "+task1": { "td_load>": "my_transfer_unique_id" }, "+task2": { "td_run>": "my_saved_query" } } } ``` **Figure 1: Example of a basic Treasure Data workflow object** ```json { "id": "7828866", "name": "wtt_workflow", "project": { "id": "265740", "name": "wtt_workflow" }, "revision": "ce2a35ae71a442b6abb3274551fe1692", "timezone": "UTC", "config": { "_export": { "td": { "database": "dbname.table" } }, "schedule": { "start": "2022-04-27", "minutes_interval>": 30, "end": "2022-04-30" }, "+task1": { "td_load>": "my_transfer_unique_id" }, "+task2": { "td_run>": "my_saved_query" } } } ```