Authentication
All requests require theAuthorization header with your API key:
curl -H "Authorization: Bearer se_your_api_key" \
https://api.usesendly.app/v1/emails
Base URL
https://api.usesendly.app/v1
Send an Email
curl -X POST https://api.usesendly.app/v1/emails \
-H "Authorization: Bearer se_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "noreply@yourdomain.com",
"to": "user@example.com",
"subject": "Welcome!",
"html": "<h1>Hello!</h1><p>Thanks for signing up.</p>"
}'
import { Sendly } from '@sendlyapp/sdk'
const client = new Sendly('se_your_api_key')
await client.emails.send({
from: 'noreply@yourdomain.com',
to: 'user@example.com',
subject: 'Welcome!',
html: '<h1>Hello!</h1><p>Thanks for signing up.</p>'
})
List Emails
curl https://api.usesendly.app/v1/emails?limit=20&sortOrder=desc \
-H "Authorization: Bearer se_your_api_key"
const response = await client.emails.list({
limit: 20,
sortOrder: 'desc'
})
response.data.forEach(email => {
console.log(`${email.to} - ${email.status}`)
})
Get Email Status
curl https://api.usesendly.app/v1/emails/email_123 \
-H "Authorization: Bearer se_your_api_key"
const email = await client.emails.get('email_123')
console.log(`Status: ${email.status}`)
Create a Domain
curl -X POST https://api.usesendly.app/v1/domains \
-H "Authorization: Bearer se_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"domain": "mail.yourdomain.com"
}'
const domain = await client.domains.create({
domain: 'mail.yourdomain.com'
})
Verify Domain
curl -X POST https://api.usesendly.app/v1/domains/mail.yourdomain.com/verify \
-H "Authorization: Bearer se_your_api_key"
await client.domains.verify('mail.yourdomain.com')
List Domains
curl https://api.usesendly.app/v1/domains \
-H "Authorization: Bearer se_your_api_key"
const response = await client.domains.list()
Create Webhook
curl -X POST https://api.usesendly.app/v1/webhooks \
-H "Authorization: Bearer se_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourdomain.com/webhooks/sendly",
"events": [
"email.delivered",
"email.bounced",
"email.opened",
"email.clicked"
]
}'
const webhook = await client.webhooks.create({
url: 'https://yourdomain.com/webhooks/sendly',
events: [
'email.delivered',
'email.bounced',
'email.opened',
'email.clicked'
]
})
Error Handling
Errors are returned with appropriate HTTP status codes:# 400 Bad Request
curl -X POST https://api.usesendly.app/v1/emails \
-H "Authorization: Bearer se_your_api_key" \
-H "Content-Type: application/json" \
-d '{"from": "invalid"}'
# Response:
# {
# "code": "INVALID_EMAIL",
# "message": "The email address is invalid",
# }
Save Response to File
curl https://api.usesendly.app/v1/emails \
-H "Authorization: Bearer se_your_api_key" \
-o response.json
Pretty Print JSON
curl https://api.usesendly.app/v1/emails \
-H "Authorization: Bearer se_your_api_key" | jq
Common HTTP Methods
| Method | Purpose |
|---|---|
| GET | Retrieve data |
| POST | Create new resource |
| PATCH | Update resource |
| DELETE | Delete resource |
Resources
Need help? Contact support@usesendly.app