> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.mercoa.com/embedded-ap-ar/guides/accounts-payable/email-inbox/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server. Mercoa's email inbox allows you to provide an email address for your users to send invoices to. Any email sent to the customer's inbox with an attached invoice PDF or image is automatically processed. Your users can then view, approve, and pay the invoice from the Mercoa dashboard. You can also use the [Mercoa API](/api-reference/invoice/get) to access the invoices directly. Emails sent to the Mercoa inbox must have at least one PDF or image attachment. Each attachment is processed as a separate invoice. ## Setup To set up an email inbox, you must add a domain to your Mercoa account. We recommend using `ap.yourcompany.com` as the domain name, where `yourcompany.com` is your company's domain name. Using the `ap` subdomain ensures that your email inbox is not confused with your company's main email inbox. Go to the [Developer Portal](https://mercoa.com/dashboard/developers#email) and enter your domain in the `Email Inbox Domain` field. Please enter the full domain name, including the `ap` subdomain, for example: `ap.yourcompany.com`. We recommend using a separate test and production subdomain, such as `aptest.yourcompany.com` and `ap.yourcompany.com`, to separate the Mercoa sandbox environment from the production environment. ## Creating Email Addresses Once you have added a domain to your Mercoa account, you can create email addresses for your users. If you haven't already, [create an `Entity`](/common-concepts/entities) for each of your users. If you are only using Mercoa for email inboxes, entities don't need to be verified. By default, Mercoa creates the email based on the `Entity` name. You can change this email address in the Admin UI or using the [API](/api-reference/entity/update) with the `emailTo` field. For example, if your email domain is `ap.myplatform.com` and you want your entity to have `acme@ap.myplatform.com`, set the `emailTo` to `acme`. ### Forwarding Rules and Aliases If your entity already has an AP inbox, for example `ap@acme.com`, you can ask them to set up a forwarding rule to auto-forward all emails to your `acme@ap.yourplatform.com` email address. When doing this, it's important to ensure you add `ap@acme.com` to the entity's `emailToAlias` field. Unlike `emailTo`, use the full email address for the alias. You can add as many aliases to an entity as needed. ## DNS Add the following DNS records to your domain: | Type | Name | Value | TTL | | :--- | :--- | :-------------------------- | :-- | | MX | ap | 10 client1.cloudmailin.net. | 300 | | MX | ap | 20 client2.cloudmailin.net. | 300 | Once this step is complete, it can take up to 24 hours for the DNS records to propagate. Please [contact us](mailto:support@mercoa.com) to speed up the process! ## Webhooks Mercoa can send a webhook to your server when an invoice is received. You can use this webhook to automatically process the invoice in your system. You can learn more about creating webhooks [here](/common-concepts/webhooks). ## Supported File Types Mercoa supports the following file types: * PDF * JPEG * PNG * WEBP * GIF * DOC * DOCX * XLS * XLSX * PPT * PPTX * CSV * RTF Office files are converted to PDF before being uploaded to Mercoa. All PDFs are sanitized by removing any metadata, annotations, and JavaScript embedded in the document, which can help prevent malicious attacks. Larger PDFs are compressed to reduce the size of the file before being uploaded. ![Invoice Inbox Flow](/_fern-img/119818d0639bd9dc360042487b4588fe335c5a7c0761eab596e552cb114eed13.webp) All other attachments are discarded, including ZIP files, EXE files, etc. ## Email Logs You can view the email logs for your organization in the [dashboard](https://mercoa.com/dashboard/developers#email). All incoming emails are logged, including the subject, sender, and recipients. The source email for an invoice can also be accessed using the API: ### Request GET [https://api.mercoa.com/invoice/\{invoiceId}/source-email](https://api.mercoa.com/invoice/\{invoiceId}/source-email) **`Default`** ```curl Default curl https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email \ -H "Authorization: Bearer " ``` **`Default`** ```python Default import requests url = "https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Default`** ```typescript Default import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.invoice.document.getSourceEmail("in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9"); ``` **`Default`** ```go Default package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Default`** ```ruby Default require 'uri' require 'net/http' url = URI("https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Default`** ```java Default import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email") .header("Authorization", "Bearer ") .asString(); ``` **`Default`** ```php Default request('GET', 'https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Default`** ```csharp Default using RestSharp; var client = new RestClient("https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Default`** ```swift Default import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/invoice/in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9/source-email")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ## Testing While testing, Mercoa's automatic document deduplication can be turned off by adding the `+mercoa-skip-deduplication` string to the users inbox address. For example, if your inbox address is `acme@ap.myplatform.com`, you can send an email to `acme+mercoa-skip-deduplication@ap.myplatform.com` to disable deduplication for that invoice.