Files and attachments (API)
Files reach Sofia Space in three steps: you ask for an upload, send the bytes straight to storage on the address you get back, then confirm. The confirmed file can then be attached to a task or a docs page — for example a signed contract PDF from your CRM, or a monthly report from your ERP.
Scope: uploading needs tasks:write or docs:write; attaching to a task needs tasks:write, to a page docs:write; listing needs tasks:read or docs:read. You must be able to edit the task or page. Tokens with only the script scopes (task:create, doc:create) can’t upload.
Size limit per file: the smaller of your plan’s largest-file limit and 100 MB. On Free that is 25 MB; on paid plans, 100 MB. Every upload also counts toward the workspace’s storage. See Limits.
Upload and attach a file: the whole flow
Section titled “Upload and attach a file: the whole flow”Example: attach contract-1042.pdf (248,113 bytes) to task SALES-42.
-
Compute the file’s SHA-256 (64 hex characters):
Terminal window shasum -a 256 contract-1042.pdf# 28eb2bd698097d10caa10931fa26e05b2afa5e2c2fdec83df7d292659dfec556 contract-1042.pdf -
Ask for an upload.
moduleistaskfor a task attachment ordocfor a page attachment. Send it: without it the 25 MB chat limit applies:Terminal window curl -X POST https://acme.sofiaspace.uz/api/v1/files/upload-requests \-H "Authorization: Bearer $SOFIA_TOKEN" \-H "Content-Type: application/json" \-d '{"orgId": "6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20","fileName": "contract-1042.pdf","mimeType": "application/pdf","sizeBytes": 248113,"checksum": "28eb2bd698097d10caa10931fa26e05b2afa5e2c2fdec83df7d292659dfec556","module": "task"}'{"fileId": "d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13","alreadyExists": false,"uploadUrl": "https://files.sofiaspace.uz/...signed-address...","expiresInSeconds": 900}If
alreadyExistsistrue, you already uploaded a file with the same SHA-256 to this workspace:uploadUrlis empty, so skip steps 3 and 4 and attachfileId(step 5). This happens only for your own earlier uploads (with a token, the token owner’s). A file someone else uploaded is never reused, even with identical bytes: you get a newfileIdand anuploadUrl. -
Send the bytes to
uploadUrlwith aPUT, with the sameContent-Typeyou declared and noAuthorizationheader:Terminal window curl -X PUT -H "Content-Type: application/pdf" \--upload-file contract-1042.pdf "$UPLOAD_URL"Do it before the address expires (
expiresInSeconds). -
Confirm the upload:
Terminal window curl -X POST https://acme.sofiaspace.uz/api/v1/files/d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13/confirm \-H "Authorization: Bearer $SOFIA_TOKEN"{"id": "d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13","orgId": "6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20","uploadedBy": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21","fileName": "contract-1042.pdf","mimeType": "application/pdf","sizeBytes": 248113,"checksum": "28eb2bd698097d10caa10931fa26e05b2afa5e2c2fdec83df7d292659dfec556","status": "ACTIVE","createdAt": "2026-11-14T08:00:00Z","confirmedAt": "2026-11-14T08:00:03Z"}Confirming checks that the bytes arrived, that their size is exactly
sizeBytes, that their content is the kind of filemimeTypesays (an image declared asimage/pngmust really be an image), and that their SHA-256 is thechecksumyou declared. If not, you get409and the uploaded bytes are thrown away; the file stays unconfirmed. Upload the right bytes again to the sameuploadUrlwhile it is valid and confirm again, or start again from step 2.This is also when the file counts toward the workspace’s storage: a workspace that is full gets
409 ENTITLEMENT_DENIED. -
Attach it to the task (or the page, below):
Terminal window curl -X POST https://acme.sofiaspace.uz/api/v1/tasks/7c3e9a15-2d4f-4b6a-9e8c-1f3a5b7d9e20/attachments \-H "Authorization: Bearer $SOFIA_TOKEN" \-H "Content-Type: application/json" \-d '{"fileId":"d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13"}'{"id": "e5a7b9c2-4f6d-4e8a-8b2d-3f5a7c9e1b24","taskId": "7c3e9a15-2d4f-4b6a-9e8c-1f3a5b7d9e20","fileId": "d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13","filename": "contract-1042.pdf","contentType": "application/pdf","sizeBytes": 248113,"uploadedBy": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21","uploadedAt": "2026-11-14T08:00:04Z"}The file now shows under the task’s attachments in the app.
Ask for an upload
Section titled “Ask for an upload”POST /api/v1/files/upload-requests — Scope: tasks:write or docs:write.
| Field | Type | Required | Meaning |
|---|---|---|---|
orgId |
string | yes | Your organization ID |
fileName |
string | yes | Name shown in Sofia Space, with its extension |
mimeType |
string | yes | For example application/pdf, image/png |
sizeBytes |
integer | yes | Exact size in bytes, more than 0 |
checksum |
string | yes | SHA-256 of the bytes, exactly 64 hex characters (upper or lower case; stored lower-case). It is checked against the bytes when you confirm |
module |
string | send it | task or doc. Leaving it out applies the chat limit of 25 MB |
Limits:
- Size: 100 MB for
taskanddoc, and never more than your plan’s largest file (25 MB on Free, 250 MB on Pro, 500 MB on Business). In practice: 25 MB on Free, 100 MB on paid plans. - Type:
.exe,.dll,.bat,.cmd,.com,.scr,.msi,.jar,.app,.deband.rpmfiles are refused. - Rate: at most 120 upload requests a minute per person; more gets
429withRetry-After. - The upload address works for 15 minutes (
expiresInSeconds:900).
Errors:
| Status | code or error |
When |
|---|---|---|
400 |
INVALID_ARGUMENT |
Over 100 MB for the module (“File exceeds the maximum upload size …”), a refused extension, a missing field, or a checksum that isn’t 64 hex characters (“checksum must be the file’s SHA-256 as 64 hex characters”) |
403 |
NOT_ORG_MEMBER |
orgId is not your token’s workspace |
409 |
ENTITLEMENT_DENIED (key: file.max.mb) |
Over your plan’s largest file |
429 |
RATE_LIMITED |
Over 120 upload requests a minute |
Confirm an upload
Section titled “Confirm an upload”POST /api/v1/files/{fileId}/confirm — Scope: tasks:write or docs:write. No body. Safe to repeat: confirming a file that is already confirmed returns it unchanged. Returns the file; checksum is only shown to the person who uploaded it.
Errors: 409 FAILED_PRECONDITION when the bytes never arrived, the size differs from sizeBytes, the content isn’t the declared type, or its SHA-256 isn’t the declared checksum (“Uploaded content does not match the declared SHA-256 checksum for file …”). The bytes are deleted and the file stays unconfirmed: upload the right bytes and confirm again. 409 ENTITLEMENT_DENIED (key: storage.total.gb) when the workspace’s storage is full.
Task attachments
Section titled “Task attachments”GET /api/v1/tasks/{taskId}/attachments — Scope: tasks:read. Returns {"attachments": [ … ]} with the attachment shape shown above.
POST /api/v1/tasks/{taskId}/attachments — Scope: tasks:write. Body {"fileId": "…"}. Returns 200 and the attachment. The name, type and size come from the confirmed file, not from your request. The file must be confirmed and belong to the same workspace.
Page attachments
Section titled “Page attachments”GET /api/v1/pages/{pageId}/attachments — Scope: docs:read. Returns {"attachments": [ … ]} in the same shape, with pageId instead of taskId.
POST /api/v1/pages/{pageId}/attachments — Scope: docs:write. Body {"fileId": "…"}. Returns 200 and the attachment. Upload with "module": "doc".
What you can’t do with the API
Section titled “What you can’t do with the API”- You can’t download a file with a token: lists show names, types and sizes, but not download links. The
…/attachments/{fileId}/download-urlroutes refuse tokens with403and"error": "SIGNED_IN_APP_ONLY". Download in the app. - You can’t remove an attachment with a token:
DELETE /api/v1/tasks/{taskId}/attachments/{attachmentId}andDELETE /api/v1/pages/{pageId}/attachments/{attachmentId}refuse tokens with403and"error": "SIGNED_IN_APP_ONLY". Remove it in the app. (AI apps signed in through the Sofia Space MCP server can.) - You can’t put files into Drive, chat or a user’s avatar with a token, or reuse a file someone else uploaded without uploading it yourself.
- Files over 100 MB can’t be uploaded through the API, on any plan.
Related
Section titled “Related”- Description and attachments — files on tasks in the app
- Images and attachments — files on pages
- Rate limits and size limits