Download an attachment

Download the file someone sent you

GET/v1/attachments/{id}

Returns the raw bytes of one inbound attachment. Ids come from attachmentIds on a message event, whose attachments gives each file's mimeType, filename and byteSize; content-type on this response is read from the bytes, so the two can differ. There is no CDN URL on the event. A photo background's picture is fetched here too, by the attachmentId its chat_background event or conversation.background_changed webhook may carry.

Example request

curl -o attachment.bin \
  https://api.mapier.ai/v1/attachments/8f2c1a4e-6b3d-4c71-9a05-2e7d8f1b3c64 \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "x-mapier-version: 2026-12-01"

The id is the whole path segment. There are no sub-paths and no size, format or thumbnail parameter, so a query string is ignored rather than selecting a rendition.

Conditional requests

Pass the etag you stored previously to skip re-downloading:

If-None-Match: "9f3c2a7e41b0d58c6e9f3a1b7c2d4e5f60718293a4b5c6d7e8f9012a3b4c5d6e"

A match returns 304 Not Modified with no body.

Response

HTTP/1.1 200 OK
content-type: image/heic
content-length: 1048576
etag: "9f3c2a7e41b0d58c6e9f3a1b7c2d4e5f60718293a4b5c6d7e8f9012a3b4c5d6e"
cache-control: private, max-age=31536000, immutable

The response carries these four headers:

Prop

Type

There is no content-disposition, so no filename: the event carries none either, and a client names the file itself.

Files are served as sent. iPhone photos commonly arrive as HEIC, which browsers other than Safari cannot display. Convert server-side if you need to render them.

Lifetime and access

The URL is permanent and unsigned — it is not a presigned link that expires. Access is controlled by your credential on every request, so the URL is safe to store but not safe to hand to a browser or a third party as-is.

An attachment of another project returns 404, the same answer as one that does not exist.

An attachment that has not finished transferring also returns 404; retry shortly.

The API publishes no maximum download size. Stream large responses rather than buffering them if you cannot bound the size.

Errors

StatusCodeCause
400bad_requestThe id could not be decoded; or, with a personal access token, no x-mapier-project header
401invalid_credentialsNo key, or one that is unknown, revoked or expired
403forbiddenA personal access token not made for this environment, or whose owner's role no longer allows this
403insufficient_scopeThe key does not carry the messages:read scope
404not_foundUnknown attachment, another project's, or not yet available
409project_archivedThe project is archived
422validation_failedAn x-mapier-version that is not a published version
429rate_limited120 requests per minute, per key; the Retry-After header says how long to wait (a channel's own rate limit may give the same seconds in details.retryAfter too)
500internal_errorAn unexpected error on Mapier's side; quote the error's requestId to support
503line_unavailable · upstream_unavailableThe line holding it cannot serve it right now, or the channel did not answer
503service_busyMapier was too busy to take the request and did nothing; wait details.retryAfter seconds and fetch again

Guide