Skip to main content

Endpoints

MethodPathScopeDescription
POST/media/presignmedia:writeGet a presigned upload URL
POST/media/confirmmedia:writeConfirm a completed upload

Upload Flow

Uploading media to clarife is a three-step process:
1

Get a presigned URL

Call /media/presign with the file details. You receive a time-limited upload URL and a b2_key.
2

Upload the file

PUT the file directly to the presigned URL. This uploads to clarife’s storage without proxying through the API.
3

Confirm the upload

Call /media/confirm with the media_id to mark the file as active.

Step 1: Get a Presigned URL

curl -X POST https://my.clarife.app/api/v1/media/presign \
  -H "Authorization: Bearer clrf_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "document_id": "d1234567-...",
    "media_id": "m1234567-...",
    "filename": "step-3-screenshot.png",
    "mime_type": "image/png",
    "file_size_bytes": 245760
  }'
FieldTypeRequiredDescription
document_iduuidYesDocument to attach the media to
media_iduuidYesClient-generated UUID for the media
filenamestringYesOriginal filename (max 255 chars)
mime_typestringYesMIME type (see supported types below)
file_size_bytesintegerYesFile size in bytes
Supported MIME types (images only):
TypeExtension
image/png.png
image/jpeg.jpg
image/gif.gif
image/webp.webp
image/svg+xml.svg
image/bmp.bmp
image/tiff.tiff
Response:
{
  "upload_url": "https://s3.us-west-004.backblazeb2.com/...",
  "b2_key": "media/user-id/doc-id/media-id.png",
  "media_id": "m1234567-..."
}
Maximum file size is 30 MB. The presigned URL expires after 15 minutes.

Step 2: Upload the File

Upload the file directly to the presigned URL using a PUT request:
curl -X PUT "https://s3.us-west-004.backblazeb2.com/..." \
  -H "Content-Type: image/png" \
  --data-binary @step-3-screenshot.png

Step 3: Confirm the Upload

curl -X POST https://my.clarife.app/api/v1/media/confirm \
  -H "Authorization: Bearer clrf_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "media_id": "m1234567-..." }'
Response:
{
  "id": "m1234567-...",
  "status": "active"
}

Complete Example

# 1. Get presigned URL
RESPONSE=$(curl -s -X POST https://my.clarife.app/api/v1/media/presign \
  -H "Authorization: Bearer clrf_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "document_id": "d1234567-...",
    "media_id": "'$(uuidgen | tr A-Z a-z)'",
    "filename": "screenshot.png",
    "mime_type": "image/png",
    "file_size_bytes": '$(stat -f%z screenshot.png)'
  }')

UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
MEDIA_ID=$(echo $RESPONSE | jq -r '.media_id')

# 2. Upload file to presigned URL
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: image/png" \
  --data-binary @screenshot.png

# 3. Confirm the upload
curl -X POST https://my.clarife.app/api/v1/media/confirm \
  -H "Authorization: Bearer clrf_your_key" \
  -H "Content-Type: application/json" \
  -d "{\"media_id\":\"$MEDIA_ID\"}"

Storage Limits

PlanStorage limit
Free100 MB
Pro10 GB
Business100 GB
Exceeding the storage limit returns a 403 error with code PLAN_LIMIT_REACHED.
Uploads that are not confirmed within 24 hours are automatically cleaned up.