Get Workflow
This guide explains how to retrieve a specific Workflow from your account using its ID.
Get a Workflow by ID
API Endpoint
GET https://api.documentpro.ai/v1/templates/{template_id}
Path Parameters
template_id
(required): The unique identifier of the Workflow you want to retrieve.
Example implementation using Python
import requests
# Your API key
api_key = 'YOUR_API_KEY'
template_id = 'YOUR_TEMPLATE_ID'
url = f"https://api.documentpro.ai/v1/templates/{template_id}"
headers = {
'x-api-key': api_key
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print('Workflow retrieved successfully')
print(response.json())
else:
print('Failed to retrieve Workflow')
print(response.text)
Successful response body
Example response with status code 200
:
{
"template_id": "710a20fc-e280-43eb-9a9f-5436e600c710",
"template_title": "Custom Invoice Workflow",
"template_type": "Invoice",
"template_category": "other",
"template_schema": {
"fields": [
{
"name": "buyer_name",
"type": "text",
"description": "name of the buyer"
},
{
"name": "total_amount",
"type": "number"
},
{
"name": "line_items",
"type": "table",
"description": "invoice line items",
"subFields": [
{
"name": "description",
"type": "text",
"description": "description of item"
},
{
"name": "subtotal",
"type": "number"
}
]
}
]
},
"email_id": "custom_invoice_workflow_fbb499@inbox.documentpro-ai.com",
"webhook_url": null,
"parser_config": {
"parse_email_attachments": true,
"parse_email_body": false,
"date_format": null,
"outbound_integration": null,
"ocr_config": {
"engine": "aws_textract",
"detect_layout": true,
"detect_tables": false,
"remove_headers": true,
"remove_footers": true,
"remove_tables": false
},
"query_config": {
"query_model": "gpt-4o-mini",
"set_max_output_tokens": false,
"include_example": false,
"minimize_tokens": true,
"selected_language": null
}
},
"created_at": "2023-11-15T12:13:12.056281"
}
Error responses
- If the Workflow is not found (status code
404
):
{
"success": false,
"error": "not_found",
"message": "Workflow not found"
}
- For other errors (status codes
400
,401
,403
, and500
):
{
"success": false,
"error": "error_code",
"message": "descriptive error message"
}
Using the retrieved Workflow
Once you've successfully retrieved a Workflow, you can use its details to:
- Understand the structure of data it extracts (
template_schema
). - See its configuration settings (
parser_config
). - Use its
template_id
for other operations, such as updating the Workflow or processing documents with it. - Check its associated email address (
email_id
) for submitting documents via email.
Remember to handle potential errors in your application, especially the case where a Workflow might not be found.