import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const attachment = await commune.attachments.get('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6');
console.log(attachment.data.filename); // contract.pdf
console.log(attachment.data.mime_type); // application/pdf
console.log(attachment.data.size); // 204800
from commune import CommuneClient
client = CommuneClient()
attachment = client.attachments.get("a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
print(attachment.data.filename)
print(attachment.data.size)
get_attachment(id="a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
curl "https://api.commune.email/v1/attachments/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
-H "Authorization: Bearer comm_..."
commune attachments get a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
{
"data": {
"attachment_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"filename": "contract.pdf",
"mime_type": "application/pdf",
"size": 204800,
"source": "email",
"storage_type": "cloudinary"
}
}
{
"error": "Attachment not found"
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
Attachments
Get attachment
Retrieve attachment metadata by ID. To get a download URL, use the /url sub-endpoint.
GET
/
v1
/
attachments
/
:id
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const attachment = await commune.attachments.get('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6');
console.log(attachment.data.filename); // contract.pdf
console.log(attachment.data.mime_type); // application/pdf
console.log(attachment.data.size); // 204800
from commune import CommuneClient
client = CommuneClient()
attachment = client.attachments.get("a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
print(attachment.data.filename)
print(attachment.data.size)
get_attachment(id="a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
curl "https://api.commune.email/v1/attachments/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
-H "Authorization: Bearer comm_..."
commune attachments get a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
{
"data": {
"attachment_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"filename": "contract.pdf",
"mime_type": "application/pdf",
"size": 204800,
"source": "email",
"storage_type": "cloudinary"
}
}
{
"error": "Attachment not found"
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const attachment = await commune.attachments.get('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6');
console.log(attachment.data.filename); // contract.pdf
console.log(attachment.data.mime_type); // application/pdf
console.log(attachment.data.size); // 204800
from commune import CommuneClient
client = CommuneClient()
attachment = client.attachments.get("a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
print(attachment.data.filename)
print(attachment.data.size)
get_attachment(id="a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")
curl "https://api.commune.email/v1/attachments/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" \
-H "Authorization: Bearer comm_..."
commune attachments get a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
{
"data": {
"attachment_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"message_id": "49a3999c-0ce1-4ea6-ab68-e08a5c73e498",
"filename": "contract.pdf",
"mime_type": "application/pdf",
"size": 204800,
"source": "email",
"storage_type": "cloudinary"
}
}
{
"error": "Attachment not found"
}
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
Path Parameters
string
required
The attachment ID returned by Upload attachment or found in a message’s
metadata.attachment_ids array.Response
object
Attachment metadata. The raw file content (
content_base64) is not returned by this endpoint for security and performance reasons.Hide properties
Hide properties
string
Unique attachment identifier (32-character hex string).
string
ID of the message this attachment is associated with. Empty string for pre-uploaded attachments that have not yet been sent.
string
Original filename of the attachment.
string
MIME type of the file.
number
File size in bytes.
string
Channel the attachment originated from. Always
"email" for email attachments.string
Backend storage location. One of:
cloudinary, database.Download URL
To get a temporary signed download URL for the attachment content, callGET /v1/attachments/:id/url with an optional expires_in query parameter (seconds, default 3600):
cURL
curl "https://api.commune.email/v1/attachments/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6/url?expires_in=3600" \
-H "Authorization: Bearer comm_..."
{
"data": {
"url": "https://res.cloudinary.com/...",
"expires_in": 3600,
"filename": "contract.pdf",
"mime_type": "application/pdf",
"size": 204800
}
}
Last modified on March 19, 2026
Was this page helpful?

