Skip to documentation
Dashboard
Attachments

Prepare an attachment

Reserve storage and receive a short-lived upload instruction for one private file.

POST/api/v1/attachments
On this page

Authentication

Send a RouteKite API key as a Bearer token. This endpoint requires the email:send scope.

Required headers
NameTypeRequirementDescription
AuthorizationstringRequiredBearer API key with the required workspace scope.Example: Bearer rk_your_key
Content-TypestringRequiredMust be application/json.Example: application/json

Request body

Request fields
NameTypeRequirementDescription
filenamestringRequiredOriginal filename with a supported extension. Maximum 255 characters.Example: invoice.pdf
content_typestringRequiredThe exact supported MIME type for the filename.Example: application/pdf
size_bytesintegerRequiredThe exact positive byte size, up to 10,000,000 bytes.Example: 245800
sha256stringRequiredThe lowercase 64-character SHA-256 digest of the exact bytes.Example: 0123456789abcdef...
retentionenumOptionalauto_delete by default, or keep until explicit deletion.Example: auto_delete

Response

Response fields
NameTypeRequirementDescription
iduuidAlwaysThe pending attachment ID.
statusenumAlwayspending after preparation.
retentionenumAlwaysThe selected retention mode.
upload.methodstringAlwaysUse this exact method.
upload.urlurlAlwaysOpaque upload destination.
upload.headersobjectAlwaysUse these exact headers.
upload.expires_atdate-timeAlwaysWhen the instruction expires.

Behavior

The upload instruction expires after two hours. Upload the exact bytes described by the prepared metadata.

Errors

StatusCodeWhat it meansWhat to do
400INVALID_REQUESTAttachment metadata is invalid.Confirm filename, type, size, and digest.
401UNAUTHORIZEDThe API key is invalid.Check the Bearer header.
403FORBIDDENThe key cannot manage attachments.Use email:send access.
404ATTACHMENT_NOT_FOUNDThe attachment is unavailable in this workspace.Check the ID and workspace.
410ATTACHMENT_EXPIREDThe upload instruction or file expired.Prepare a new upload.
413STORAGE_LIMIT_EXCEEDEDThe account cannot reserve this file.Remove unused files and retry.
422ATTACHMENT_TYPE_UNSUPPORTEDThe format is not accepted.Use a supported format.
422ATTACHMENT_INVALIDThe bytes do not match the prepared metadata.Recalculate and upload the exact file.
500 / 503ATTACHMENT_UNAVAILABLEThe operation could not complete.Retry after a short delay.