Upload an attachment to any supported entity
curl --request POST \
--url https://api.trycomp.ai/v1/attachments \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"fileName": "document.pdf",
"fileType": "application/pdf",
"entityId": "tsk_abc123def456",
"entityType": "task"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fileName: 'document.pdf',
fileType: 'application/pdf',
entityId: 'tsk_abc123def456',
entityType: 'task'
})
};
fetch('https://api.trycomp.ai/v1/attachments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.trycomp.ai/v1/attachments"
payload = {
"fileName": "document.pdf",
"fileType": "application/pdf",
"entityId": "tsk_abc123def456",
"entityType": "task"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "att_abc123def456",
"name": "document.pdf",
"type": "application/pdf",
"size": 1024000,
"downloadUrl": "https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...",
"createdAt": "2024-01-15T10:30:00Z",
"reviewPending": false,
"uploadedBy": {
"id": "usr_abc123def456",
"name": "Jane Doe"
},
"markedReviewedAt": "2024-01-16T09:00:00Z",
"markedReviewedBy": {
"id": "usr_abc123def456",
"name": "Jane Doe"
}
}{
"message": "File size exceeds maximum allowed size of 100MB"
}{
"message": "Unauthorized"
}Attachments
Upload an attachment to any supported entity | Comp AI API
Upload a base64-encoded file and attach it to a task, vendor, risk, comment, or other supported entity type. The file is uploaded to S3 and a database.
POST
/
v1
/
attachments
Upload an attachment to any supported entity
curl --request POST \
--url https://api.trycomp.ai/v1/attachments \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"fileName": "document.pdf",
"fileType": "application/pdf",
"entityId": "tsk_abc123def456",
"entityType": "task"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fileName: 'document.pdf',
fileType: 'application/pdf',
entityId: 'tsk_abc123def456',
entityType: 'task'
})
};
fetch('https://api.trycomp.ai/v1/attachments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.trycomp.ai/v1/attachments"
payload = {
"fileName": "document.pdf",
"fileType": "application/pdf",
"entityId": "tsk_abc123def456",
"entityType": "task"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "att_abc123def456",
"name": "document.pdf",
"type": "application/pdf",
"size": 1024000,
"downloadUrl": "https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...",
"createdAt": "2024-01-15T10:30:00Z",
"reviewPending": false,
"uploadedBy": {
"id": "usr_abc123def456",
"name": "Jane Doe"
},
"markedReviewedAt": "2024-01-16T09:00:00Z",
"markedReviewedBy": {
"id": "usr_abc123def456",
"name": "Jane Doe"
}
}{
"message": "File size exceeds maximum allowed size of 100MB"
}{
"message": "Unauthorized"
}Body
application/json
Base64-encoded file contents. For the web UI / direct callers. AI/MCP clients should instead upload via /v1/uploads/presign (purpose=attachment) and pass s3Key — base64 through an LLM is impractically slow and times out. Provide exactly one of fileData or s3Key.
Example:
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
Response
Attachment uploaded successfully
Was this page helpful?

