Attach files with the API
Upload text, pictures, PDFs and audio to a cloud project through the API, then attach them to a step.
You can add files to a step through the API, like Add file… in the editor. Text files take one call. Pictures, PDFs and audio take three steps, because the file goes straight to storage and is checked before it can be used.
Which files are accepted and how big they may be: supported file types. The same list is in GET /v1/capabilities (attachments.accepted) and in every file error.
The examples use {id} for the project id. Every call needs your key: Authorization: Bearer amk_live_….
Text files: one call
For .txt, .md, .mmd and .mermaid, send the name and the text:
POST /v1/projects/{id}/attachments{ "name": "interview-notes.md", "text": "# Interview\n- Budget approved in Q3\n- Decision maker: CFO" }The answer has status: "ready" and an upload_id. Attach it right away (see attach to a step).
Text must be UTF-8 and pass the content rules: no hidden characters, no instructions to an AI, no scripts.
Pictures, PDFs and audio: three steps
Ask for an upload link
POST /v1/projects/{id}/attachments{ "name": "call.mp3", "size": 2483112 }The answer (201) has status: "pending", an upload_id and upload.url, a one-time link valid 15 minutes, with the headers to send.
Send the file to the link
Send the raw bytes with PUT. Do not send your API key here; send only the headers from upload.headers:
curl -X PUT -H "Content-Type: audio/mpeg" --data-binary @call.mp3 "<upload.url>"Finish the upload
POST /v1/projects/{id}/attachments/{upload_id}/completeaiMermaid now checks the real file: its type (a PNG must really be a PNG, a PDF a real PDF), its size, and the project and account limits. On success the answer is status: "ready" with a sha256. Calling it again on a ready upload gives the same answer.
Quarantine and the 15-minute window
- Until
completehas checked the file, it is in quarantine: it cannot be attached or downloaded. - Call
completewithin 15 minutes of step 1. Later, the upload is closed (upload_expired) and you start again. - If the check fails, the stored file is deleted (
upload_deleted: truein the answer). Start again with step 1. - After a timeout,
GET /v1/projects/{id}/attachments/{upload_id}tells you the status (pendingorready), when it expires, and whether it is already attached. Repeat only the step that is missing.
Attach to a step
A ready upload is attached with the add_attachment operation in a batch:
POST /v1/projects/{id}/batch{ "ops": [ { "op": "add_attachment", "to": "n2", "upload_id": "8d0e7c52-1f3a-4b6d-9e2c-7a5b4c3d2e1f" } ] }to is a step or group id from the brief. The upload must belong to the same project. Uploads that are never attached are deleted after 24 hours.
Afterwards GET /v1/projects/{id}/brief lists the file on the step, with a download link.
To rename a file, or set the language of a voice recording, use update_attachment. See layout, groups and text.
Limits
- A project holds at most 200 files and 100 MB of attachments.
- Your plan's account storage counts too (see Free and PRO).
- The type comes from the file name ending and is checked against the real bytes. A renamed file is refused.
When something goes wrong
| Code | What happened | What to do |
|---|---|---|
unsupported_file_type (415) | The file ending is not accepted. The answer lists accepted. | Convert the file to an accepted type. |
invalid_file (422) | The bytes do not match the ending. The answer has reason, expected and detected. | Send the real file with the right ending. |
unsafe_content (422) | Text breaks a content rule. reasons names the rule. | Remove the flagged parts and upload again. |
plan_limit (403) | A limit would be passed. limit says which: file_size, project_files, project_bytes or account_storage, with max, used and size. | Use a smaller file, remove files, or free space. |
upload_not_ready (409) | You tried to attach a file before complete. | Call complete first. |
upload_expired (410) | More than 15 minutes passed. | Start again with step 1. |
unknown_upload (422) | No such upload in this project. | Check the upload_id and the project id. |
already_attached (422) | This upload is already attached. | Nothing to do: the file is already attached. |
For AI agents
- Always read
nextin each answer. It says which call comes next. - On an error, read
fix. It says what to change. - Never put the API key into the
PUTtoupload.url.
The full walkthrough is in the spec under x-examples.attach_a_file. Reference pages: start an upload, finish an upload, check an upload.