Skip to content

Commit 256682b

Browse files
authored
API: Workflows - local sources and destinations (#535)
1 parent e0b6a6c commit 256682b

File tree

2 files changed

+189
-4
lines changed

2 files changed

+189
-4
lines changed

api-reference/workflow/overview.mdx

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,15 +1736,41 @@ the `POST` method to call the `/workflows/<workflow-id>/run` endpoint (for `curl
17361736
asyncio.run(run_workflow())
17371737
```
17381738
</Accordion>
1739-
<Accordion title="curl">
1739+
<Accordion title="curl (remote source and remote destination)">
17401740
```bash
17411741
curl --request 'POST' --location \
17421742
"$UNSTRUCTURED_API_URL/workflows/<workflow-id>/run" \
17431743
--header 'accept: application/json' \
17441744
--header "unstructured-api-key: $UNSTRUCTURED_API_KEY"
17451745
```
17461746
</Accordion>
1747-
<Accordion title="Postman">
1747+
<Accordion title="curl (local source and local destination)">
1748+
To run a workflow that uses a local source and local destination, the workflow must have already been created to use a local source and a local destination. Also,
1749+
the workflow must have already been created as a custom worklow, and the workflow cannot have been created to run on a schedule.
1750+
1751+
The workflow's source and destination must both be local. You cannot run a workflow that specifies a local source and a remote destination, nor can you run a worklow that specifies a remote source
1752+
and a local destination.
1753+
1754+
The Unstructured user interface (UI) and the Unstructured Python SDK currently do not support running workflows that use a local source
1755+
and a local destination.
1756+
1757+
In the following command, replace:
1758+
1759+
- `</full/path/to/local/filename.extension>` with the full path to the local file to upload.
1760+
- `<filename.extension>` with the filename of the local file to upload.
1761+
- `<local-file-media-type>` with the local file's media type. For a list of available media types, such as `application/pdf`, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml).
1762+
1763+
```bash
1764+
curl --request 'POST' --location \
1765+
"$UNSTRUCTURED_API_URL/workflows/<workflow-id>/run" \
1766+
--header 'accept: application/json' \
1767+
--header "unstructured-api-key: $UNSTRUCTURED_API_KEY" \
1768+
--form "input_files=@</full/path/to/local/filename.extension>" \
1769+
--form "filename=<filename.extension>" \
1770+
--form "type=<local-file-media-type>" \
1771+
```
1772+
</Accordion>
1773+
<Accordion title="Postman (remote source and remote destination)">
17481774
1. In the method drop-down list, select **POST**.
17491775
2. In the address box, enter the following URL:
17501776

@@ -1759,6 +1785,38 @@ the `POST` method to call the `/workflows/<workflow-id>/run` endpoint (for `curl
17591785

17601786
4. Click **Send**.
17611787
</Accordion>
1788+
<Accordion title="Postman (local source and local destination)">
1789+
To run a workflow that uses a local source and local destination, the workflow must have already been created to use a local source and a local destination. Also,
1790+
the workflow must have already been created as a custom worklow, and the workflow cannot have been created to run on a schedule.
1791+
1792+
The workflow's source and destination must both be local. You cannot run a workflow that specifies a local source and a remote destination, nor can you run a worklow that specifies a remote source
1793+
and a local destination.
1794+
1795+
The Unstructured user interface (UI) and the Unstructured Python SDK currently do not support running workflows that use a local source
1796+
and a local destination.
1797+
1798+
1. In the method drop-down list, select **POST**.
1799+
2. In the address box, enter the following URL:
1800+
1801+
```text
1802+
{{UNSTRUCTURED_API_URL}}/workflows/<workflow-id>/run
1803+
```
1804+
1805+
3. On the **Headers** tab, enter the following headers:
1806+
1807+
- **Key**: `unstructured-api-key`, **Value**: `{{UNSTRUCTURED_API_KEY}}`
1808+
- **Key**: `accept`, **Value**: `application/json`
1809+
1810+
4. On the **Body** tab, select **form-data**, and specify the settings for the workflow run:
1811+
1812+
- **Key**: `input_files`, **File**, **Value**: Click the **Value** box, then click **New file from local machine**, and select the file to upload.
1813+
- **Key**: `filename`, **Text**, **Value**: Type the name of the file that you just uploaded.
1814+
- **Key**: `type`, **Text**, **Value**: `<local-file-media-type>`
1815+
1816+
For a list of available media types, such as `application/pdf`, see [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml).
1817+
1818+
5. Click **Send**.
1819+
</Accordion>
17621820
</AccordionGroup>
17631821

17641822
To run a workflow on a schedule instead, specify the `schedule` setting in the request body when you create or update a
@@ -2284,3 +2342,51 @@ the `POST` method to call the `/jobs/<job-id>/cancel` endpoint (for `curl` or Po
22842342
4. Click **Send**.
22852343
</Accordion>
22862344
</AccordionGroup>
2345+
2346+
### Download a processed local file from a job
2347+
2348+
This applies only to jobs that use a workflow with a local source and a local destination.
2349+
2350+
To download a processed local file from a completed job, use `GET` to call the `/jobs/<job-id>/download` endpoint, replacing
2351+
`<job-id>` with the job's unique ID. To get this ID, see [List jobs](#list-jobs).
2352+
2353+
You must also provide Unstructured's IDs for the file to download and the workflow's output node. To get these IDs, see [Get a job](#get-a-job). In the
2354+
response:
2355+
2356+
- Unstructured's IDs for the file to download and the workflow's output node are in the `output_node_files` array.
2357+
- The ID for the file to download is in the `output_node_files` array's `file_id` field.
2358+
- The ID for the workflow's output node is in the `output_node_files` array's `node_id` field.
2359+
2360+
Currently, you cannot use the Unstructured user interface (UI) or the Unstructured Python SDK to download a file from a job that uses a
2361+
workflow with a local source and a local destination.
2362+
2363+
<AccordionGroup>
2364+
<Accordion title="curl">
2365+
```bash
2366+
curl --request 'GET' --location \
2367+
"$UNSTRUCTURED_API_URL/jobs/<job-id>/download?file_id=<file-id>&node_id=<node-id>" \
2368+
--header 'accept: application/json' \
2369+
--header "unstructured-api-key: $UNSTRUCTURED_API_KEY"
2370+
```
2371+
</Accordion>
2372+
<Accordion title="Postman">
2373+
1. In the method drop-down list, select **GET**.
2374+
2. In the address box, enter the following URL:
2375+
2376+
```text
2377+
{{UNSTRUCTURED_API_URL}}/jobs/<job-id>/download
2378+
```
2379+
2380+
3. On the **Headers** tab, enter the following headers:
2381+
2382+
- **Key**: `unstructured-api-key`, **Value**: `{{UNSTRUCTURED_API_KEY}}`
2383+
- **Key**: `accept`, **Value**: `application/json`
2384+
2385+
4. On the **Params** tab, enter the following query parameters:
2386+
2387+
- **Key**: `file_id`, **Value**: `<file-id>`
2388+
- **Key**: `node_id`, **Value**: `<node-id>`
2389+
2390+
5. Click **Send**.
2391+
</Accordion>
2392+
</AccordionGroup>

api-reference/workflow/workflows.mdx

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ specify the settings for the workflow, as follows:
193193
asyncio.run(create_workflow())
194194
```
195195
</Accordion>
196-
<Accordion title="curl">
196+
<Accordion title="curl (remote source and remote destination)">
197197
```bash
198198
curl --request 'POST' --location \
199199
"$UNSTRUCTURED_API_URL/workflows" \
@@ -222,7 +222,41 @@ specify the settings for the workflow, as follows:
222222
}'
223223
```
224224
</Accordion>
225-
<Accordion title="Postman">
225+
<Accordion title="curl (local source and local destination)">
226+
To use a local source and a local destination, do not specify a `source_id` or `destination_id` value. Also, the `workflow_type` must be set to `custom`.
227+
228+
The source and destination must both be local. You cannot specify a local source and a remote destination, nor can you specify a remote source
229+
and a local destination.
230+
231+
The Unstructured user interface (UI) and the Unstructured Python SDK currently do not support creating a workflow with a local source
232+
and a local destination.
233+
234+
```bash
235+
curl --request 'POST' --location \
236+
"$UNSTRUCTURED_API_URL/workflows" \
237+
--header "unstructured-api-key: $UNSTRUCTURED_API_KEY" \
238+
--header 'accept: application/json' \
239+
--data \
240+
'{
241+
"name": "<name>",
242+
"workflow_type": "custom",
243+
"workflow_nodes": [
244+
{
245+
"name": "<node-name>",
246+
"type": "<node-type>",
247+
"subtype": "<node-subtype>",
248+
"settings": {
249+
"...": "..."
250+
}
251+
},
252+
{
253+
"...": "..."
254+
}
255+
]
256+
}'
257+
```
258+
</Accordion>
259+
<Accordion title="Postman (remote source and remote destination)">
226260
1. In the method drop-down list, select **POST**.
227261
2. In the address box, enter the following URL:
228262

@@ -262,6 +296,51 @@ specify the settings for the workflow, as follows:
262296

263297
5. Click **Send**.
264298
</Accordion>
299+
<Accordion title="Postman (local source and local destination)">
300+
To use a local source and a local destination do not specify a `source_id` or `destination_id` value. Also, the `workflow_type` must be set to `custom`.
301+
302+
The source and destination must both be local. You cannot specify a local source and a remote destination, nor can you specify a remote source
303+
and a local destination.
304+
305+
The Unstructured user interface (UI) and the Unstructured Python SDK currently do not support creating a workflow with a local source
306+
and a local destination.
307+
308+
1. In the method drop-down list, select **POST**.
309+
2. In the address box, enter the following URL:
310+
311+
```text
312+
{{UNSTRUCTURED_API_URL}}/workflows
313+
```
314+
315+
3. On the **Headers** tab, enter the following headers:
316+
317+
- **Key**: `unstructured-api-key`, **Value**: `{{UNSTRUCTURED_API_KEY}}`
318+
- **Key**: `accept`, **Value**: `application/json`
319+
320+
4. On the **Body** tab, select **raw** and **JSON**, and specify the settings for the workflow:
321+
322+
```json
323+
{
324+
"name": "<name>",
325+
"workflow_type": "custom",
326+
"workflow_nodes": [
327+
{
328+
"name": "<node-name>",
329+
"type": "<node-type>",
330+
"subtype": "<node-subtype>",
331+
"settings": {
332+
"...": "..."
333+
}
334+
},
335+
{
336+
"...": "..."
337+
}
338+
]
339+
}
340+
```
341+
342+
5. Click **Send**.
343+
</Accordion>
265344
</AccordionGroup>
266345

267346
Replace the preceding placeholders as follows:

0 commit comments

Comments
 (0)