InterfacesAPI SpecSections
API Spec Designed
Base address: https://01scale.com/api/upload/v1. Open an endpoint for its inputs, constraints, errors and samples.
POST/filesCreate a file and get an upload link
Records a new file and returns a link the browser uses to send the file straight to private storage. The file itself never passes through the API. Signed in
Scope: upload:write
Inputs
file_namebodystringrequired- The name the person sees. Never used as the storage key.
- 1 to 255 characters after trimming; no
/,\or control characters. mimebodystringrequired- The file type the browser reports. Checked again against the real bytes on completion.
- One of
application/pdf,image/png,image/jpeg,application/json,text/csv, and allowed byacceptif given. sizebodyintegerrequired- The exact size in bytes. The upload link only accepts this size.
- 1 to 10,485,760 (10 MB), and at most
accept.max_bytesif given. acceptbodyobjectoptional- The calling app's own limits. DocFlow sends PDF, PNG and JPEG, 10 MB and 10 pages.
{mimes[], max_bytes, max_pages}; each value may only narrow the service's limits, never widen them.max_pages1 to 10, PDFs only.Idempotency-Keyheaderstringoptional- Makes a retried request safe.
- 1 to 255 characters. Same key and same body within 24 hours returns the first response.
What it does
- Checks the inputs against the service's limits and
accept, before anything is stored. - Creates the file with status
pending_uploadand storage keyusers/{owner_id}/{file_id}/original.{ext}, whereextcomes frommime. - Signs an S3 PUT link valid for 5 minutes.
Content-TypeandContent-Lengthare part of the signature, so S3 refuses a different type or size. - Records
file.createdin the audit log.
Responses
- 201The file was created.
file(statuspending_upload) andupload:url,method(alwaysPUT), theheadersthe browser must send, andexpires_at. - 413
file_too_largesizeis over 10 MB or overaccept.max_bytes. - 415
unsupported_file_typemimeis not one of the allowed types, or not allowed byaccept. - 422
validation_failedAnother input is missing or malformed;errors[]lists each field. - 422
idempotency_key_reusedThe sameIdempotency-Keywas sent with a different body. - 401
not_authenticatedNo valid access token. - 503
storage_unavailableAWS S3 could not be reached. Nothing was changed; safe to retry.
Sample request
POST /api/upload/v1/files HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>
Idempotency-Key: 8b1f6c2e-upload-1
Content-Type: application/json
{
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size": 248913,
"accept": {
"mimes": [
"application/pdf",
"image/png",
"image/jpeg"
],
"max_bytes": 10485760,
"max_pages": 10
}
}Sample response
{
"file": {
"id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size_bytes": 248913,
"pages": null,
"status": "pending_upload",
"rejection_reason": null,
"sha256": null,
"created_at": "2026-11-17T09:14:07Z",
"completed_at": null,
"expires_at": "2026-12-17T09:14:07Z"
},
"upload": {
"url": "https://01scale-uploads.s3.us-east-1.amazonaws.com/users/0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e/0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b/original.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE%2F20261117%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20261117T091407Z&X-Amz-Expires=300&X-Amz-SignedHeaders=content-length%3Bcontent-type%3Bhost&X-Amz-Signature=5f2c...",
"method": "PUT",
"headers": {
"Content-Type": "application/pdf",
"Content-Length": "248913"
},
"expires_at": "2026-11-17T09:19:07Z"
}
}POST/files/{fileId}/completeConfirm the upload and check the file
Called after the browser has sent the file. Upload checks what actually arrived in storage and marks the file ready or rejected. Safe to call more than once. Signed in
Scope: upload:write
Inputs
fileIdpathuuidrequired- The file to confirm.
- A file of the caller's.
What it does
- If the file is already
readyorrejected, returns it unchanged. - Asks S3 whether the object exists and compares its size with the size declared at creation.
- Reads the first bytes to confirm the real type:
%PDF-for PDF, the PNG signature,FF D8 FFfor JPEG; JSON must parse, CSV must be valid UTF-8 text. - For a PDF, counts its pages with a PDF parser (not by text search) and checks them against
accept.max_pages. An image counts as 1 page. - Passing: computes the SHA-256 of the content, sets status
ready,pagesandcompleted_at, and recordsfile.uploaded. - Failing a check: sets status
rejectedwith arejection_reason, deletes the object from S3, and recordsfile.rejected. This is still a200: the check ran and has an answer.
Responses
- 200The check has run.
filewith statusready, orrejectedand itsrejection_reason:type_mismatch,too_many_pages,unreadable. - 401
not_authenticatedNo valid access token. The gateway normally answers this before the request arrives. - 404
file_not_foundNo such file, or it belongs to another user. The same answer in both cases. - 409
upload_missingNothing has arrived in storage yet, for example the browser has not finished sending. Safe to retry. - 409
size_mismatchWhat arrived is not the declared size. The object is deleted; create a new file to try again. - 409
file_deletedThe file was deleted or has expired. - 503
storage_unavailableAWS S3 could not be reached. Nothing was changed; safe to retry.
Sample request
POST /api/upload/v1/files/0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b/complete HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"file": {
"id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size_bytes": 248913,
"pages": 2,
"status": "ready",
"rejection_reason": null,
"sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-11-17T09:14:07Z",
"completed_at": "2026-11-17T09:14:11Z",
"expires_at": "2026-12-17T09:14:07Z"
}
}GET/files/{fileId}Get one file
A file's details and status. Signed in
Scope: upload:read
Inputs
fileIdpathuuidrequired- The file.
- A UUID.
What it does
- Read only.
Responses
- 200The file exists and is the caller's.
file. - 401
not_authenticatedNo valid access token. The gateway normally answers this before the request arrives. - 404
file_not_foundNo such file, or it belongs to another user. The same answer in both cases.
Sample request
GET /api/upload/v1/files/0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"file": {
"id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size_bytes": 248913,
"pages": 2,
"status": "ready",
"rejection_reason": null,
"sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-11-17T09:14:07Z",
"completed_at": "2026-11-17T09:14:11Z",
"expires_at": "2026-12-17T09:14:07Z"
}
}GET/filesList my files
The caller's files, newest first. Signed in
Scope: upload:read
Inputs
statusquerystringoptional- Only files with this status.
- One of
pending_upload,ready,rejected. Deleted and expired files are never listed. cursorquerystringoptional- Where to continue.
- A
next_cursorfrom an earlier page, unchanged. limitqueryintegeroptional- How many to return.
- 1 to 100. Default 20.
What it does
- Read only. Ordered by
created_atthenid, newest first.
Responses
- 200Always, even when empty.
data[]of files andnext_cursor(null on the last page). - 422
validation_failedstatus,cursororlimitis not valid. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/upload/v1/files?status=ready&limit=2 HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"data": [
{
"id": "0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b",
"file_name": "acme-invoice-0042.pdf",
"mime": "application/pdf",
"size_bytes": 248913,
"pages": 2,
"status": "ready",
"rejection_reason": null,
"sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-11-17T09:14:07Z",
"completed_at": "2026-11-17T09:14:11Z",
"expires_at": "2026-12-17T09:14:07Z"
}
],
"next_cursor": null
}GET/files/{fileId}/download-urlGet a link to read the file
A link valid for 5 minutes that opens or downloads the file directly from storage. Signed in
Scope: upload:read
Inputs
fileIdpathuuidrequired- The file.
- A file of the caller's with status
ready. dispositionquerystringoptional- Show in the browser, or download.
inline(default) orattachment.filenamequerystringoptional- The name the downloaded file gets.
- 1 to 255 characters; same rules as
file_name. Default: the file'sfile_name.
What it does
- Signs an S3 GET link valid for 5 minutes, with the content type and
Content-Dispositionfixed in the signature. - Records
file.downloadedwhendispositionisattachment.
Responses
- 200The file is ready.
urlandexpires_at. - 401
not_authenticatedNo valid access token. The gateway normally answers this before the request arrives. - 404
file_not_foundNo such file, or it belongs to another user. The same answer in both cases. - 409
file_not_readyThe file is still uploading, or was rejected. - 410
file_expiredThe file was removed after 30 days. - 503
storage_unavailableAWS S3 could not be reached. Nothing was changed; safe to retry.
Sample request
GET /api/upload/v1/files/0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b/download-url?disposition=attachment HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"url": "https://01scale-uploads.s3.us-east-1.amazonaws.com/users/0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e/0193b0c4-2a10-7e55-8d31-6c7d8e9f0a1b/original.pdf?response-content-disposition=attachment%3B%20filename%3D%22acme-invoice-0042.pdf%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE%2F20261117%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20261117T091407Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=5f2c...",
"expires_at": "2026-11-17T09:25:00Z"
}DELETE/files/{fileId}Delete a file
Removes the stored object and marks the file deleted. Safe to call more than once. Signed in
Scope: upload:write
Inputs
fileIdpathuuidrequired- The file.
- A file of the caller's.
What it does
- Deletes the object from S3, sets status
deletedanddeleted_at, and recordsfile.deleted. - A file that is already deleted returns
204again.
Responses
- 204The file is deleted. No body.
- 401
not_authenticatedNo valid access token. The gateway normally answers this before the request arrives. - 404
file_not_foundNo such file, or it belongs to another user. The same answer in both cases. - 503
storage_unavailableAWS S3 could not be reached. Nothing was changed; safe to retry.
Sample request
DELETE /api/upload/v1/files/0193b0c9-5f22-7a08-9e44-1a2b3c4d5e6f HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
HTTP/1.1 204 No ContentPOST/eventsReceive platform events
Where other services' signed events arrive. In version 1 Upload acts on one: a user's account was deleted, so their files go too. Service
Scope: None: HMAC signature
Inputs
X-01scale-Signatureheaderstringrequired- Proves the event came from the platform.
- HMAC-SHA256 of the raw body with the shared events key, compared in constant time.
event_idbodyuuidrequired- The event's ID.
- Each event is processed once; a repeat returns
200with no effect. typebodystringrequired- What happened.
- Version 1 acts on
identity.user.deleted; other types are acknowledged and ignored. databodyobjectrequired- The event's details.
- For
identity.user.deleted:{user_id}.
What it does
- For
identity.user.deleted: deletes the object of each of that user's files, using the keys inupload.files(so the service never needs permission to list the bucket), marks the filesdeleted, and recordsfile.deletedfor each withreason: account_deleted.
Responses
- 200Accepted, including a repeat or an ignored type. No body.
- 401
invalid_signatureThe signature is missing or wrong.
Sample request
POST /api/upload/v1/events HTTP/1.1
X-01scale-Signature: sha256=8c1f...
Content-Type: application/json
{
"event_id": "0193b2aa-6f01-7c2d-9e3f-4a5b6c7d8e9f",
"type": "identity.user.deleted",
"occurred_at": "2026-11-17T10:00:00Z",
"data": {
"user_id": "0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e"
}
}Sample response
HTTP/1.1 200 OKErrors
Every error has the same shape and a stable code to branch on.
{
"type": "https://01scale.com/errors/file_too_large",
"title": "File too large",
"status": 413,
"detail": "This file is 14.2 MB. The limit is 10 MB.",
"code": "file_too_large",
"request_id": "req_0193a61f9c2e"
}Handled without an endpoint
- Sending the file (UPLOAD-V1-E2-02)
- The browser PUTs the bytes straight to S3 with the link from
POST /files, sending exactly theheadersreturned. Upload never receives the file's content through its API. - The storage bucket (UPLOAD-V1-E2-01)
- Private, encrypted, no public access, objects deleted after 30 days, and CORS open only to 01scale.com and localhost. Setup steps in
docs/infra/s3.md. - Abandoned uploads
- A daily clean-up deletes files still
pending_uploadafter 24 hours, and their object if one arrived. Files past 30 days are markedexpiredto match the bucket's own deletion. - DocFlow's endpoints in these stories
POST /api/docflow/v1/documents,…/upload-completeand the documents list belong to the DocFlow app, which calls this service. They are designed with the DocFlow app shell (DOCFLOW-V1-E0-09).- AI agents
- Each endpoint above is also a tool on Upload's MCP server,
POST /api/upload/mcp, with the same inputs and errors. An agent creates a file and receives the upload link; sending the bytes is an ordinary HTTPS PUT. - Health and contract
- Like every service, Upload also serves
GET /healthandGET /openapi.jsonfrom the service template (SERVICEKIT-V1-E0-05).
Constraints at the API level
mimemust be one of the five allowed types, and allowed byacceptif the app sent it.sizemust be between 1 byte and 10 MB, and withinaccept.max_bytes.acceptcan only narrow the service's limits, never widen them.file_nameis 1 to 255 characters, with no path separators or control characters; it is never used to build the storage key.- The owner is always the token's user; an app storing a file for a user uses a delegated token (decision on #24).
- Another user's file always answers
404 file_not_found, never403. - Upload and download links last 5 minutes, and fix the type and size (upload) or type and filename (download) in their signature.
POST /filesacceptsIdempotency-Key;completeandDELETEare idempotent by design.- Events must carry a valid signature and are processed once per
event_id. - Rate limits at the gateway (Nikhil's decision on #64): per user, 10 requests a minute that change something (POST, PUT, PATCH, DELETE) and 60 reads a minute; with an API key, 10 requests a minute in total. Over a limit,
429 rate_limitedwithRetry-After.