curl -X POST "https://api.usegately.com/api/v1/campaigns/upload-attachment" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Project-ID: YOUR_PROJECT_ID" \
-F "file=@/path/to/report.pdf"
import { GatelyCampaigns } from '@gately/sdk'
const campaigns = new GatelyCampaigns({ projectId: 'YOUR_PROJECT_ID' })
const fileInput = document.querySelector<HTMLInputElement>('#file-input')
const file = fileInput!.files![0]
const { attachment } = await campaigns.uploadAttachment(file)
// Pass directly into send()
await campaigns.send({
name: 'Monthly Report',
subject: 'Your report is attached',
content: '<p>Please find your report attached.</p>',
recipient_emails: ['user@example.com'],
attachments: [attachment],
})
{
"success": true,
"attachment": {
"content": "JVBERi0xLjQKJcOkw7zDtsO...",
"filename": "report.pdf",
"type": "application/pdf",
"size": 204800,
"disposition": "attachment"
},
"message": "File uploaded successfully"
}
{
"error": "File size exceeds 10 MB limit"
}
{
"error": "File type application/zip is not allowed"
}
Email Campaigns
Upload Attachment
Upload a file and get back base64 attachment data ready to use in a campaign
POST
/
api
/
v1
/
campaigns
/
upload-attachment
curl -X POST "https://api.usegately.com/api/v1/campaigns/upload-attachment" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Project-ID: YOUR_PROJECT_ID" \
-F "file=@/path/to/report.pdf"
import { GatelyCampaigns } from '@gately/sdk'
const campaigns = new GatelyCampaigns({ projectId: 'YOUR_PROJECT_ID' })
const fileInput = document.querySelector<HTMLInputElement>('#file-input')
const file = fileInput!.files![0]
const { attachment } = await campaigns.uploadAttachment(file)
// Pass directly into send()
await campaigns.send({
name: 'Monthly Report',
subject: 'Your report is attached',
content: '<p>Please find your report attached.</p>',
recipient_emails: ['user@example.com'],
attachments: [attachment],
})
{
"success": true,
"attachment": {
"content": "JVBERi0xLjQKJcOkw7zDtsO...",
"filename": "report.pdf",
"type": "application/pdf",
"size": 204800,
"disposition": "attachment"
},
"message": "File uploaded successfully"
}
{
"error": "File size exceeds 10 MB limit"
}
{
"error": "File type application/zip is not allowed"
}
Accepts a
multipart/form-data upload and returns the file encoded as base64. Pass the returned attachment object directly into the attachments array of Send Campaign.
Limits
- Max file size: 10 MB per file
- Allowed types: PDF, Word, Excel, plain text, CSV, JPEG, PNG, GIF, WebP
Headers
string
required
Bearer YOUR_API_KEYstring
Your project UUID. Not required if the API key already encodes the project.
Request Body
file
required
The file to upload (
multipart/form-data)Response
boolean
true on successful uploadobject
string
Human-readable confirmation
curl -X POST "https://api.usegately.com/api/v1/campaigns/upload-attachment" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Project-ID: YOUR_PROJECT_ID" \
-F "file=@/path/to/report.pdf"
import { GatelyCampaigns } from '@gately/sdk'
const campaigns = new GatelyCampaigns({ projectId: 'YOUR_PROJECT_ID' })
const fileInput = document.querySelector<HTMLInputElement>('#file-input')
const file = fileInput!.files![0]
const { attachment } = await campaigns.uploadAttachment(file)
// Pass directly into send()
await campaigns.send({
name: 'Monthly Report',
subject: 'Your report is attached',
content: '<p>Please find your report attached.</p>',
recipient_emails: ['user@example.com'],
attachments: [attachment],
})
{
"success": true,
"attachment": {
"content": "JVBERi0xLjQKJcOkw7zDtsO...",
"filename": "report.pdf",
"type": "application/pdf",
"size": 204800,
"disposition": "attachment"
},
"message": "File uploaded successfully"
}
{
"error": "File size exceeds 10 MB limit"
}
{
"error": "File type application/zip is not allowed"
}
Was this page helpful?