### Install Mintlify CLI Source: https://github.com/inboundemail/docs.inbound.new/blob/main/README.md Install the Mintlify CLI globally using npm. This is required for local development. ```bash npm i -g mintlify ``` -------------------------------- ### Install Inbound Email SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/index.mdx Install the Inbound Email SDK using npm for a streamlined developer experience. ```bash npm install @inboundemail/sdk ``` -------------------------------- ### Get Thread Statistics with Inbound SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/threads/thread-stats.mdx Use the Inbound SDK to fetch thread statistics. This example shows how to retrieve the data and log key metrics like total threads, average messages per thread, and unread threads. ```javascript import { Inbound } from '@inboundemail/sdk' const inbound = new Inbound('YOUR_API_KEY') const { data: stats, error } = await inbound.thread.getStats() if (error) { console.error('Error:', error) } else { console.log(`Total threads: ${stats.totalThreads}`) console.log(`Average messages per thread: ${stats.averageMessagesPerThread}`) console.log(`Unread threads: ${stats.unreadStats.unreadThreads}`) } ``` -------------------------------- ### TXT Record Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Example of a TXT DNS record, commonly used for domain verification and AWS SES identity verification. ```dns Name: _amazonses.example.com Value: abc123def456ghi789jkl ``` -------------------------------- ### Create Webhook Endpoint with Python Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/create-endpoint.mdx Use the Python requests library to create a webhook endpoint. This example shows how to construct the JSON payload and send a POST request to the API. Ensure you have your API key and the 'requests' library installed. ```python import requests response = requests.post( 'https://inbound.new/api/v2/endpoints', headers={'Authorization': f'Bearer {api_key}'}, json={ 'name': 'Production Webhook', 'type': 'webhook', 'description': 'Main webhook for production alerts', 'config': { 'url': 'https://api.example.com/webhook', 'timeout': 30, 'retryAttempts': 3, 'headers': { 'X-Custom-Header': 'value' } } } ) endpoint = response.json() print(f"Created endpoint: {endpoint['id']}") ``` -------------------------------- ### Start Local Development Server Source: https://github.com/inboundemail/docs.inbound.new/blob/main/README.md Run the Mintlify development server from the root of your documentation directory. Ensure docs.json is present. ```bash mintlify dev ``` -------------------------------- ### Get Endpoint Response Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/get-endpoint.mdx This JSON object shows the structure of a successful response when retrieving endpoint details. It includes configuration, statistics, and associated data. ```json { "id": "ep_abc123", "name": "Production Webhook", "type": "webhook", "config": { "url": "https://api.example.com/webhook", "timeout": 30, "retryAttempts": 3, "headers": { "X-Custom-Header": "value" } }, "isActive": true, "description": "Main webhook for production alerts", "userId": "user_123", "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-15T10:30:00Z", "groupEmails": null, "deliveryStats": { "total": 145, "successful": 142, "failed": 3, "lastDelivery": "2024-01-15T14:30:00Z" }, "recentDeliveries": [ { "id": "del_xyz789", "emailId": "inbnd_7g8h9i0j1k2l", "deliveryType": "webhook", "status": "success", "attempts": 1, "lastAttemptAt": "2024-01-15T14:30:00Z", "createdAt": "2024-01-15T14:30:00Z", "responseData": { "responseCode": 200, "responseBody": "OK", "deliveryTime": 250, "url": "https://api.example.com/webhook" } } ], "associatedEmails": [ { "id": "addr_123", "address": "alerts@example.com", "isActive": true, "createdAt": "2024-01-15T10:30:00Z" } ], "catchAllDomains": [ { "id": "dom_456", "domain": "example.com", "status": "ses_verified" } ] } ``` -------------------------------- ### CNAME Record Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Example of a CNAME (Canonical Name) record, often used for subdomain configurations. ```dns Name: mail.example.com Value: inbound-smtp.us-east-1.amazonaws.com ``` -------------------------------- ### Update Endpoint Request Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/update-endpoint.mdx This example shows the basic structure of a PUT request to update an endpoint. Replace `{id}` with the actual endpoint ID. ```bash PUT https://inbound.new/api/v2/endpoints/{id} ``` -------------------------------- ### SPF Record Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Example of an SPF (Sender Policy Framework) TXT record, which helps prevent email spoofing by defining authorized mail servers. ```dns Name: example.com Value: v=spf1 include:amazonses.com ~all ``` -------------------------------- ### MX Record Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Example of an MX DNS record, used to specify mail servers responsible for accepting email on behalf of a domain. ```dns Name: example.com Value: 10 inbound-smtp.us-east-1.amazonaws.com Priority: 10 ``` -------------------------------- ### Delete Endpoint Request Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/delete-endpoint.mdx Shows the basic structure of a DELETE request to remove an endpoint. ```bash DELETE https://inbound.new/api/v2/endpoints/{id} ``` -------------------------------- ### Get Domain Details (Python) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-domain.mdx Use the Python requests library to get domain details from the Inbound Email API. This example shows how to set the Authorization header. ```python import requests response = requests.get( 'https://inbound.new/api/v2/domains/dom_abc123', headers={'Authorization': 'Bearer YOUR_API_KEY'} ) data = response.json() ``` -------------------------------- ### Get Thread Statistics with Python Requests Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/threads/thread-stats.mdx Use the Python requests library to call the thread statistics API. This example demonstrates how to send the GET request and parse the JSON response. ```python import requests response = requests.get( 'https://inbound.new/api/v2/threads/stats', headers={'Authorization': 'Bearer YOUR_API_KEY'} ) data = response.json() ``` -------------------------------- ### Initialize Domain Authentication with Python Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/init-domain-auth.mdx Use the requests library to send a POST request for initializing domain authentication. Ensure you include the correct API key and content type in the headers. ```python import requests response = requests.post( 'https://inbound.new/api/v2/domains/dom_abc123/auth', headers={ 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, json={ 'mailFromDomain': 'mail', 'generateSpf': True, 'generateDmarc': True } ) data = response.json() ``` -------------------------------- ### Initialize Domain Authentication with PHP Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/init-domain-auth.mdx Utilize PHP's stream contexts to make a POST request for domain authentication initialization. The request body should be JSON-encoded. ```php 'mail', 'generateSpf' => true, 'generateDmarc' => true ]; $options = [ 'http' => [ 'header' => [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json' ], 'method' => 'POST', 'content' => json_encode($data) ] ]; $context = stream_context_create($options); $response = file_get_contents('https://inbound.new/api/v2/domains/dom_abc123/auth', false, $context); $data = json_decode($response, true); ?> ``` -------------------------------- ### Get Email Group Endpoint Details (Python) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/get-endpoint.mdx Fetch email group endpoint details using Python. This example demonstrates how to access the group name and recipient list. ```python import requests response = requests.get( 'https://inbound.new/api/v2/endpoints/ep_def456', headers={'Authorization': f'Bearer {api_key}'} ) endpoint = response.json() print(f"Email Group: {endpoint['name']}") print(f"Recipients: {', '.join(endpoint['groupEmails'])}") ``` -------------------------------- ### Get Domain Details Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-domain.mdx Fetches the details for a specific domain, including its verification status, DNS records, and configuration. This is useful for monitoring domain health and ensuring proper email delivery setup. ```APIDOC ## GET /domains/{domainId} ### Description Retrieves the details of a specific domain. ### Method GET ### Endpoint /domains/{domainId} ### Parameters #### Path Parameters - **domainId** (string) - Required - The unique identifier of the domain to retrieve. #### Query Parameters - **check** (boolean) - Optional - If true, the response will include real-time verification status in the `verificationCheck` field. ### Response #### Success Response (200) - **id** (string) - Required - Unique identifier for the domain. - **domain** (string) - Required - The domain name (e.g., "example.com"). - **status** (string) - Required - Current verification status: `pending`, `verified`, or `failed`. - **canReceiveEmails** (boolean) - Required - Whether the domain is configured to receive emails. - **hasMxRecords** (boolean) - Required - Whether the domain has valid MX records configured. - **domainProvider** (string | null) - Detected domain provider (e.g., "Cloudflare", "GoDaddy"). - **providerConfidence** (string | null) - Confidence level of provider detection: `high`, `medium`, `low`. - **lastDnsCheck** (string | null) - ISO 8601 timestamp of the last DNS verification check. - **lastSesCheck** (string | null) - ISO 8601 timestamp of the last AWS SES verification check. - **mailFromDomain** (string | null) - Configured MAIL FROM domain (if set). This eliminates "via amazonses.com" attribution. - **mailFromDomainStatus** (string | null) - MAIL FROM domain status: `Pending`, `Success`, `Failed`, or `NotSet`. - **mailFromDomainVerifiedAt** (string | null) - ISO 8601 timestamp when the MAIL FROM domain was verified. - **isCatchAllEnabled** (boolean) - Required - Whether catch-all email forwarding is enabled for this domain. - **catchAllEndpointId** (string | null) - ID of the endpoint used for catch-all email forwarding. - **createdAt** (string) - Required - ISO 8601 timestamp when the domain was added. - **updatedAt** (string) - Required - ISO 8601 timestamp when the domain was last updated. - **userId** (string) - Required - ID of the user who owns this domain. - **stats** (object) - Required - Detailed domain statistics and usage information. - **totalEmailAddresses** (integer) - Required - Total number of email addresses configured for this domain. - **activeEmailAddresses** (integer) - Required - Number of active email addresses for this domain. - **emailsLast24h** (integer) - Required - Number of emails received in the last 24 hours. - **emailsLast7d** (integer) - Required - Number of emails received in the last 7 days. - **emailsLast30d** (integer) - Required - Number of emails received in the last 30 days. - **catchAllEndpoint** (object | null) - Information about the catch-all endpoint (if configured). - **id** (string) - Required - Unique identifier for the endpoint. - **name** (string) - Required - Display name of the endpoint. - **type** (string) - Required - Type of endpoint: `webhook`, `email`, or `email_group`. - **isActive** (boolean) - Required - Whether the endpoint is currently active. - **verificationCheck** (object) - Optional - Real-time verification status (only included when `check=true` parameter is used). - **dnsRecords** (array) - Required - Array of DNS record verification results. - **type** (string) - Required - DNS record type (e.g., "TXT", "MX", "CNAME"). - **name** (string) - Required - DNS record name/hostname. - **value** (string) - Required - Expected DNS record value. - **isVerified** (boolean) - Required - Whether this DNS record is currently verified. - **error** (string) - Optional - Error message if verification failed. #### Response Example ```json { "id": "d_abc123", "domain": "example.com", "status": "verified", "canReceiveEmails": true, "hasMxRecords": true, "domainProvider": "Cloudflare", "providerConfidence": "high", "lastDnsCheck": "2023-10-27T10:00:00Z", "lastSesCheck": "2023-10-27T10:05:00Z", "mailFromDomain": null, "mailFromDomainStatus": "NotSet", "mailFromDomainVerifiedAt": null, "isCatchAllEnabled": false, "catchAllEndpointId": null, "createdAt": "2023-01-01T09:00:00Z", "updatedAt": "2023-10-26T15:30:00Z", "userId": "u_xyz789", "stats": { "totalEmailAddresses": 10, "activeEmailAddresses": 5, "emailsLast24h": 150, "emailsLast7d": 1000, "emailsLast30d": 5000 }, "catchAllEndpoint": null, "verificationCheck": { "dnsRecords": [ { "type": "TXT", "name": "_amazonses.example.com", "value": "...", "isVerified": true, "error": null } ] } } ``` ``` -------------------------------- ### Create an Email Forward Endpoint Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/create-endpoint.mdx This example shows how to create an endpoint to forward incoming emails to a single email address. You can optionally configure subject prefixes, custom 'from' addresses, and sender names. ```bash POST https://inbound.new/api/v2/endpoints Content-Type: application/json Authorization: Bearer YOUR_API_KEY { "name": "Support Forwarding", "type": "email", "config": { "forwardTo": "support@example.com", "includeAttachments": true, "subjectPrefix": "[Support] ", "fromAddress": "noreply@example.com", "senderName": "Support Team" }, "description": "Forward support emails to the main support inbox" } ``` -------------------------------- ### Create Domain using Python Requests Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/create-domain.mdx Utilize the Python Requests library to make a POST request to create a domain. This example shows how to set headers and send a JSON body. ```python import requests response = requests.post( 'https://inbound.new/api/v2/domains', headers={ 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, json={ 'domain': 'example.com' } ) data = response.json() ``` -------------------------------- ### Get Scheduled Email Details with Inbound SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/emails/get-scheduled-email.mdx Use the Inbound SDK to retrieve scheduled email details by its ID. This example shows how to handle successful responses and errors, and access key information like status and scheduled time. ```javascript import { Inbound } from '@inboundemail/sdk'; const inbound = new Inbound('your_api_key'); // Get scheduled email details const { data, error } = await inbound.email.sent.getScheduled('sch_1234567890abcdef'); if (error) { console.error('Error:', error); } else { console.log('Email status:', data.status); console.log('Scheduled for:', data.scheduled_at); console.log('Subject:', data.subject); if (data.status === 'failed') { console.log('Last error:', data.last_error); } } ``` -------------------------------- ### List Emails with Inbound SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/mail/list-emails.mdx Demonstrates how to list emails using the Inbound SDK, including basic requests and requests with various filters and search parameters. ```javascript import { InboundEmailClient } from '@inboundemail/sdk'; const inbound = new InboundEmailClient('your_api_key_here'); // Basic request const { data, error } = await inbound.mail.list(); // With filters const { data, error } = await inbound.mail.list({ limit: 20, status: 'processed', domain: 'example.com' }); // With search const { data, error } = await inbound.mail.list({ search: 'urgent', timeRange: '7d' }); // Filter by email address const { data, error } = await inbound.mail.list({ emailAddress: 'customer@example.com', limit: 50 }); // Filter by email ID (thread) const { data, error } = await inbound.mail.list({ emailId: 'ses_abc123', includeArchived: true }); ``` -------------------------------- ### Complete Webhook Example with Verification Source: https://github.com/inboundemail/docs.inbound.new/blob/main/webhook.mdx This snippet demonstrates how to verify an incoming webhook and process its payload. It includes steps for authentication, parsing the JSON payload, logging email details, and handling attachments. ```typescript import { Inbound, verifyWebhookFromHeaders, type InboundWebhookPayload } from '@inboundemail/sdk' const inbound = new Inbound(process.env.INBOUND_API_KEY!) export async function POST(request: Request) { // Step 1: Verify webhook authenticity const isValid = await verifyWebhookFromHeaders(request.headers, inbound) if (!isValid) { console.warn('Webhook verification failed', { endpointId: request.headers.get('X-Endpoint-ID'), timestamp: new Date().toISOString() }) return new Response('Unauthorized', { status: 401 }) } // Step 2: Parse verified payload const payload: InboundWebhookPayload = await request.json() const { email, endpoint } = payload // Step 3: Process the email console.log(`Received email from ${email.from.addresses[0].address}`) console.log(`Subject: ${email.subject}`) console.log(`Endpoint: ${endpoint.name}`) // Step 4: Handle attachments if present if (email.parsedData.attachments?.length > 0) { for (const attachment of email.parsedData.attachments) { // Download attachment using the provided downloadUrl const response = await fetch(attachment.downloadUrl, { headers: { 'Authorization': `Bearer ${process.env.INBOUND_API_KEY}` } }) if (response.ok) { const fileBuffer = await response.arrayBuffer() // Process attachment... } } } return new Response('OK', { status: 200 }) } ``` -------------------------------- ### Send Reply using Legacy API Version Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/emails/reply-to-email.mdx This example shows how to send a reply using a specific historical API version. Ensure you include the 'API-Version' header. ```bash curl -X POST https://inbound.new/api/v2/emails/inbnd_abc123def456ghi/reply \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "API-Version: reply-10-01-25" \ -H "Content-Type: application/json" \ -d '{ "from": "support@yourdomain.com", "text": "Your reply message" }' ``` -------------------------------- ### Re-install Mintlify Dependencies Source: https://github.com/inboundemail/docs.inbound.new/blob/main/README.md If 'mintlify dev' is not running, use this command to re-install dependencies. ```bash mintlify install ``` -------------------------------- ### Download Attachment using cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/attachments/download-attachment.mdx A command-line example using cURL to download an attachment directly from the API. Replace `YOUR_API_KEY` with your actual API key. ```bash curl -X GET 'https://inbound.new/api/v2/attachments/inbnd_abc123def456ghi/document.pdf' \ -H 'Authorization: Bearer YOUR_API_KEY' \ --output document.pdf ``` -------------------------------- ### Basic GET Request for Listing Emails Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/mail/list-emails.mdx This snippet shows a basic GET request to list emails without any filters. ```bash GET https://inbound.new/api/v2/mail ``` -------------------------------- ### Create Domain using Node.js SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/create-domain.mdx Use the InboundEmailClient SDK to create a new domain. Ensure you have your API key and handle potential errors. ```javascript import { InboundEmailClient } from '@inboundemail/sdk'; const inbound = new InboundEmailClient('YOUR_API_KEY'); const { data, error } = await inbound.domain.create({ domain: 'example.com' }); if (error) { console.error('Error:', error); } else { console.log('Domain created:', data); } ``` -------------------------------- ### Get Email Details using Python Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/mail/get-email.mdx Fetch email details by making a GET request to the API. The response is parsed as JSON. ```python import requests response = requests.get( 'https://inbound.new/api/v2/mail/inbnd_123abc456def789', headers={'Authorization': f'Bearer {api_key}'} ) email = response.json() ``` -------------------------------- ### Verifying Webhooks with the SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/webhook.mdx This example demonstrates how to use the Inbound Email SDK to verify the authenticity of incoming webhook requests before processing their payload. ```APIDOC ## Verifying Webhooks with the SDK The SDK provides a simple helper function to verify webhook requests: ```typescript import { Inbound, verifyWebhookFromHeaders } from '@inboundemail/sdk' const inbound = new Inbound(process.env.INBOUND_API_KEY!) export async function POST(request: Request) { // Verify webhook authenticity before processing const isValid = await verifyWebhookFromHeaders(request.headers, inbound) if (!isValid) { return new Response('Unauthorized', { status: 401 }) } // Process the verified webhook payload const payload = await request.json() const { email } = payload // Your webhook handling logic here console.log('Received verified email:', email.subject) return new Response('OK', { status: 200 }) } ``` ``` -------------------------------- ### Initialize Domain Authentication with Node.js SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/init-domain-auth.mdx Use the InboundEmailClient to initialize domain authentication. This method returns DNS records that need to be added to your DNS provider. ```javascript import { InboundEmailClient } from '@inboundemail/sdk'; const inbound = new InboundEmailClient('YOUR_API_KEY'); // Initialize domain authentication with default settings const { data, error } = await inbound.domain.verify('dom_abc123'); if (error) { console.error('Failed to initialize domain authentication:', error); } else { console.log('Domain authentication initialized:', data); console.log('DNS records to add:', data.records); } ``` -------------------------------- ### DMARC Record Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Example of a DMARC (Domain-based Message Authentication, Reporting & Conformance) TXT record, used to specify email authentication policies and reporting. ```dns Name: _dmarc.example.com Value: v=DMARC1; p=none; rua=mailto:dmarc@example.com; ruf=mailto:dmarc@example.com; fo=1; aspf=r; adkim=r ``` -------------------------------- ### Initialize Domain Authentication with cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/init-domain-auth.mdx Send a POST request to the API endpoint to initialize domain authentication. This example includes parameters for generating SPF and DMARC records. ```bash curl -X POST "https://inbound.new/api/v2/domains/dom_abc123/auth" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mailFromDomain": "mail", "generateSpf": true, "generateDmarc": true }' ``` -------------------------------- ### Get Email Address using Python Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/email-addresses/get-email-address.mdx Use the Python requests library to get email address details. Pass your API key in the Authorization header. ```python import requests response = requests.get( 'https://inbound.new/api/v2/email-addresses/email_addr_123', headers={'Authorization': 'Bearer YOUR_API_KEY'} ) data = response.json() ``` -------------------------------- ### Reply to an Email (JavaScript SDK) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/emails/reply-to-email.mdx Use the Inbound SDK to send a reply to a specific email. This example demonstrates both the organized API and the simplified reply method, both supporting idempotency keys. ```javascript import { Inbound } from '@inboundemail/sdk'; const inbound = new Inbound('YOUR_API_KEY'); // Using the organized API with idempotency const { data, error } = await inbound.email.sent.reply('inbnd_abc123def456ghi', { from: 'support@yourdomain.com', text: 'Thanks for your message!' }, { idempotencyKey: 'reply-abc123-user456-v1' }); // Using the simplified reply method with idempotency const { data, error } = await inbound.reply('inbnd_abc123def456ghi', { from: 'support@yourdomain.com', text: 'Your reply message' }, { idempotencyKey: 'unique-key-123' }); ``` -------------------------------- ### Send Reply using Current API Version Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/emails/reply-to-email.mdx This example demonstrates sending a reply using the current API version by omitting the 'API-Version' header. This version supports new features like 'replyAll'. ```javascript const response = await fetch('https://inbound.new/api/v2/emails/inbnd_abc123def456ghi/reply', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ from: 'support@yourdomain.com', text: 'Your reply message', replyAll: true // New feature in current version }) }); ``` -------------------------------- ### API Error Response Examples Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/email-addresses/list-email-addresses.mdx These JSON examples illustrate potential error responses from the API, including bad requests, unauthorized access, and internal server errors. ```json { "error": "Limit must be between 1 and 100" } ``` ```json { "error": "Unauthorized" } ``` ```json { "error": "Internal server error" } ``` -------------------------------- ### Create Domain Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/create-domain.mdx Creates a new domain and provides the necessary DNS records for verification. The domain status will be 'pending' until DNS records are propagated and verified. ```APIDOC ## POST /api/v2/domains ### Description Creates a new domain to receive emails. Upon creation, the API returns the domain details along with the required DNS records (TXT, MX, SPF, DMARC) that need to be configured in your DNS provider. ### Method POST ### Endpoint /api/v2/domains ### Parameters #### Request Body - **domain** (string) - Required - The domain name to add (e.g., "example.com"). - **domainProvider** (string) - Optional - The DNS provider for the domain (e.g., "Cloudflare", "GoDaddy"). This is used for informational purposes and to potentially offer provider-specific guidance. ### Request Example { "domain": "example.com", "domainProvider": "Cloudflare" } ### Response #### Success Response (201 Created) - **id** (string) - The unique identifier for the created domain. - **domain** (string) - The domain name that was created. - **status** (string) - The current status of the domain (e.g., "pending", "verified"). - **canReceiveEmails** (boolean) - Indicates if the domain is configured to receive emails. - **hasMxRecords** (boolean) - Indicates if the required MX records are detected. - **domainProvider** (string) - The DNS provider associated with the domain. - **providerConfidence** (string) - The confidence level of the provider detection. - **dnsRecords** (array) - An array of DNS records required for verification and email routing. - **type** (string) - The type of DNS record (e.g., "TXT", "MX", "SPF", "DMARC"). - **name** (string) - The name or host for the DNS record. - **value** (string) - The value of the DNS record. - **isRequired** (boolean) - Indicates if the record is strictly required for basic functionality. - **createdAt** (string) - The timestamp when the domain was created. - **updatedAt** (string) - The timestamp when the domain was last updated. #### Response Example { "id": "dom_abc123", "domain": "example.com", "status": "pending", "canReceiveEmails": true, "hasMxRecords": false, "domainProvider": "Cloudflare", "providerConfidence": "high", "dnsRecords": [ { "type": "TXT", "name": "_amazonses.example.com", "value": "abc123def456ghi789jkl", "isRequired": true }, { "type": "MX", "name": "example.com", "value": "10 inbound-smtp.us-east-1.amazonaws.com", "isRequired": true }, { "type": "TXT", "name": "example.com", "value": "v=spf1 include:amazonses.com ~all", "isRequired": false }, { "type": "TXT", "name": "_dmarc.example.com", "value": "v=DMARC1; p=none; rua=mailto:dmarc@example.com; ruf=mailto:dmarc@example.com; fo=1; aspf=r; adkim=r", "isRequired": false } ], "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-15T10:30:00Z" } ### Error Responses - **400 Bad Request - Invalid Domain**: The provided domain name is not in a valid format. - **400 Bad Request - DNS Conflicts**: The domain already has conflicting MX or CNAME records. - **401 Unauthorized**: Authentication credentials are invalid or missing. - **403 Forbidden - Domain Limit**: The user has reached the maximum number of domains allowed by their plan. - **409 Conflict - Domain Exists**: The domain has already been added. - **500 Internal Server Error**: An unexpected error occurred on the server. ``` -------------------------------- ### Get a Thread using cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/threads/get-thread.mdx Make a GET request to the threads endpoint using cURL to fetch thread details. Include your API key in the Authorization header. ```bash curl -X GET 'https://inbound.new/api/v2/threads/thread_abc123' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### List Endpoints with Node.js SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/list-endpoints.mdx Use the Node.js SDK to retrieve a paginated list of all endpoints in your account. Ensure you have initialized the client with your API key. ```javascript import { InboundEmailClient } from '@inboundemail/sdk' const inbound = new InboundEmailClient('your_api_key') const { data, error } = await inbound.endpoint.list() ``` -------------------------------- ### Get Email Details using cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/mail/get-email.mdx Make a GET request to the API endpoint to retrieve email details. Ensure to include the Authorization header with your API key. ```bash curl -X GET https://inbound.new/api/v2/mail/inbnd_123abc456def789 \ -H "Authorization: Bearer your_api_key_here" ``` -------------------------------- ### Create Webhook Endpoint with Inbound SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/endpoints/create-endpoint.mdx Use the Inbound SDK to create a new webhook endpoint. Ensure you have your API key and the SDK installed. This snippet demonstrates setting the endpoint name, type, description, and configuration including URL, timeout, retry attempts, and custom headers. ```javascript import { InboundEmailClient } from '@inboundemail/sdk' const inbound = new InboundEmailClient('your_api_key') const { data, error } = await inbound.endpoint.create({ name: 'Production Webhook', type: 'webhook', description: 'Main webhook for production alerts', config: { url: 'https://api.example.com/webhook', timeout: 30, retryAttempts: 3, headers: { 'X-Custom-Header': 'value' } } }) if (error) { console.error('Error:', error) } else { console.log(`Created endpoint: ${data.id}`) } ``` -------------------------------- ### Get Thread Statistics with cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/threads/thread-stats.mdx Make a GET request to the /api/v2/threads/stats endpoint using cURL to retrieve thread statistics. Ensure you include the Authorization header with your API key. ```bash curl -X GET 'https://inbound.new/api/v2/threads/stats' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Partially Verified Domain Response Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/verify-domain-auth.mdx This JSON response shows a domain that is still pending verification. It details which DNS records are verified and provides next steps for completion. ```json { "success": true, "domain": "example.com", "overallStatus": "pending", "dnsRecords": [ { "type": "TXT", "name": "_amazonses.example.com", "value": "abcd1234efgh5678ijkl9012mnop3456", "isRequired": true, "isVerified": true, "description": "SES domain verification", "lastChecked": "2024-01-15T10:30:00Z" }, { "type": "CNAME", "name": "abc123def456._domainkey.example.com", "value": "abc123def456.dkim.amazonses.com", "isRequired": true, "isVerified": false, "description": "DKIM authentication token 1", "error": "No CNAME records found for abc123def456._domainkey.example.com. Please add the CNAME record to your DNS.", "lastChecked": "2024-01-15T10:30:00Z" } ], "sesStatus": { "identityStatus": "Success", "identityVerified": true, "dkimStatus": "Pending", "dkimVerified": false, "dkimTokens": ["abc123def456", "ghi789jkl012", "mno345pqr678"], "mailFromDomain": "mail.example.com", "mailFromStatus": "Pending", "mailFromVerified": false }, "summary": { "totalRecords": 5, "verifiedRecords": 2, "requiredRecords": 3, "verifiedRequiredRecords": 1 }, "message": "Domain authentication in progress. 2/5 DNS records verified, 1/3 required records verified.", "nextSteps": [ "Add 2 missing required DNS record(s): CNAME abc123def456._domainkey.example.com, MX mail.example.com", "Wait for DKIM verification (requires CNAME records)", "Wait for MAIL FROM domain verification (requires MX record)" ] } ``` -------------------------------- ### Get DNS Records using cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-dns-records.mdx Make a GET request to the API endpoint using cURL to fetch DNS records. Include your API key in the Authorization header. ```bash curl -X GET 'https://inbound.new/api/v2/domains/dom_abc123/dns-records' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Enable Catch-All Email Forwarding (Node.js SDK) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/update-domain.mdx Use the InboundEmail SDK to enable catch-all forwarding for a domain by providing the domain ID and the endpoint ID. Ensure you have your API key for authentication. ```javascript import { InboundEmailClient } from '@inboundemail/sdk'; const inbound = new InboundEmailClient('YOUR_API_KEY'); const { data, error } = await inbound.domain.update('dom_abc123', { isCatchAllEnabled: true, catchAllEndpointId: 'end_xyz789' }); if (error) { console.error('Error:', error); } else { console.log('Domain updated:', data); } ``` -------------------------------- ### Get Email Address using cURL Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/email-addresses/get-email-address.mdx Make a GET request to the email addresses endpoint using cURL to fetch details. Include your API key in the Authorization header. ```bash curl -X GET 'https://inbound.new/api/v2/email-addresses/email_addr_123' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Get Domain Details (cURL) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-domain.mdx Make a GET request to the Inbound Email API to fetch domain details using cURL. Ensure you replace 'YOUR_API_KEY' with your actual API key. ```bash curl -X GET 'https://inbound.new/api/v2/domains/dom_abc123' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Get Domain with Verification Check (Python) Source: https://github.com/inboundemail/docs.inbound.new/blob/main/api-reference/domains/get-domain.mdx Use Python's requests library to get domain details and verification status by passing 'check=true' as a parameter. This ensures up-to-date verification information. ```python import requests response = requests.get( 'https://inbound.new/api/v2/domains/dom_abc123', params={'check': 'true'}, headers={'Authorization': 'Bearer YOUR_API_KEY'} ) data = response.json() ``` -------------------------------- ### Verify Webhook with SDK Source: https://github.com/inboundemail/docs.inbound.new/blob/main/webhook.mdx Example of how to verify incoming webhook requests using the Inbound SDK's `verifyWebhookFromHeaders` function. This ensures the request is authentic before processing sensitive data. ```typescript import { Inbound, verifyWebhookFromHeaders } from '@inboundemail/sdk' const inbound = new Inbound(process.env.INBOUND_API_KEY!) export async function POST(request: Request) { // Verify webhook authenticity before processing const isValid = await verifyWebhookFromHeaders(request.headers, inbound) if (!isValid) { return new Response('Unauthorized', { status: 401 }) } // Process the verified webhook payload const payload: InboundWebhookPayload = await request.json() const { email } = payload // Your webhook handling logic here console.log('Received verified email:', email.subject) return new Response('OK', { status: 200 }) } ``` -------------------------------- ### Inbound Webhook Payload Structure Example Source: https://github.com/inboundemail/docs.inbound.new/blob/main/webhook.mdx An example of the complete typed webhook payload structure for an 'email.received' event. This object contains all details about the received email, including sender, recipient, subject, and content. ```typescript const payload: InboundWebhookPayload = { event: 'email.received', timestamp: '2024-01-15T10:30:00Z', email: { id: 'inbnd_abc123def456ghi', messageId: '', from: { text: 'John Doe ', addresses: [{ name: 'John Doe', address: 'john@example.com' }] }, to: { text: 'support@yourdomain.com', addresses: [{ name: null, address: 'support@yourdomain.com' }] }, recipient: 'support@yourdomain.com', subject: 'Help with my order', receivedAt: '2024-01-15T10:30:00Z', parsedData: { messageId: '', date: new Date('2024-01-15T10:30:00Z'), subject: 'Help with my order', from: { text: 'John Doe ', addresses: [{ name: 'John Doe', address: 'john@example.com' }] }, to: { text: 'support@yourdomain.com', addresses: [{ name: null, address: 'support@yourdomain.com' }] }, cc: null, bcc: null, replyTo: null, inReplyTo: undefined, references: undefined, textBody: 'Hello, I need help with my recent order...', htmlBody: '

Hello, I need help with my recent order...

', raw: 'From: john@example.com\r\nTo: support@yourdomain.com\r\n...', attachments: [ { filename: 'order-receipt.pdf', contentType: 'application/pdf', size: 45678, contentId: '', contentDisposition: 'attachment', downloadUrl: 'https://inbound.new/api/v2/attachments/inbnd_abc123def456ghi/order-receipt.pdf' } ], headers: {}, priority: undefined }, cleanedContent: { html: '

Hello, I need help with my recent order...

', text: 'Hello, I need help with my recent order...', hasHtml: true, hasText: true, attachments: [ { filename: 'order-receipt.pdf', contentType: 'application/pdf', size: 45678, contentId: '', contentDisposition: 'attachment', downloadUrl: 'https://inbound.new/api/v2/attachments/inbnd_abc123def456ghi/order-receipt.pdf' } ], headers: {} } }, endpoint: { id: 'endp_xyz789', name: 'Support Webhook', type: 'webhook' } } ```