Media

Sending and receiving media

Upload the file first, then send a message that refers to it. Uploads go straight to storage over a short-lived URL.

Upload, then send
# 1. Ask for an upload URL
curl https://api.quic.chat/platform/v1/media \
  -H "Authorization: Bearer $QUIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "fileName": "invoice-1042.pdf", "mimeType": "application/pdf", "size": 48213 }'

# 2. PUT the bytes to upload.url with upload.headers (within 15 minutes)
curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/pdf" --data-binary @invoice-1042.pdf

# 3. Send it
curl https://api.quic.chat/platform/v1/messages \
  -H "Authorization: Bearer $QUIC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "to": { "appUserId": "u_4f9XkQ2bT7mN1pR8sV0wYz" }, "type": "file", "mediaId": "<media.id from step 1>", "text": "Your invoice" }'

Uploading#

  1. POST /media with fileName, mimeType and size (bytes). You get media.id and an upload object with a URL, method PUT and headers.
  2. PUT the exact bytes to that URL with those headers within 15 minutes.
  3. Send with type matching the file and mediaId. If the upload hasn't finished you get 409 media_not_uploaded; if the bytes don't match what you declared, 422 media_invalid.

Types and limits#

Allowed media
KindMIME typesMax size
Imageimage/jpeg, image/png, image/webp, image/gif16 MB
Videovideo/mp4, video/3gpp, video/quicktime16 MB
Audioaudio/mpeg, audio/mp4, audio/aac, audio/ogg, audio/amr16 MB
DocumentPDF, plain text, CSV, Word, Excel, PowerPoint100 MB

SVG, HTML, executables and archives are refused (415 unsupported_media_type). Each app can create up to 100 uploads per hour.

Media users send you#

message.received events list attachments as media[] with an id. Call GET /media/:id for a download URL that is valid for one hour; fetch a fresh one when it expires.