Upload a file directly
Uploads one photo, document or voice recording as its bytes, for a card, a project, the key's person's photo or a report to use.
Its kind follows Content-Type: a JPEG is a photo, a document's type or Werk-Filename a document, an audio type a recording. An upload not used within 24 hours is let go.
Authorization
Authorization: Bearer <key> Authentication
Headers
The language tag Werk writes the answer's own words in, such as step names and history lines, matched to a language it serves; a card's text stays as written. At a project's paths, the reads of its cards and steps, of a card, its update photos, a file and its reminders, and of follow and reminder invitations, and a document's read-now and consent, take the language of the person's chat with Werk in that project first, while it has one. Without either, the language Werk uses with the person the key or the connection acts for.
An id the caller makes for this request; sent again with it and the same bytes, it changes nothing twice.
A document's name, percent-encoded.
Query parameters
The project the upload is for.
profile_photo for the key's person's photo, account_feedback for a report's recording; it takes no project.
Body
Response
201 The upload.
The file's id.
What the file is: a photo, a voice recording or a document.
The document's name; only a document has one.
The document's format; only a document has one.
The file's media type.
The file's size in bytes.
The photo's width in pixels; absent on photos stored before sizes were kept.
The photo's height in pixels; absent on photos stored before sizes were kept.
The recording's length in seconds; only a voice recording has one.
False once the file's bytes were released and it can no longer be read.
Errors
invalid_query The query is not in the form the route takes; the limit is in the unit of the input details.field names (characters for a text, entries for a list, the value for a number).invalid_idempotency_key The Idempotency-Key header is not a uuid.conversation_required The request names no project, and the session has no project of its own to use.invalid_media The file, its name or the request about it is not in a form the route takes; the limit is in the unit of the input details.field names (characters for a text, entries for a list, the value for a number).photo_side_too_large The photo's longer side has more pixels than this request takes.unsupported_media_type The file's type is not one the route takes.document_unsupported_format The document's format is not one Werk reads.document_password_protected The document is protected by a password.document_unreadable The document could not be read.session_revoked The request carries no session the server holds, or its session has ended.session_expired The session has expired.not_for_client The route, setting or input the request names is open only to Werk's own apps, and the request's session is a connected app's or an API key's.conversation_not_found The project the request names, or its chat, is not one the signed-in person is in.session_changed The session changed while the request was in flight.project_deleted The project is being deleted.idempotency_conflict The request's key, or the upload address it was sent to, was already used with other content.payload_too_large The request body has more bytes than the route takes.document_too_large The document has more bytes than Werk reads.rate_limited More requests of this kind were sent than Werk takes within the time it counts them over.server_error The server could not complete the request, and it is not known whether a write it holds was made.curl -X POST "https://api.getwerk.ai/api/v1/assets?project=2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73" \
-H "Authorization: Bearer wk_key_..." \
-H "Idempotency-Key: f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4e03" \
-H "Content-Type: image/jpeg" \
--data-binary @fileimport { readFile } from "node:fs/promises";
const res = await fetch("https://api.getwerk.ai/api/v1/assets?project=2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73", {
method: "POST",
headers: {
Authorization: "Bearer wk_key_...",
"Idempotency-Key": "f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4e03",
"Content-Type": "image/jpeg",
},
body: await readFile("file"),
});
const answer = await res.json();{
"id": "f3a9c1e7-5b2d-4c68-a4e0-9d7b3f1c5e82",
"kind": "image",
"mimeType": "image/jpeg",
"sizeBytes": 482113,
"width": 1600,
"height": 1200
}Send a requestPOST
This request cannot be sent from this page. Run its example instead.