DevelopersHow to connect an assistantKeys
Reference/Files/Create

Get upload addresses

POSThttps://api.getwerk.ai/api/v1/projects/{projectId}/upload-grants

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

AuthorizationheaderRequired

Authorization: Bearer <key> Authentication

Path parameters

projectIdstring, uuidRequired

The project's id.

Body

filesarray of objectsRequired

One entry per file to upload, in order.

From 1 to 10 items
Show properties of filesHide properties of files

One of 2 shapes, told apart by kind:

kindimage
kindenumRequired

image for a photo, document for a document.

Allowed valuesimage
kinddocument
kindenumRequired

image for a photo, document for a document.

Allowed valuesdocument
filenamestringRequired

The document's name as Werk will show it.

From 1 to 255 characters

Response

200 The upload addresses.

grantsarray of objects

One upload address per file, in the order asked.

Show properties of grantsHide properties of grants
assetIdstring, uuid

The upload's id, which the card's request then names.

pathstring

The address under the API's base to send the file's bytes to; it carries its own grant, so it needs no key.

maxBytesinteger

The most bytes the file may have.

At least 1
maxSideinteger

For a photo, the most pixels its longer side may have.

At least 1

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_attachmentA 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).
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).
401session_revokedThe request carries no session the server holds, or its session has ended.
401session_expiredThe session has expired.
403photos_unavailablePhotos are not open to the signed-in person.
404conversation_not_foundThe project the request names, or its chat, is not one the signed-in person is in.
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.
413payload_too_largeThe request body has more bytes than the route takes.
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 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"
      }
    ]
  }'
TypeScript
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();
200JSON
{
  "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
    }
  ]
}