Skip to main content

API Code Examples

Practical examples for common use cases. Replace $TOKEN with your API token and $BLOCK_ID with your Motor Block ID.

Yesterday's Email Performance

Get a complete performance report for the last 24 hours:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/metrics?from=2024-01-15T00:00:00Z&to=2024-01-16T00:00:00Z&interval=hour"

Perfect for daily performance reports, monitoring dashboards, or automated alerts.

One-Call Dashboard Overview

Fetch a single JSON payload with totals, rates, reputation, rate limits, anomalies, and top domains:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/overview" | jq '.'

Use this as the backbone for custom dashboards without stitching together multiple endpoints.

Find Bounced Emails from Gmail

Search for all bounced emails from Gmail to investigate delivery issues:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/logs?status=bounced&query=domain:gmail.com&limit=50"

Monitor Rate Limit Usage

Check how close you are to hitting your email sending limits:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/rate-limits"

Essential for capacity planning and optimizing sending schedules.

Provider-Specific Deliverability

See which mailbox providers are healthy and which are struggling:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/providers?from=2024-01-15T00:00:00Z&to=2024-01-22T00:00:00Z"

Spot provider-specific issues like Microsoft-only problems or Gmail throttling.

Track a Specific Campaign

Monitor all emails sent for a specific campaign:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/logs?query=metadata.campaign_id:newsletter-2024-01&limit=100"

Domain Health Check

Verify SPF, DKIM, and DMARC status for your sending domain:

curl -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/domain-health" | jq '.'

Ideal for pre-flight checks, onboarding flows, or periodic audits.

Real-Time Event Monitoring

Watch live email events as they happen via Server-Sent Events:

curl -N -H "Authorization: Bearer $TOKEN" \
"$API_BASE/motor-blocks/$BLOCK_ID/events/stream"

Multi-Language Examples

cURL

curl -sS -H "Authorization: Bearer $TOKEN" \
"https://api.motorical.com/api/public/v1/motor-blocks/$BLOCK_ID/rate-limits"

Node.js

const res = await fetch(
`https://api.motorical.com/api/public/v1/motor-blocks/${blockId}/rate-limits`,
{ headers: { Authorization: `Bearer ${token}` } }
);
console.log(await res.json());

Python

import requests

response = requests.get(
f'https://api.motorical.com/api/public/v1/motor-blocks/{block_id}/rate-limits',
headers={'Authorization': f'Bearer {token}'}
)
print(response.json())