Skip to content

API Endpoints

The mailiam API provides RESTful endpoints for managing forms, sending emails, and processing submissions.

https://api.mailiam.io

Include your API key in the Authorization header:

Terminal window
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.mailiam.io/api/forms

Submit data to a form endpoint.

Terminal window
curl -X POST https://api.mailiam.io/submit/contact \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"message": "Hello world"
}'

Response:

{
"success": true,
"message": "Form submitted successfully"
}

List all forms for your account.

Terminal window
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.mailiam.io/api/forms

Response:

{
"forms": [
{
"id": "contact",
"name": "Contact Form",
"submissions": 42,
"created_at": "2024-01-01T00:00:00Z"
}
]
}

Create a new form.

Terminal window
curl -X POST https://api.mailiam.io/api/forms \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Newsletter Signup",
"to": "admin@example.com",
"subject": "New Newsletter Subscription"
}'

Send a transactional email.

Terminal window
curl -X POST https://api.mailiam.io/api/email/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "user@example.com",
"subject": "Welcome!",
"template": "welcome",
"data": {
"name": "John Doe"
}
}'

Create a new customer for billing purposes.

Terminal window
curl -X POST https://api.mailiam.io/api/billing/customer \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"name": "John Doe",
"tenantId": "tenant_123"
}'

Response:

{
"id": "cust_123",
"email": "user@example.com",
"name": "John Doe",
"created_at": "2024-01-15T10:00:00Z"
}

Create a subscription for a customer with one of the available plans (starter, developer, scale).

Terminal window
curl -X POST https://api.mailiam.io/api/billing/subscription \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "tenant_123",
"plan": "starter"
}'

Response:

{
"id": "sub_123",
"customer_id": "cust_123",
"plan": "starter",
"status": "active",
"created_at": "2024-01-15T10:05:00Z"
}

Change the current subscription plan.

Terminal window
curl -X PATCH https://api.mailiam.io/api/billing/subscription/change \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "tenant_123",
"newPlan": "developer"
}'

Cancel a subscription.

Terminal window
curl -X DELETE https://api.mailiam.io/api/billing/subscription \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "tenant_123"
}'

Record email usage for billing purposes.

Terminal window
curl -X POST https://api.mailiam.io/api/billing/usage \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "tenant_123",
"emailCount": 50
}'

Response:

{
"emailsRecorded": 50,
"currentPeriodEmails": 5234,
"includedEmails": 10000,
"overage": 0,
"plan": "developer"
}

Get current billing information for a customer, including usage and overage charges.

Terminal window
curl https://api.mailiam.io/api/billing/info \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "tenant_123"
}'

Response:

{
"tenantId": "tenant_123",
"plan": "developer",
"status": "active",
"monthlyFee": 19.00,
"includedEmails": 10000,
"currentPeriod": {
"emailsSent": 5234,
"emailsIncluded": 10000,
"overage": 0,
"overageCost": 0.00
},
"totalEmailsSent": 15234,
"createdAt": "2024-01-15T10:00:00Z",
"lastEmailSent": "2024-01-20T14:30:00Z"
}

All endpoints return consistent error responses:

{
"error": true,
"message": "Invalid API key",
"code": 401
}
  • Free Plan: 100 requests/hour
  • Pro Plan: 1,000 requests/hour
  • Enterprise: Custom limits

Rate limit headers are included in all responses:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200