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
400
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).400
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).400
photo_side_too_large The photo's longer side has more pixels than this request takes.400
unsupported_media_type The file's type is not one the route takes.400
document_unsupported_format The document's format is not one Werk reads.400
document_password_protected The document is protected by a password.400
document_unreadable The document could not be read.401
session_revoked The request carries no session the server holds, or its session has ended.401
session_expired The session has expired.404
conversation_not_found The project the request names, or its chat, is not one the signed-in person is in.404
upload_grant_invalid This upload address is not one Werk gave, or it was changed.409
session_changed The session changed while the request was in flight.409
project_deleted The project is being deleted.409
project_archived The project is archived, so it does not take this request.409
upload_grant_expired This upload address has expired and takes no file.409
idempotency_conflict The request's key, or the upload address it was sent to, was already used with other content.413
payload_too_large The request body has more bytes than the route takes.413
document_too_large The document has more bytes than Werk reads.429
rate_limited More requests of this kind were sent than Werk takes within the time it counts them over.500
server_error The 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 @fileTypeScript
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
Send a requestPUT
It is sent with the key you give, as you. A change made here is real.
File body Required
JSON
The request could not be sent, or its response could not be read.