DevelopersHow to connect an assistantKeys
Reference/Files/Change

Upload a file

PUThttps://api.getwerk.ai/api/v1/assets/{assetId}/upload/{grant}

Sends one file's bytes to the upload address its grant made.

It needs no key: the grant names who uploads and what. Sent again with the same bytes it changes nothing; other bytes are refused.

Path parameters

assetIdstring, uuidRequired

The upload's id, as the address names it.

grantstringRequired

The grant, as the address names it.

At least 1 character

Body

image/jpegaudio/mp4audio/x-m4aaudio/webmaudio/oggapplication/pdfapplication/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheettext/csvtext/plaintext/markdown

Response

204 The file is stored.

Errors

400invalid_queryThe 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).
400invalid_mediaThe 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).
400photo_side_too_largeThe photo's longer side has more pixels than this request takes.
400unsupported_media_typeThe file's type is not one the route takes.
400document_unsupported_formatThe document's format is not one Werk reads.
400document_password_protectedThe document is protected by a password.
400document_unreadableThe document could not be read.
401session_revokedThe request carries no session the server holds, or its session has ended.
401session_expiredThe session has expired.
404conversation_not_foundThe project the request names, or its chat, is not one the signed-in person is in.
404upload_grant_invalidThis upload address is not one Werk gave, or it was changed.
409session_changedThe session changed while the request was in flight.
409project_deletedThe project is being deleted.
409project_archivedThe project is archived, so it does not take this request.
409upload_grant_expiredThis upload address has expired and takes no file.
409idempotency_conflictThe request's key, or the upload address it was sent to, was already used with other content.
413payload_too_largeThe request body has more bytes than the route takes.
413document_too_largeThe document has more bytes than Werk reads.
rate_limitedMore requests of this kind were sent than Werk takes within the time it counts them over.
500server_errorThe server could not complete the request, and it is not known whether a write it holds was made.
curl
curl -X PUT "https://api.getwerk.ai/api/v1/assets/f3a9c1e7-5b2d-4c68-a4e0-9d7b3f1c5e82/upload/AQJ4c2VhbGVkLWdyYW50LWZvci10aGUtZmlsZQ" \
  -H "Content-Type: image/jpeg" \
  --data-binary @file
TypeScript
import { readFile } from "node:fs/promises";

const res = await fetch("https://api.getwerk.ai/api/v1/assets/f3a9c1e7-5b2d-4c68-a4e0-9d7b3f1c5e82/upload/AQJ4c2VhbGVkLWdyYW50LWZvci10aGUtZmlsZQ", {
  method: "PUT",
  headers: {
    "Content-Type": "image/jpeg",
  },
  body: await readFile("file"),
});
204