curl Examples
Common API operations using curl.
These examples assume you have API_URL and TOKEN environment variables set:
export API_URL="https://your-api-url"
export TOKEN="your-api-key"List emails in an inbox
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test" | jqWait for an email to arrive
Long-poll for up to 15 seconds:
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&wait=true&timeout=15" | jqFilter by sender
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&sender=noreply@example.com" | jqFilter by subject
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&subject=Verify" | jqFilter emails with attachments
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&hasAttachments=true" | jqGet a specific email
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails/abc123@mail.example.com" | jqDownload raw .eml file
The -L flag follows the redirect to the pre-signed S3 URL:
curl -L -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails/abc123@mail.example.com/raw" -o email.emlDownload an attachment
curl -L -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails/abc123@mail.example.com/attachments/invoice.pdf" -o invoice.pdfPaginate through results
# First page
RESPONSE=$(curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&limit=10")
echo "$RESPONSE" | jq '.emails | length'
# Next page using cursor
CURSOR=$(echo "$RESPONSE" | jq -r '.nextCursor')
curl -s -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test&limit=10&cursor=$CURSOR" | jqDelete a single email
curl -X DELETE -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails/abc123@mail.example.com" | jqDelete all emails in an inbox
curl -X DELETE -H "Authorization: Bearer $TOKEN" \
"$API_URL/v1/emails?inbox=test" | jqHealth check
No authentication required:
curl -s "$API_URL/health" | jq