Skip to main content
Upload File
Uploads a file directly to storage without processing. The file must be a PDF, JPEG, PNG or WebP; any other type is refused with 400 storage/unsupported-file-type. The file type is inferred automatically from the MIME type. The uploaded file isn’t attached to anything: it has no entity, comment, space or event. A file that belongs to a record is sent with that record’s own request (for example, the images and files of Create Entity or Create Comment, or the cover of Update Event). This endpoint accepts multipart/form-data. Requires an authenticated user. Rate limit: 10 requests per 5 minutes.

Body Parameters

file
required
The file to upload: PDF, JPEG, PNG or WebP. Maximum 50 MB.
string
Stringified JSON: { "pathParts": [...] }, the same object as an inline files.options. pathParts are the folder segments the file is stored under; the new file’s id is always added after them, so the file is stored under <pathParts>/<fileId>/<filename>. Example: { "pathParts": ["documents", "user-123"] } → documents/user-123/<fileId>/<filename>. Each part is slugified. Without file.options, or with no or an empty pathParts, the file is stored under files. pathParts is the only key file.options takes; any other (an image option such as mode, sent here by mistake) is refused with 400 storage/invalid-body, param naming it. A part that is, or becomes, a . or .. folder is refused with 400 storage/invalid-body and param file.options.pathParts.
string
Stringified JSON object of custom key-value data stored on the file. The server adds originalFilename alongside, replacing any value of yours under that key. Anything other than a JSON object is refused with 400 storage/invalid-body.
string
Service key only: the user this request acts as, who owns the uploaded file; the upload runs under that user’s own checks. Leave it out to upload an app-owned file with no owning user. A user that doesn’t exist returns 404 storage/user-not-found. A user token always acts as its own user and must not send it (400 storage/acting-user-not-allowed).

Response

201 Created with the File, the same shape Fetch File returns. The file is stored as uploaded, so image is null, even for an image.
The type field is one of: image, video, document, other. It is inferred from the MIME type.

Error Responses

Returned with no JSON body: 401 when no Authorization header is sent, 403 when the access token is invalid or expired. Checked before any uploaded file is read, so a request with no credentials gets 401 rather than a body or acting-user error.
A user token sent actingUserId, even naming its own user. Only a service key names the user it acts as; a user token always acts as its own user.
The request sent a top-level pathParts. The folder goes inside file.options. Nothing is stored:
The request sent position. A file uploaded here belongs to no record, so it has no place in a list. Nothing is stored:
The request sent entityId, commentId, spaceId or eventId. A file uploaded here isn’t attached to anything, so these fields are refused rather than ignored, and nothing is stored. param names the field:
The request sent userId. On this route the user a service key acts as is actingUserId.With a service key:
With a user token:
file.options or metadata was refused. Nothing is stored. param names the field.file.options isn’t valid JSON:
A folder in pathParts is, or becomes once slugified, . or ..:
When the folder only becomes . or .. through slugifying, error is the message alone, without the file.options.pathParts: prefix.file.options has a key other than pathParts. param names the first one:
A file.options that isn’t a JSON object, a pathParts that isn’t an array of strings, or metadata that isn’t a JSON object, gets the same code, with param naming the value.
Returned when a service key names an actingUserId that isn’t a user in this project. Checked before the upload.
A file was refused as the body was read: storage/unsupported-file-type or storage/unexpected-file-field, with param naming the field when there is one. A body over 250 MB gets 413 request/body-too-large; one that can’t be read at all gets request/invalid-multipart or request/field-too-large. See Upload errors.