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.
Read content in chunks
Section titled “Read content in chunks”Each request reads at most 65,536 bytes.
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.
- Decode
content_base64and check it againstsha256. - If
next_offsetisn’tnull, request the next chunk withoffsetset tonext_offsetandexpected_versionset to theversionfrom the first response. - If the file changes between chunks, the request fails with
409. Start again from offset0.
Raw bytes
Section titled “Raw bytes”Send Accept: application/octet-stream to receive raw bytes instead of JSON. With binary Accept you can also:
- Send one
Range: bytes=start-endheader and receive206 Partial Content. - Send
If-Matchwith the returnedETag. A changed file returns412.
The response headers X-Gateway-File-Offset, X-Gateway-File-Size, X-Gateway-Next-Offset and X-Gateway-Content-SHA256 describe the chunk.