Skip to content
Console

Read attachments

Attachments belong to a message in a conversation. Every file read names the exact conversation and message, so the Gateway can check you may see that message.

Step Operation
List a message’s attachments GET /api/v1/conversations/{conversation_id}/messages/{message_id}/attachments
Read one file’s metadata GET /api/v1/files/{file_id}
Read file content GET /api/v1/files/{file_id}/content

All three need file_read, conversation_read, message_content_read and contact_read_pii, with the message_content and pii flags. Internal attachments also need include_internal=true, internal_notes_read and the internal_notes flag.

Each request reads at most 65,536 bytes.

Terminal window
curl -s "$GATEWAY/api/v1/files/fil_4927_123_77/content?conversation_id=con_4927_123_456&message_id=msg_4927_123_789" \
-H "Authorization: Bearer $INSIDE_GATEWAY_TOKEN"

The default JSON response contains content_base64, next_offset, version and sha256.

  1. Decode content_base64 and check it against sha256.
  2. If next_offset isn’t null, request the next chunk with offset set to next_offset and expected_version set to the version from the first response.
  3. If the file changes between chunks, the request fails with 409. Start again from offset 0.

Send Accept: application/octet-stream to receive raw bytes instead of JSON. With binary Accept you can also:

  • Send one Range: bytes=start-end header and receive 206 Partial Content.
  • Send If-Match with the returned ETag. A changed file returns 412.

The response headers X-Gateway-File-Offset, X-Gateway-File-Size, X-Gateway-Next-Offset and X-Gateway-Content-SHA256 describe the chunk.