Get upload addresses
Makes one upload address per file to add, valid an hour, each with the most bytes it takes.
Each address carries its own grant, so the bytes are sent there with no key. The upload's id then goes in a card's attachments.
Authorization
Authorization: Bearer <key> Authentication
Path parameters
The project's id.
Body
One entry per file to upload, in order.
Show properties of filesHide properties of files
One of 2 shapes, told apart by kind:
kindimageimage for a photo, document for a document.
kinddocumentimage for a photo, document for a document.
The document's name as Werk will show it.
Response
200 The upload addresses.
One upload address per file, in the order asked.
Show properties of grantsHide properties of grants
The upload's id, which the card's request then names.
The address under the API's base to send the file's bytes to; it carries its own grant, so it needs no key.
The most bytes the file may have.
For a photo, the most pixels its longer side may have.
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_attachment A file the request names, or the way it names it, is not one the request takes there; 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_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).session_revoked The request carries no session the server holds, or its session has ended.session_expired The session has expired.photos_unavailable Photos are not open to the signed-in person.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.project_archived The project is archived, so it does not take this request.payload_too_large The request body has more bytes than the route takes.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/projects/2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73/upload-grants" \
-H "Authorization: Bearer wk_key_..." \
-H "Content-Type: application/json" \
-d '{
"files": [
{
"kind": "image"
},
{
"kind": "document",
"filename": "countertop-quote.pdf"
}
]
}'const res = await fetch("https://api.getwerk.ai/api/v1/projects/2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73/upload-grants", {
method: "POST",
headers: {
Authorization: "Bearer wk_key_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
"files": [
{
"kind": "image"
},
{
"kind": "document",
"filename": "countertop-quote.pdf"
}
]
}),
});
const answer = await res.json();{
"grants": [
{
"assetId": "f3a9c1e7-5b2d-4c68-a4e0-9d7b3f1c5e82",
"path": "/assets/f3a9c1e7-5b2d-4c68-a4e0-9d7b3f1c5e82/upload/AQJ4c2VhbGVkLWdyYW50LWZvci10aGUtZmlsZQ",
"maxBytes": 2097152,
"maxSide": 2048
},
{
"assetId": "a2d8f4b6-1c9e-4a37-8b5f-0e3c7a9d2f14",
"path": "/assets/a2d8f4b6-1c9e-4a37-8b5f-0e3c7a9d2f14/upload/AQJ4c2VhbGVkLWdyYW50LWZvci10aGUtZmlsZQ",
"maxBytes": 10485760
}
]
}Send a requestPOST
It is sent with the key you give, as you. A change made here is real.
The request could not be sent, or its response could not be read.