Skip to Content
Files

Create a file (presigned upload)

POST
/api/v1/files

Create a file record and get a presigned URL to upload the bytes directly to storage.

Flow:

  1. Compute the file's SHA-256 hash and base64-encode it.
  2. Call this endpoint with the filename, MIME type, size, and checksum. You receive the file object and a presigned uploadUrl.
  3. PUT the raw bytes to uploadUrl with headers Content-Type: <mimeType> and x-amz-checksum-sha256: <checksum>. S3 verifies the checksum on write.
  4. (Recommended) Call POST /api/v1/files/:id/confirm to verify the upload and flip the record to CONFIRMED immediately. Otherwise it is confirmed automatically the first time it is fetched via GET /api/v1/files/:id.

Why: the bytes go straight to storage, so there is no API-server size limit.

Authorization

headerAuthorizationBearer <token>

API key, e.g. Authorization: Bearer sajn_svc_.... Not scope-limited: acts with its owner's workspace role.

Header Parameters

Sajn-Version?string

API version for this request. Without it, the request uses the organization's default version; an organization without a default is pinned to the latest version by its first request.

Value in"2026-09""2026-10"
Sajn-Workspace?string

ID of the workspace this request acts in, from GET /api/v1/workspaces. Without it, an API key acts in its default workspace. The token's user must be a member of the workspace; an OAuth token only accepts the workspace it was granted for. A workspace that doesn't exist or can't be reached returns 403 WORKSPACE_ACCESS_DENIED.

Idempotency-Key?string

Makes retries safe. A retry with the same key and the same request replays the stored response for 24 hours (header Idempotent-Replayed: true); the same key with a different request returns 400.

Lengthlength <= 255

Request Body

Body

application/json
  1. body

Request a presigned upload URL and create a pending file record

fileName*string

Original filename including its extension

Length1 <= length <= 255
mimeType*string

MIME type of the file

Value in"application/pdf""application/msword""application/vnd.openxmlformats-officedocument.wordprocessingml.document""application/vnd.ms-excel""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet""application/vnd.ms-powerpoint""application/vnd.openxmlformats-officedocument.presentationml.presentation""video/mp4""video/quicktime""video/x-msvideo""video/webm""image/jpeg""image/png""image/gif""image/webp""image/svg+xml"
size*integer

File size in bytes (max 25 MB)

Range0 < value <= 26214400
checksum*string

Base64-encoded SHA-256 checksum of the file. S3 enforces it on upload, so a mismatch rejects the bytes.

Length1 <= length
visibility?string

File visibility (default PRIVATE)

Default"PRIVATE"
Value in"PRIVATE""PUBLIC"

Response Body

The created file and the URL to upload its bytes to

application/json
  1. response

The created file and the URL to upload its bytes to

id*string

Unique file identifier

filename*string

Original filename

mimeType*string

MIME type of the file

size*number

File size in bytes

visibility*string

File visibility

Value in"PRIVATE""PUBLIC"
url*string

URL to access the file (signed URL for private, direct URL for public)

Formaturi
createdAt*string

Date and time when file was uploaded

Formatdate-time
updatedAt*string

Date and time when file was last updated

Formatdate-time
uploadedBy*

The user who uploaded the file

key*string

The storage key of the file. Set it as a PDF field's fieldMeta.value to render the file.

uploadUrl*string

Presigned PUT URL (valid 15 minutes). Upload the bytes here with headers Content-Type: and x-amz-checksum-sha256: .

Formaturi
Example Request
curl -X POST 'https://app.sajn.se/api/v1/files' \  -H 'Content-Type: application/json' \  -d '{  "fileName": "anstallningsavtal-kai-lindqvist.pdf",  "mimeType": "application/pdf",  "size": 184320,  "checksum": "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=",  "visibility": "PRIVATE"}'
Example Response
{  "id": "cm4k2x9p10012abcd1234efgh",  "filename": "anstallningsavtal-kai-lindqvist.pdf",  "mimeType": "application/pdf",  "size": 184320,  "visibility": "PRIVATE",  "url": "https://files.sajn.se/files/anstallningsavtal-kai-lindqvist.pdf",  "createdAt": "2026-09-28T09:12:00.000Z",  "updatedAt": "2026-09-28T09:15:00.000Z",  "uploadedBy": {    "id": "cm4k2x9p10002abcd1234efgh",    "email": "alex@example.com",    "name": "Alex Berg"  },  "key": "f/cm4k2x9p10000abcd1234efgh/cm4k2x9p10012abcd1234efgh/anstallningsavtal-kai-lindqvist.pdf",  "uploadUrl": "https://files.sajn.se/uploads/anstallningsavtal-kai-lindqvist.pdf?X-Amz-Expires=3600"}

Was this page helpful?