# Download to a file
curl -H "Authorization: Bearer gork_live_YOUR_API_KEY" \
https://api.gork.email/v1/attachments/att_9c1f2ab7d3 \
--output report.pdf
import { GorkClient } from "@gork/sdk"
const client = new GorkClient({ apiKey: process.env.GORK_API_KEY })
// Metadata comes from the message
const message = await client.messages.get("msg_90e38dfb4a2c")
const [file] = message.attachments ?? []
if (file) {
// Bytes
const bytes = await client.attachments.download(file.id)
// Or decode a text-like file (txt / csv / json) straight to a string
const text = await client.attachments.downloadText(file.id)
console.log(text)
}
import os, requests
res = requests.get(
"https://api.gork.email/v1/attachments/att_9c1f2ab7d3",
headers={"Authorization": f"Bearer {os.getenv('GORK_API_KEY')}"},
)
res.raise_for_status()
open("report.pdf", "wb").write(res.content)
Content-Type: application/pdf
Content-Length: 48213
Content-Disposition: attachment; filename="report.pdf"; filename*=UTF-8''report.pdf
X-Content-Type-Options: nosniff
<binary file bytes>
Messages
Read Attachment
Download the bytes of a file attached to an inbound or outbound message.
GET
/
v1
/
attachments
/
{id}
# Download to a file
curl -H "Authorization: Bearer gork_live_YOUR_API_KEY" \
https://api.gork.email/v1/attachments/att_9c1f2ab7d3 \
--output report.pdf
import { GorkClient } from "@gork/sdk"
const client = new GorkClient({ apiKey: process.env.GORK_API_KEY })
// Metadata comes from the message
const message = await client.messages.get("msg_90e38dfb4a2c")
const [file] = message.attachments ?? []
if (file) {
// Bytes
const bytes = await client.attachments.download(file.id)
// Or decode a text-like file (txt / csv / json) straight to a string
const text = await client.attachments.downloadText(file.id)
console.log(text)
}
import os, requests
res = requests.get(
"https://api.gork.email/v1/attachments/att_9c1f2ab7d3",
headers={"Authorization": f"Bearer {os.getenv('GORK_API_KEY')}"},
)
res.raise_for_status()
open("report.pdf", "wb").write(res.content)
Content-Type: application/pdf
Content-Length: 48213
Content-Disposition: attachment; filename="report.pdf"; filename*=UTF-8''report.pdf
X-Content-Type-Options: nosniff
<binary file bytes>
Every file attached to a message — one your agent sent, or one that arrived
in an inbound email — is stored and addressable by its
att_... id. Message
detail (GET /v1/messages/{id}) and thread responses include an attachments
array with each file’s id, filename, contentType, and sizeBytes.
Use this endpoint to read the actual file: parse a received CSV, archive a
signed PDF, or inspect a document your agent was sent.
Path parameters
string
required
The attachment ID (
att_...) from a message’s attachments array.Query parameters
boolean
default:"false"
Set
inline=1 to render in a browser tab instead of downloading. Only
honoured for types that are safe to render (image/png, image/jpeg,
image/gif, image/webp, application/pdf, text/plain); every other
type is always served as a download so hostile HTML/SVG can never run on
your origin.Response
The raw file bytes withContent-Type, Content-Length, and
Content-Disposition headers. Tenancy is enforced: an attachment belonging to
another organization returns 404, and an inbox-scoped key can only read files
on messages in its own inbox (403 inbox_access_denied otherwise).
If the record exists but the stored file was already removed by the plan’s
retention policy, the API returns 410 attachment_bytes_missing.
# Download to a file
curl -H "Authorization: Bearer gork_live_YOUR_API_KEY" \
https://api.gork.email/v1/attachments/att_9c1f2ab7d3 \
--output report.pdf
import { GorkClient } from "@gork/sdk"
const client = new GorkClient({ apiKey: process.env.GORK_API_KEY })
// Metadata comes from the message
const message = await client.messages.get("msg_90e38dfb4a2c")
const [file] = message.attachments ?? []
if (file) {
// Bytes
const bytes = await client.attachments.download(file.id)
// Or decode a text-like file (txt / csv / json) straight to a string
const text = await client.attachments.downloadText(file.id)
console.log(text)
}
import os, requests
res = requests.get(
"https://api.gork.email/v1/attachments/att_9c1f2ab7d3",
headers={"Authorization": f"Bearer {os.getenv('GORK_API_KEY')}"},
)
res.raise_for_status()
open("report.pdf", "wb").write(res.content)
Content-Type: application/pdf
Content-Length: 48213
Content-Disposition: attachment; filename="report.pdf"; filename*=UTF-8''report.pdf
X-Content-Type-Options: nosniff
<binary file bytes>
Reading attachments from an agent (MCP)
Claude Code, Cursor, and other MCP clients get this through thegork_read_attachment tool: text files are returned decoded, binary files come
back base64-encoded (files over 2MB return metadata only, with a pointer to the
endpoint). See Connect your AI for the setup.