Attachments
List, upload, download, and delete files attached to a document
Overview
Attachment tools manage the files attached to a document: a PRD (PRD-*), an implementation plan (PLN-*), an issue (ISS-*; legacy FEA-* slugs still resolve), or an organization-level document (DOC-*). Every tool takes the document as entityId, which accepts a UUID or a slug; pass the user's slug verbatim and the API resolves it.
An attachment has a purpose:
| Purpose | Meaning |
|---|---|
context | A file attached to the document as supporting material. This is the default. |
inline | An image referenced from the document body with an attachment://<attachmentId> URL. Inline attachments must be images. |
| Tool | Scope |
|---|---|
list-attachments | read |
download-attachment | read |
upload-attachment | write |
create-inline-image-attachment | write |
delete-attachment | delete |
A tool is offered to a session only when the session's credential carries its scope. When a call fails, the tool returns an isError result whose text gives the error title, a description, and, when the API sent them, the error code, message, and timestamp.
Allowed file types and sizes
The API accepts these MIME types for upload-attachment:
| Kind | MIME types | Size limit |
|---|---|---|
| Media | video/quicktime, video/mp4, audio/mpeg | 524,288,000 bytes (500 MiB) |
| Images | image/jpeg, image/png, image/gif, image/webp | 10,485,760 bytes (10 MiB) |
| Other files | application/pdf, text/csv, application/json, text/plain, text/markdown, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 10,485,760 bytes (10 MiB) |
create-inline-image-attachment accepts only the four image types, up to 524,288 bytes (512 KiB) of decoded image data.
List Attachments
Tool: list-attachments
Scope: read
Underlying API: GET /documents/{entityId}/attachments (with ?purpose=<value> when purpose is given)
| Name | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Document UUID or slug (e.g. PRD-7, PLN-12, ISS-42). Blank values, ., and .. are rejected. |
purpose | "context" | "inline" | "all" | No | Which attachments to list. When omitted, the API lists context attachments only. |
limit | integer | No | Page size, 1–100. Default 25. |
offset | integer | No | Starting offset, minimum 0. Default 0. |
The API returns at most 200 attachments for a document, newest first. The tool pages over that list locally with limit and offset.
Returns
A paginated envelope:
{
"total": 2,
"offset": 0,
"limit": 25,
"returned": 2,
"hasMore": false,
"nextOffset": null,
"items": [
{
"id": "6f1c2d3e-...",
"artifactId": "0b9a8c7d-...",
"filename": "architecture.png",
"mimeType": "image/png",
"sizeBytes": 48213,
"purpose": "context",
"createdAt": "2026-10-01T12:00:00.000Z",
"createdById": "a1b2c3d4-...",
"previewUrl": "https://..."
}
]
}previewUrl is a signed URL that is present only for image attachments, and is omitted when the URL could not be signed. Call again with offset: nextOffset while hasMore is true.
Errors
- The document does not exist in your organization:
Document not found(404). - An unrecognized
purposevalue is rejected by input validation.
Example
list-attachments(entityId: "PRD-7", purpose: "all")Upload an Attachment
Tool: upload-attachment
Scope: write
Underlying API: POST /documents/{entityId}/attachments
The tool does not take file bytes. It asks the API for a presigned upload URL; you then upload the bytes yourself with an HTTP PUT to that URL, using exactly the mimeType and sizeBytes you declared. After the upload, call list-attachments to see the attachment.
| Name | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Document UUID or slug. |
filename | string | Yes | Original filename to store. 1–255 characters (the 255 limit is enforced by the API). |
mimeType | string | Yes | The MIME type the PUT must use. Must be one of the allowed types. |
sizeBytes | integer | Yes | Declared byte size the PUT must match. Positive; at most 524,288,000 for media types and 10,485,760 for every other type. |
purpose | "context" | "inline" | No | Defaults to context. inline requires an image MIME type. |
Returns
The API response, as JSON:
{
"attachmentId": "6f1c2d3e-...",
"uploadUrl": "https://...",
"key": "...",
"expiresAt": "2026-10-01T12:15:00.000Z"
}The upload URL is signed for 15 minutes; use it right away. expiresAt may be absent when the API predates it. The response may also carry an operationReceipt object recording the write.
Errors
- The document does not exist in your organization:
Document not found(404). - A MIME type outside the allowed list, a filename over 255 characters, or a non-media file over 10,485,760 bytes: a 400 validation error.
purpose: "inline"with a non-image MIME type: a 400 (inline attachments must use one of: image/jpeg, image/png, image/gif, image/webp).- Too many uploads: a 429 with code
attachment_upload_rate_limitedandretryAfterSecondsin the details.
Example
upload-attachment(entityId: "PLN-12", filename: "spec.pdf", mimeType: "application/pdf", sizeBytes: 182044)Create an Inline Image Attachment
Tool: create-inline-image-attachment
Scope: write
Underlying API: POST /documents/{entityId}/attachments/images
Stores an image from base64 bytes in one call and returns a reference you can put in the document's Markdown. Use this when you have the image bytes in hand and want to embed the image in a document body; to put the reference in the document, append a new version with create-document-version.
| Name | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Document UUID or slug. The document must already exist. |
filename | string | Yes | Image filename to store. 1–255 characters (the 255 limit is enforced by the API). |
mimeType | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | Yes | MIME type of the bytes. The API checks that the bytes match it. |
dataBase64 | string | Yes | Raw base64 image bytes, with no data: URL prefix. 1–699,052 characters (512 KiB of image data). |
altText | string | No | Alt text for the returned Markdown snippet. When omitted or blank, the filename is used. |
Returns
The tool returns the result both as text and as structured content:
{
"attachmentId": "6f1c2d3e-...",
"attachmentRef": "attachment://6f1c2d3e-...",
"markdownImage": "",
"attachment": {
"id": "6f1c2d3e-...",
"artifactId": "0b9a8c7d-...",
"filename": "login.png",
"mimeType": "image/png",
"sizeBytes": 48213,
"purpose": "inline",
"createdAt": "2026-10-01T12:00:00.000Z",
"createdById": "a1b2c3d4-...",
"previewUrl": "https://..."
}
}The submitted bytes and the storage key are never returned. previewUrl is omitted when the API does not return one. The response may also carry an operationReceipt object.
Errors
| Code | Status | Cause |
|---|---|---|
document_not_found | 404 | The document does not exist in your organization. |
invalid_inline_image_base64 | 400 | dataBase64 is not raw canonical base64. |
inline_image_mime_mismatch | 400 | The bytes do not match the declared mimeType. |
unsupported_image_mime_type | 400 | The MIME type is not a supported image type. |
inline_image_too_large | 413 | The image, or the request body (768 KiB limit), is too large. |
attachment_upload_rate_limited | 429 | Too many uploads; retry after retryAfterSeconds. |
file_attachments_storage_unconfigured | 503 | File storage is not configured on the server. |
attachment_storage_write_failed | 502 | Storing the image failed. |
attachment_persistence_failed | 500 | Recording the attachment failed. |
Example
create-inline-image-attachment(entityId: "ISS-42", filename: "login.png", mimeType: "image/png", dataBase64: "iVBORw0KGgo...", altText: "Login screen")Download an Attachment
Tool: download-attachment
Scope: read
Underlying API: GET /documents/{entityId}/attachments/{attachmentId}
| Name | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | UUID or slug of the document the attachment belongs to. The attachment is looked up only on that document in your organization. |
attachmentId | string | Yes | Attachment UUID, from list-attachments. |
Returns
{
"downloadUrl": "https://..."
}The URL is signed for one hour and asks the browser to download the file under its stored filename. Download the file soon after the call.
Errors
- The document does not exist in your organization:
Document not found(404). - No attachment with that id on that document:
Attachment not found(404).
Example
download-attachment(entityId: "PRD-7", attachmentId: "6f1c2d3e-...")Delete an Attachment
Tool: delete-attachment
Scope: delete
Underlying API: DELETE /documents/{entityId}/attachments/{attachmentId}
Removes one attachment from a document. Over MCP you can delete only attachments that you created: the MCP server calls the API with your API key, and for API-key requests the API deletes an attachment only when its creator is the authenticated user.
| Name | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | UUID or slug of the document the attachment belongs to. |
attachmentId | string | Yes | Attachment UUID, from list-attachments. |
Returns
The API's delete acknowledgement, for example:
{
"deleted": true
}The response may also carry an operationReceipt object.
Errors
- The document does not exist in your organization:
Document not found(404). - No attachment with that id on that document, or the attachment was created by someone else:
Attachment not found(404). The two cases return the same error.
Example
delete-attachment(entityId: "PRD-7", attachmentId: "6f1c2d3e-...")