Endpoint
GET /tasks/{task_id}/steps/{step_id}/document
Authentication
This endpoint requires authentication via API key. Include your API key in the X-API-Key header:
X-API-Key: ca_your_api_key_here
Path Parameters
| Parameter | Type | Required | Description |
|---|
task_id | integer | Yes | Unique identifier for the task |
step_id | string | Yes | Unique identifier for the workflow step |
Request Example
curl -X GET "https://platform.chamelio.ai/tasks/12345/steps/review_step/document" \
-H "X-API-Key: ca_your_api_key_here" \
--output document.pdf
import requests
task_id = 12345
step_id = "review_step"
url = f"https://platform.chamelio.ai/tasks/{task_id}/steps/{step_id}/document"
headers = {
"X-API-Key": "ca_your_api_key_here"
}
response = requests.get(url, headers=headers)
# Save the document
if response.status_code == 200:
with open("document.pdf", "wb") as f:
f.write(response.content)
print("Document downloaded successfully")
else:
print(response.json())
const taskId = 12345;
const stepId = 'review_step';
const response = await fetch(
`https://platform.chamelio.ai/tasks/${taskId}/steps/${stepId}/document`,
{
method: 'GET',
headers: {
'X-API-Key': 'ca_your_api_key_here'
}
}
);
if (response.ok) {
const blob = await response.blob();
// Create download link
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.pdf';
a.click();
} else {
const error = await response.json();
console.error(error);
}
Response
Success Response
Status Code: 200 OK
The response contains a presigned URL or document metadata:
{
"download_url": "https://s3.amazonaws.com/...",
"file_name": "reviewed_contract.pdf",
"expires_at": "2025-01-20T12:00:00Z"
}
Response Fields
| Field | Type | Description |
|---|
download_url | string | Presigned URL to download the document |
file_name | string | Name of the document file |
expires_at | string | ISO 8601 timestamp when the download URL expires |
Error Responses
401 Unauthorized
Returned when authentication fails. See the authentication errors section for details.
{
"detail": "Invalid API key"
}
404 Not Found
Returned when the task, step, or document doesn’t exist.
{
"detail": "Document not found for step"
}
501 Not Implemented
Returned when the step hasn’t generated a document yet or doesn’t generate documents.
{
"detail": "Document not available for this step"
}
500 Internal Server Error
Returned when the request fails due to a server error.
{
"detail": "Failed to download step document"
}
Notes
This endpoint is specifically for documents generated by workflow steps (like document generation or AI review steps). For uploaded documents, use the Download File endpoint instead.
The presigned download URL expires after a certain time (indicated by expires_at). Download the file before the URL expires or request a new URL.
Use the List Task Files endpoint to discover which steps have generated documents and their associated step_id values.
Use Cases
This endpoint is useful for:
- Document retrieval - Download AI-generated or modified documents from workflows
- Contract export - Export reviewed, redlined, or approved contracts
- Archival - Save generated documents to external storage systems
- Distribution - Share workflow outputs with external stakeholders