Domains
Manage custom domains for receiving emails. Before you can receive emails on a domain, it must be verified via DNS TXT record and configured with MoMail’s MX records.
List Domains
Section titled “List Domains”Retrieve all domains associated with your account.
GET /domainsResponse
Section titled “Response”{ "success": true, "data": [ { "domain_id": "dom_abc123", "domain_name": "example.com", "verified": true, "mx_configured": true, "created_at": "2024-01-15T10:30:00.000Z" } ]}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
domain_id | string | Unique identifier for the domain |
domain_name | string | The registered domain name |
verified | boolean | Whether DNS verification is complete |
mx_configured | boolean | Whether MX records are properly configured |
created_at | string | ISO 8601 timestamp of domain creation |
Create Domain
Section titled “Create Domain”Register a new domain for email receiving.
POST /domainsRequest Body
Section titled “Request Body”{ "domain": "example.com"}Parameters
Section titled “Parameters”| Field | Type | Required | Description |
|---|---|---|---|
domain | string | Yes | Valid domain name (1-253 characters) |
Response
Section titled “Response”{ "success": true, "data": { "domain_id": "dom_abc123", "domain_name": "example.com", "verification_token": "momail-verify=xyz789abc...", "verified": false, "mx_configured": false, "created_at": "2024-01-15T10:30:00.000Z" }}Get Domain
Section titled “Get Domain”Retrieve details for a specific domain.
GET /domains/{id}Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Domain UUID |
Response
Section titled “Response”{ "success": true, "data": { "domain_id": "dom_abc123", "domain_name": "example.com", "verification_instructions": { "type": "TXT", "name": "_momail", "value": "momail-verify=xyz789abc..." }, "verified": false, "mx_configured": false, "created_at": "2024-01-15T10:30:00.000Z" }}Verify Domain
Section titled “Verify Domain”Trigger DNS verification for a domain. MoMail checks for the TXT record and updates the domain status.
POST /domains/{id}/verifyParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Domain UUID |
Response (Success)
Section titled “Response (Success)”{ "success": true, "data": { "verified": true, "mx_instructions": { "host": "mx.momail.io", "priority": 10 } }}Response (Pending Verification)
Section titled “Response (Pending Verification)”{ "success": false, "error": { "code": "VERIFICATION_FAILED", "message": "TXT record not found or does not match verification token", "details": { "expected_txt_record": "momail-verify=xyz789abc...", "instructions": "Add a TXT record to your DNS with the above value" } }}Delete Domain
Section titled “Delete Domain”Remove a domain from your account.
DELETE /domains/{id}Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Domain UUID |
Response
Section titled “Response”{ "success": true, "data": { "message": "Domain deleted successfully" }}DNS Configuration
Section titled “DNS Configuration”Verification TXT Record
Section titled “Verification TXT Record”Add this TXT record to verify domain ownership:
| Type | Name | Value |
|---|---|---|
| TXT | _momail | momail-verify={your_token} |
MX Record
Section titled “MX Record”After verification, add this MX record to receive emails:
| Type | Host | Priority | Value |
|---|---|---|---|
| MX | @ | 10 | mx.momail.io |
Code Examples
Section titled “Code Examples”# List domainscurl https://api.momail.io/v1/domains \ -H "X-API-Key: your_key"
# Create domaincurl -X POST https://api.momail.io/v1/domains \ -H "X-API-Key: your_key" \ -H "Content-Type: application/json" \ -d '{"domain": "example.com"}'
# Verify domaincurl -X POST https://api.momail.io/v1/domains/dom_abc123/verify \ -H "X-API-Key: your_key"
# Delete domaincurl -X DELETE https://api.momail.io/v1/domains/dom_abc123 \ -H "X-API-Key: your_key"// List domainsconst domains = await fetch('https://api.momail.io/v1/domains', { headers: { 'X-API-Key': 'your_key' }}).then(r => r.json());
// Create domainconst newDomain = await fetch('https://api.momail.io/v1/domains', { method: 'POST', headers: { 'X-API-Key': 'your_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ domain: 'example.com' })}).then(r => r.json());
// Verify domainconst verification = await fetch(`https://api.momail.io/v1/domains/${domainId}/verify`, { method: 'POST', headers: { 'X-API-Key': 'your_key' }}).then(r => r.json());import requests
headers = {'X-API-Key': 'your_key'}
# List domainsresponse = requests.get('https://api.momail.io/v1/domains', headers=headers)domains = response.json()['data']
# Create domainresponse = requests.post( 'https://api.momail.io/v1/domains', headers=headers, json={'domain': 'example.com'})domain_id = response.json()['data']['domain_id']
# Verify domainresponse = requests.post( f'https://api.momail.io/v1/domains/{domain_id}/verify', headers=headers)