> 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/creating-payouts-via-api/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server. In this guide, we will be using Mercoa for AP Payments. We will not be using the frontend components or workflows. If you plan to use Mercoa's frontend components, check out our [Frontend Integration](/getting-started/step-3-frontend-integration) guide. ## Install SDK #### Javascript/Typescript ```bash npm install --save @mercoa/javascript # or yarn add @mercoa/javascript ``` #### Java ```groovy implementation 'com.mercoa:mercoa:v0.3.34' ``` #### Python ```bash pip install mercoa # or poetry add mercoa ``` #### Go ```bash go get github.com/mercoa-finance/go ``` ## Create the payer entity [API Reference](/api-reference/entity/create) The payer entity is the customer who will initiate the payment of an invoice. In order to start processing payments for the customer, you will need to [collect data required to run KYB](/common-concepts/entities#requirements). ### Request POST [https://api.mercoa.com/entity](https://api.mercoa.com/entity) **`BusinessPayor`** ```curl BusinessPayor curl -X POST https://api.mercoa.com/entity \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "isCustomer": true, "isPayor": true, "isPayee": false, "accountType": "business", "foreignId": "MY-DB-ID-12345", "profile": { "business": { "email": "customer@acme.com", "legalBusinessName": "Acme Inc.", "website": "http://www.acme.com", "businessType": "llc", "phone": { "countryCode": "1", "number": "4155551234" }, "address": { "addressLine1": "123 Main St", "addressLine2": "Unit 1", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "country": "US" }, "taxId": { "ein": { "number": "12-3456789" } } } } }' ``` **`BusinessPayor`** ```python BusinessPayor import requests url = "https://api.mercoa.com/entity" payload = { "isCustomer": True, "isPayor": True, "isPayee": False, "accountType": "business", "foreignId": "MY-DB-ID-12345", "profile": { "business": { "email": "customer@acme.com", "legalBusinessName": "Acme Inc.", "website": "http://www.acme.com", "businessType": "llc", "phone": { "countryCode": "1", "number": "4155551234" }, "address": { "addressLine1": "123 Main St", "addressLine2": "Unit 1", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "country": "US" }, "taxId": { "ein": { "number": "12-3456789" } } } } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`BusinessPayor`** ```typescript BusinessPayor import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.create({ isCustomer: true, isPayor: true, isPayee: false, accountType: "business", foreignId: "MY-DB-ID-12345", profile: { business: { email: "customer@acme.com", legalBusinessName: "Acme Inc.", website: "http://www.acme.com", businessType: "llc", phone: { countryCode: "1", number: "4155551234" }, address: { addressLine1: "123 Main St", addressLine2: "Unit 1", city: "San Francisco", stateOrProvince: "CA", postalCode: "94105", country: "US" }, taxId: { ein: { number: "12-3456789" } } } } }); ``` **`BusinessPayor`** ```go BusinessPayor package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity" payload := strings.NewReader("{\n \"isCustomer\": true,\n \"isPayor\": true,\n \"isPayee\": false,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-12345\",\n \"profile\": {\n \"business\": {\n \"email\": \"customer@acme.com\",\n \"legalBusinessName\": \"Acme Inc.\",\n \"website\": \"http://www.acme.com\",\n \"businessType\": \"llc\",\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Unit 1\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"country\": \"US\"\n },\n \"taxId\": {\n \"ein\": {\n \"number\": \"12-3456789\"\n }\n }\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BusinessPayor`** ```ruby BusinessPayor require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"isCustomer\": true,\n \"isPayor\": true,\n \"isPayee\": false,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-12345\",\n \"profile\": {\n \"business\": {\n \"email\": \"customer@acme.com\",\n \"legalBusinessName\": \"Acme Inc.\",\n \"website\": \"http://www.acme.com\",\n \"businessType\": \"llc\",\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Unit 1\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"country\": \"US\"\n },\n \"taxId\": {\n \"ein\": {\n \"number\": \"12-3456789\"\n }\n }\n }\n }\n}" response = http.request(request) puts response.read_body ``` **`BusinessPayor`** ```java BusinessPayor import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"isCustomer\": true,\n \"isPayor\": true,\n \"isPayee\": false,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-12345\",\n \"profile\": {\n \"business\": {\n \"email\": \"customer@acme.com\",\n \"legalBusinessName\": \"Acme Inc.\",\n \"website\": \"http://www.acme.com\",\n \"businessType\": \"llc\",\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Unit 1\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"country\": \"US\"\n },\n \"taxId\": {\n \"ein\": {\n \"number\": \"12-3456789\"\n }\n }\n }\n }\n}") .asString(); ``` **`BusinessPayor`** ```php BusinessPayor request('POST', 'https://api.mercoa.com/entity', [ 'body' => '{ "isCustomer": true, "isPayor": true, "isPayee": false, "accountType": "business", "foreignId": "MY-DB-ID-12345", "profile": { "business": { "email": "customer@acme.com", "legalBusinessName": "Acme Inc.", "website": "http://www.acme.com", "businessType": "llc", "phone": { "countryCode": "1", "number": "4155551234" }, "address": { "addressLine1": "123 Main St", "addressLine2": "Unit 1", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "country": "US" }, "taxId": { "ein": { "number": "12-3456789" } } } } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BusinessPayor`** ```csharp BusinessPayor using RestSharp; var client = new RestClient("https://api.mercoa.com/entity"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"isCustomer\": true,\n \"isPayor\": true,\n \"isPayee\": false,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-12345\",\n \"profile\": {\n \"business\": {\n \"email\": \"customer@acme.com\",\n \"legalBusinessName\": \"Acme Inc.\",\n \"website\": \"http://www.acme.com\",\n \"businessType\": \"llc\",\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Unit 1\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"country\": \"US\"\n },\n \"taxId\": {\n \"ein\": {\n \"number\": \"12-3456789\"\n }\n }\n }\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BusinessPayor`** ```swift BusinessPayor import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "isCustomer": true, "isPayor": true, "isPayee": false, "accountType": "business", "foreignId": "MY-DB-ID-12345", "profile": ["business": [ "email": "customer@acme.com", "legalBusinessName": "Acme Inc.", "website": "http://www.acme.com", "businessType": "llc", "phone": [ "countryCode": "1", "number": "4155551234" ], "address": [ "addressLine1": "123 Main St", "addressLine2": "Unit 1", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "country": "US" ], "taxId": ["ein": ["number": "12-3456789"]] ]] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` If you do not have all the data required, you can use Mercoa's [hosted onboarding](/api-reference/entity/get-onboarding-link) to capture it. By using a `foreignId`, you don't need to store the Mercoa `entityId` in your system. You can query for entities by `foreignId` with: ### Request GET [https://api.mercoa.com/entity](https://api.mercoa.com/entity) **`Find Entity With foreignId`** ```curl Find Entity With foreignId curl -G https://api.mercoa.com/entity \ -H "Authorization: Bearer " \ -d isCustomer=true \ -d foreignId=MY-DB-ID-12345 \ -d paymentMethods=true ``` **`Find Entity With foreignId`** ```python Find Entity With foreignId import requests url = "https://api.mercoa.com/entity" querystring = {"isCustomer":"true","foreignId":"MY-DB-ID-12345","paymentMethods":"true"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Find Entity With foreignId`** ```typescript Find Entity With foreignId import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.find({ isCustomer: true, foreignId: "MY-DB-ID-12345", paymentMethods: true }); ``` **`Find Entity With foreignId`** ```go Find Entity With foreignId package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true" 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)) } ``` **`Find Entity With foreignId`** ```ruby Find Entity With foreignId require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true") 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 ``` **`Find Entity With foreignId`** ```java Find Entity With foreignId import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true") .header("Authorization", "Bearer ") .asString(); ``` **`Find Entity With foreignId`** ```php Find Entity With foreignId request('GET', 'https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Find Entity With foreignId`** ```csharp Find Entity With foreignId using RestSharp; var client = new RestClient("https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Find Entity With foreignId`** ```swift Find Entity With foreignId import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity?isCustomer=true&foreignId=MY-DB-ID-12345&paymentMethods=true")! 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() ``` In this example, the `entityId` is `ent_8545a84e-a45f-41bf-bdf1-33b42a55812c` ### Create Representatives [API Reference](/api-reference/entity/representative/create) If the entity is a business, you will need to collect information about the owners and controllers of the business. See the [Business Representatives guide](/common-concepts/business-representatives) for more details. Mercoa's hosted onboarding can capture this information for you! ### Request POST [https://api.mercoa.com/entity/\{entityId}/representative](https://api.mercoa.com/entity/\{entityId}/representative) **`BusinessPayorRepresentative`** ```curl BusinessPayorRepresentative curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "name": { "firstName": "John", "lastName": "Adams", "middleName": "Quincy", "suffix": "Jr." }, "address": { "addressLine1": "123 Main St", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "addressLine2": "Unit 1", "country": "US" }, "birthDate": { "day": "1", "month": "1", "year": "1980" }, "governmentID": { "ssn": "123-45-6789" }, "responsibilities": { "isController": true, "isOwner": true, "ownershipPercentage": 40 }, "phone": { "countryCode": "1", "number": "4155551234" }, "email": "john.doe@acme.com" }' ``` **`BusinessPayorRepresentative`** ```python BusinessPayorRepresentative import requests url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative" payload = { "name": { "firstName": "John", "lastName": "Adams", "middleName": "Quincy", "suffix": "Jr." }, "address": { "addressLine1": "123 Main St", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "addressLine2": "Unit 1", "country": "US" }, "birthDate": { "day": "1", "month": "1", "year": "1980" }, "governmentID": { "ssn": "123-45-6789" }, "responsibilities": { "isController": True, "isOwner": True, "ownershipPercentage": 40 }, "phone": { "countryCode": "1", "number": "4155551234" }, "email": "john.doe@acme.com" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`BusinessPayorRepresentative`** ```typescript BusinessPayorRepresentative import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.representative.create("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", { name: { firstName: "John", middleName: "Quincy", lastName: "Adams", suffix: "Jr." }, phone: { countryCode: "1", number: "4155551234" }, email: "john.doe@acme.com", address: { addressLine1: "123 Main St", addressLine2: "Unit 1", city: "San Francisco", stateOrProvince: "CA", postalCode: "94105", country: "US" }, birthDate: { day: "1", month: "1", year: "1980" }, governmentId: { ssn: "123-45-6789" }, responsibilities: { isOwner: true, ownershipPercentage: 40, isController: true } }); ``` **`BusinessPayorRepresentative`** ```go BusinessPayorRepresentative package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative" payload := strings.NewReader("{\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Adams\",\n \"middleName\": \"Quincy\",\n \"suffix\": \"Jr.\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"addressLine2\": \"Unit 1\",\n \"country\": \"US\"\n },\n \"birthDate\": {\n \"day\": \"1\",\n \"month\": \"1\",\n \"year\": \"1980\"\n },\n \"governmentID\": {\n \"ssn\": \"123-45-6789\"\n },\n \"responsibilities\": {\n \"isController\": true,\n \"isOwner\": true,\n \"ownershipPercentage\": 40\n },\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"email\": \"john.doe@acme.com\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BusinessPayorRepresentative`** ```ruby BusinessPayorRepresentative require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Adams\",\n \"middleName\": \"Quincy\",\n \"suffix\": \"Jr.\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"addressLine2\": \"Unit 1\",\n \"country\": \"US\"\n },\n \"birthDate\": {\n \"day\": \"1\",\n \"month\": \"1\",\n \"year\": \"1980\"\n },\n \"governmentID\": {\n \"ssn\": \"123-45-6789\"\n },\n \"responsibilities\": {\n \"isController\": true,\n \"isOwner\": true,\n \"ownershipPercentage\": 40\n },\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"email\": \"john.doe@acme.com\"\n}" response = http.request(request) puts response.read_body ``` **`BusinessPayorRepresentative`** ```java BusinessPayorRepresentative import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Adams\",\n \"middleName\": \"Quincy\",\n \"suffix\": \"Jr.\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"addressLine2\": \"Unit 1\",\n \"country\": \"US\"\n },\n \"birthDate\": {\n \"day\": \"1\",\n \"month\": \"1\",\n \"year\": \"1980\"\n },\n \"governmentID\": {\n \"ssn\": \"123-45-6789\"\n },\n \"responsibilities\": {\n \"isController\": true,\n \"isOwner\": true,\n \"ownershipPercentage\": 40\n },\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"email\": \"john.doe@acme.com\"\n}") .asString(); ``` **`BusinessPayorRepresentative`** ```php BusinessPayorRepresentative request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative', [ 'body' => '{ "name": { "firstName": "John", "lastName": "Adams", "middleName": "Quincy", "suffix": "Jr." }, "address": { "addressLine1": "123 Main St", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "addressLine2": "Unit 1", "country": "US" }, "birthDate": { "day": "1", "month": "1", "year": "1980" }, "governmentID": { "ssn": "123-45-6789" }, "responsibilities": { "isController": true, "isOwner": true, "ownershipPercentage": 40 }, "phone": { "countryCode": "1", "number": "4155551234" }, "email": "john.doe@acme.com" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BusinessPayorRepresentative`** ```csharp BusinessPayorRepresentative using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Adams\",\n \"middleName\": \"Quincy\",\n \"suffix\": \"Jr.\"\n },\n \"address\": {\n \"addressLine1\": \"123 Main St\",\n \"city\": \"San Francisco\",\n \"stateOrProvince\": \"CA\",\n \"postalCode\": \"94105\",\n \"addressLine2\": \"Unit 1\",\n \"country\": \"US\"\n },\n \"birthDate\": {\n \"day\": \"1\",\n \"month\": \"1\",\n \"year\": \"1980\"\n },\n \"governmentID\": {\n \"ssn\": \"123-45-6789\"\n },\n \"responsibilities\": {\n \"isController\": true,\n \"isOwner\": true,\n \"ownershipPercentage\": 40\n },\n \"phone\": {\n \"countryCode\": \"1\",\n \"number\": \"4155551234\"\n },\n \"email\": \"john.doe@acme.com\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BusinessPayorRepresentative`** ```swift BusinessPayorRepresentative import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "name": [ "firstName": "John", "lastName": "Adams", "middleName": "Quincy", "suffix": "Jr." ], "address": [ "addressLine1": "123 Main St", "city": "San Francisco", "stateOrProvince": "CA", "postalCode": "94105", "addressLine2": "Unit 1", "country": "US" ], "birthDate": [ "day": "1", "month": "1", "year": "1980" ], "governmentID": ["ssn": "123-45-6789"], "responsibilities": [ "isController": true, "isOwner": true, "ownershipPercentage": 40 ], "phone": [ "countryCode": "1", "number": "4155551234" ], "email": "john.doe@acme.com" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/representative")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` ### Accept Terms of Service Once the entity and representatives are created, your user will need to accept the Mercoa ToS. There are a few ways to do this: 1. Include the [Mercoas ToS](https://mercoa.com/legal/platform-agreement) as part of your ToS and have the user accept the updated ToS 2. Show the [Mercoa ToS](https://mercoa.com/legal/platform-agreement) directly, and have the user accept the Mercoa ToS Mercoa's hosted onboarding can have the user accept the terms of service directly Once the user has accepted the ToS, use the [Accept ToS Endpoint](/api-reference/entity/accept-terms-of-service) to indicate as such. ### Request POST [https://api.mercoa.com/entity/\{entityId}/accept-tos](https://api.mercoa.com/entity/\{entityId}/accept-tos) **`Default`** ```curl Default curl -X POST https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos \ -H "Authorization: Bearer " ``` **`Default`** ```python Default import requests url = "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` **`Default`** ```typescript Default import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.acceptTermsOfService("ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced"); ``` **`Default`** ```go Default package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos" req, _ := http.NewRequest("POST", 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/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.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.post("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos") .header("Authorization", "Bearer ") .asString(); ``` **`Default`** ```php Default request('POST', 'https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Default`** ```csharp Default using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos"); var request = new RestRequest(Method.POST); 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/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/accept-tos")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ``` ### Initiate KYB Once all data is captured and ToS is verified, you can [initiate the KYB process](/api-reference/entity/initiate-kyb). ### Request POST [https://api.mercoa.com/entity/\{entityId}/request-kyb](https://api.mercoa.com/entity/\{entityId}/request-kyb) **`Default`** ```curl Default curl -X POST https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb \ -H "Authorization: Bearer " ``` **`Default`** ```python Default import requests url = "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` **`Default`** ```typescript Default import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.initiateKyb("ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced"); ``` **`Default`** ```go Default package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb" req, _ := http.NewRequest("POST", 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/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.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.post("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb") .header("Authorization", "Bearer ") .asString(); ``` **`Default`** ```php Default request('POST', 'https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Default`** ```csharp Default using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb"); var request = new RestRequest(Method.POST); 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/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/request-kyb")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ``` ### Create Payer Bank Account The easiest way to connect the payer bank account is to use our [Plaid integration](/common-concepts/payment-methods/plaid-integration) You can also create the account via API and use micro-deposits to verify it. Micro-deposits can take 2-5 days to show up in the bank account. [Create](/api-reference/entity/payment-method/create) ### Request POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod](https://api.mercoa.com/entity/\{entityId}/paymentMethod) **`BankAccount`** ```curl BankAccount curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "bankAccount", "accountNumber": "99988767623", "accountType": "CHECKING", "routingNumber": "12345678" }' ``` **`BankAccount`** ```python BankAccount import requests url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod" payload = { "type": "bankAccount", "accountNumber": "99988767623", "accountType": "CHECKING", "routingNumber": "12345678" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`BankAccount`** ```typescript BankAccount import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.paymentMethod.create("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", { type: "bankAccount", routingNumber: "12345678", accountNumber: "99988767623", accountType: "CHECKING" }); ``` **`BankAccount`** ```go BankAccount package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod" payload := strings.NewReader("{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"99988767623\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"12345678\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BankAccount`** ```ruby BankAccount require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"99988767623\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"12345678\"\n}" response = http.request(request) puts response.read_body ``` **`BankAccount`** ```java BankAccount import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"99988767623\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"12345678\"\n}") .asString(); ``` **`BankAccount`** ```php BankAccount request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod', [ 'body' => '{ "type": "bankAccount", "accountNumber": "99988767623", "accountType": "CHECKING", "routingNumber": "12345678" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BankAccount`** ```csharp BankAccount using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"99988767623\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"12345678\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BankAccount`** ```swift BankAccount import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "type": "bankAccount", "accountNumber": "99988767623", "accountType": "CHECKING", "routingNumber": "12345678" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` [Initiate Micro Deposits](/api-reference/entity/payment-method/bank-account/initiate-micro-deposits) ### Request POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/micro-deposits](https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/micro-deposits) **`BankAccount`** ```curl BankAccount curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits \ -H "Authorization: Bearer " ``` **`BankAccount`** ```python BankAccount import requests url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits" headers = {"Authorization": "Bearer "} response = requests.post(url, headers=headers) print(response.json()) ``` **`BankAccount`** ```typescript BankAccount import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.paymentMethod.bankAccount.initiateMicroDeposits("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "pm_4794d597-70dc-4fec-b6ec-c5988e759769"); ``` **`BankAccount`** ```go BankAccount package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits" req, _ := http.NewRequest("POST", 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)) } ``` **`BankAccount`** ```ruby BankAccount require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`BankAccount`** ```java BankAccount import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits") .header("Authorization", "Bearer ") .asString(); ``` **`BankAccount`** ```php BankAccount request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`BankAccount`** ```csharp BankAccount using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`BankAccount`** ```swift BankAccount import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ``` [Complete Micro Deposits](/api-reference/entity/payment-method/bank-account/complete-micro-deposits) ### Request PUT [https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/micro-deposits](https://api.mercoa.com/entity/\{entityId}/paymentMethod/\{paymentMethodId}/micro-deposits) **`BankAccount`** ```curl BankAccount curl -X PUT https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "amounts": [ 40, 2 ] }' ``` **`BankAccount`** ```python BankAccount import requests url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits" payload = { "amounts": [40, 2] } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers) print(response.json()) ``` **`BankAccount`** ```typescript BankAccount import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.paymentMethod.bankAccount.completeMicroDeposits("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "pm_4794d597-70dc-4fec-b6ec-c5988e759769", { amounts: [40, 2] }); ``` **`BankAccount`** ```go BankAccount package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits" payload := strings.NewReader("{\n \"amounts\": [\n 40,\n 2\n ]\n}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BankAccount`** ```ruby BankAccount require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"amounts\": [\n 40,\n 2\n ]\n}" response = http.request(request) puts response.read_body ``` **`BankAccount`** ```java BankAccount import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"amounts\": [\n 40,\n 2\n ]\n}") .asString(); ``` **`BankAccount`** ```php BankAccount request('PUT', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits', [ 'body' => '{ "amounts": [ 40, 2 ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BankAccount`** ```csharp BankAccount using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits"); var request = new RestRequest(Method.PUT); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"amounts\": [\n 40,\n 2\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BankAccount`** ```swift BankAccount import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["amounts": [40, 2]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/paymentMethod/pm_4794d597-70dc-4fec-b6ec-c5988e759769/micro-deposits")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` In this example, the payer's `paymentMethodId` is `pm_4794d597-70dc-4fec-b6ec-c5988e759769` ## Create the vendor entity The next step is to create the vendor entity. This is the entity that will be paid by your customer. For a business, we require their legal business name. ### Request POST [https://api.mercoa.com/entity](https://api.mercoa.com/entity) **`BusinessVendor`** ```curl BusinessVendor curl -X POST https://api.mercoa.com/entity \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "isCustomer": false, "isPayor": false, "isPayee": true, "accountType": "business", "foreignId": "MY-DB-ID-90909", "profile": { "business": { "email": "vendor@bigboxstore.com", "legalBusinessName": "Big Box Store", "website": "http://www.bigboxstore.com", "businessType": "publicCorporation" } } }' ``` **`BusinessVendor`** ```python BusinessVendor import requests url = "https://api.mercoa.com/entity" payload = { "isCustomer": False, "isPayor": False, "isPayee": True, "accountType": "business", "foreignId": "MY-DB-ID-90909", "profile": { "business": { "email": "vendor@bigboxstore.com", "legalBusinessName": "Big Box Store", "website": "http://www.bigboxstore.com", "businessType": "publicCorporation" } } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`BusinessVendor`** ```typescript BusinessVendor import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.create({ isCustomer: false, isPayor: false, isPayee: true, accountType: "business", foreignId: "MY-DB-ID-90909", profile: { business: { email: "vendor@bigboxstore.com", legalBusinessName: "Big Box Store", website: "http://www.bigboxstore.com", businessType: "publicCorporation" } } }); ``` **`BusinessVendor`** ```go BusinessVendor package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity" payload := strings.NewReader("{\n \"isCustomer\": false,\n \"isPayor\": false,\n \"isPayee\": true,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-90909\",\n \"profile\": {\n \"business\": {\n \"email\": \"vendor@bigboxstore.com\",\n \"legalBusinessName\": \"Big Box Store\",\n \"website\": \"http://www.bigboxstore.com\",\n \"businessType\": \"publicCorporation\"\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BusinessVendor`** ```ruby BusinessVendor require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"isCustomer\": false,\n \"isPayor\": false,\n \"isPayee\": true,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-90909\",\n \"profile\": {\n \"business\": {\n \"email\": \"vendor@bigboxstore.com\",\n \"legalBusinessName\": \"Big Box Store\",\n \"website\": \"http://www.bigboxstore.com\",\n \"businessType\": \"publicCorporation\"\n }\n }\n}" response = http.request(request) puts response.read_body ``` **`BusinessVendor`** ```java BusinessVendor import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"isCustomer\": false,\n \"isPayor\": false,\n \"isPayee\": true,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-90909\",\n \"profile\": {\n \"business\": {\n \"email\": \"vendor@bigboxstore.com\",\n \"legalBusinessName\": \"Big Box Store\",\n \"website\": \"http://www.bigboxstore.com\",\n \"businessType\": \"publicCorporation\"\n }\n }\n}") .asString(); ``` **`BusinessVendor`** ```php BusinessVendor request('POST', 'https://api.mercoa.com/entity', [ 'body' => '{ "isCustomer": false, "isPayor": false, "isPayee": true, "accountType": "business", "foreignId": "MY-DB-ID-90909", "profile": { "business": { "email": "vendor@bigboxstore.com", "legalBusinessName": "Big Box Store", "website": "http://www.bigboxstore.com", "businessType": "publicCorporation" } } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BusinessVendor`** ```csharp BusinessVendor using RestSharp; var client = new RestClient("https://api.mercoa.com/entity"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"isCustomer\": false,\n \"isPayor\": false,\n \"isPayee\": true,\n \"accountType\": \"business\",\n \"foreignId\": \"MY-DB-ID-90909\",\n \"profile\": {\n \"business\": {\n \"email\": \"vendor@bigboxstore.com\",\n \"legalBusinessName\": \"Big Box Store\",\n \"website\": \"http://www.bigboxstore.com\",\n \"businessType\": \"publicCorporation\"\n }\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BusinessVendor`** ```swift BusinessVendor import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "isCustomer": false, "isPayor": false, "isPayee": true, "accountType": "business", "foreignId": "MY-DB-ID-90909", "profile": ["business": [ "email": "vendor@bigboxstore.com", "legalBusinessName": "Big Box Store", "website": "http://www.bigboxstore.com", "businessType": "publicCorporation" ]] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` In this example, the vendor `entityId` is `ent_21661ac1-a2a8-4465-a6c0-64474ba8181d` ### Create vendor payment method If you have the vendor's bank account information, you can pre-create their payment method ### Request POST [https://api.mercoa.com/entity/\{entityId}/paymentMethod](https://api.mercoa.com/entity/\{entityId}/paymentMethod) **`BankAccountVendor`** ```curl BankAccountVendor curl -X POST https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "bankAccount", "accountNumber": "55934059697648", "accountType": "CHECKING", "routingNumber": "66554433" }' ``` **`BankAccountVendor`** ```python BankAccountVendor import requests url = "https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod" payload = { "type": "bankAccount", "accountNumber": "55934059697648", "accountType": "CHECKING", "routingNumber": "66554433" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`BankAccountVendor`** ```typescript BankAccountVendor import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.entity.paymentMethod.create("ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", { type: "bankAccount", routingNumber: "66554433", accountNumber: "55934059697648", accountType: "CHECKING" }); ``` **`BankAccountVendor`** ```go BankAccountVendor package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod" payload := strings.NewReader("{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"55934059697648\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"66554433\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`BankAccountVendor`** ```ruby BankAccountVendor require 'uri' require 'net/http' url = URI("https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"55934059697648\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"66554433\"\n}" response = http.request(request) puts response.read_body ``` **`BankAccountVendor`** ```java BankAccountVendor import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"55934059697648\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"66554433\"\n}") .asString(); ``` **`BankAccountVendor`** ```php BankAccountVendor request('POST', 'https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod', [ 'body' => '{ "type": "bankAccount", "accountNumber": "55934059697648", "accountType": "CHECKING", "routingNumber": "66554433" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`BankAccountVendor`** ```csharp BankAccountVendor using RestSharp; var client = new RestClient("https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"bankAccount\",\n \"accountNumber\": \"55934059697648\",\n \"accountType\": \"CHECKING\",\n \"routingNumber\": \"66554433\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`BankAccountVendor`** ```swift BankAccountVendor import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "type": "bankAccount", "accountNumber": "55934059697648", "accountType": "CHECKING", "routingNumber": "66554433" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_21661ac1-a2a8-4465-a6c0-64474ba8181d/paymentMethod")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` Vendor bank accounts do not need to be verified. If you don't have the vendor's account information, you can collect it using the [entity onboarding link](/api-reference/entity/get-onboarding-link) In this example, the vendor's `paymentMethodId` is `pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18` ## Create and schedule the payment The final step to make a payment is to [create and schedule the invoice](/accounts-payable/invoices#4-scheduling-the-payment). ### Request POST [https://api.mercoa.com/invoice](https://api.mercoa.com/invoice) **`CreateScheduledInvoice`** ```curl CreateScheduledInvoice curl -X POST https://api.mercoa.com/invoice \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "status": "SCHEDULED", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", "currency": "USD", "amount": 100, "invoiceDate": "2021-01-01T00:00:00Z", "dueDate": "2021-01-31T00:00:00Z", "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "deductionDate": "2021-01-29T00:00:00Z" }' ``` **`CreateScheduledInvoice`** ```python CreateScheduledInvoice import requests url = "https://api.mercoa.com/invoice" payload = { "status": "SCHEDULED", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", "currency": "USD", "amount": 100, "invoiceDate": "2021-01-01T00:00:00Z", "dueDate": "2021-01-31T00:00:00Z", "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "deductionDate": "2021-01-29T00:00:00Z" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`CreateScheduledInvoice`** ```typescript CreateScheduledInvoice import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.invoice.create({ status: "SCHEDULED", payerId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", creatorEntityId: "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", vendorId: "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", currency: "USD", amount: 100, invoiceDate: new Date("2021-01-01T00:00:00.000Z"), dueDate: new Date("2021-01-31T00:00:00.000Z"), paymentSourceId: "pm_4794d597-70dc-4fec-b6ec-c5988e759769", paymentDestinationId: "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", deductionDate: new Date("2021-01-29T00:00:00.000Z") }); ``` **`CreateScheduledInvoice`** ```go CreateScheduledInvoice package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/invoice" payload := strings.NewReader("{\n \"status\": \"SCHEDULED\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"dueDate\": \"2021-01-31T00:00:00Z\",\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"deductionDate\": \"2021-01-29T00:00:00Z\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`CreateScheduledInvoice`** ```ruby CreateScheduledInvoice require 'uri' require 'net/http' url = URI("https://api.mercoa.com/invoice") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"status\": \"SCHEDULED\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"dueDate\": \"2021-01-31T00:00:00Z\",\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"deductionDate\": \"2021-01-29T00:00:00Z\"\n}" response = http.request(request) puts response.read_body ``` **`CreateScheduledInvoice`** ```java CreateScheduledInvoice import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/invoice") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"status\": \"SCHEDULED\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"dueDate\": \"2021-01-31T00:00:00Z\",\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"deductionDate\": \"2021-01-29T00:00:00Z\"\n}") .asString(); ``` **`CreateScheduledInvoice`** ```php CreateScheduledInvoice request('POST', 'https://api.mercoa.com/invoice', [ 'body' => '{ "status": "SCHEDULED", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", "currency": "USD", "amount": 100, "invoiceDate": "2021-01-01T00:00:00Z", "dueDate": "2021-01-31T00:00:00Z", "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "deductionDate": "2021-01-29T00:00:00Z" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`CreateScheduledInvoice`** ```csharp CreateScheduledInvoice using RestSharp; var client = new RestClient("https://api.mercoa.com/invoice"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"status\": \"SCHEDULED\",\n \"payerId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"creatorEntityId\": \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n \"vendorId\": \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"invoiceDate\": \"2021-01-01T00:00:00Z\",\n \"dueDate\": \"2021-01-31T00:00:00Z\",\n \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n \"paymentDestinationId\": \"pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18\",\n \"deductionDate\": \"2021-01-29T00:00:00Z\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`CreateScheduledInvoice`** ```swift CreateScheduledInvoice import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "status": "SCHEDULED", "payerId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "creatorEntityId": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "vendorId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d", "currency": "USD", "amount": 100, "invoiceDate": "2021-01-01T00:00:00Z", "dueDate": "2021-01-31T00:00:00Z", "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769", "paymentDestinationId": "pm_5fde2f4a-facc-48ef-8f0d-6b7d087c7b18", "deductionDate": "2021-01-29T00:00:00Z" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/invoice")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ``` If you don't have the `paymentDestinationId`, you can collect it using the [payment acceptance link](/api-reference/invoice/payment-links/get-vendor-link). The invoice needs to be set into the `DRAFT` or `NEW` state as it cannot be scheduled without a `paymentDestinationId` On the `deductionDate`, the payment will be triggered! If the `deductionDate` is set to a past date or is set after the daily payments cutoff, the payment will be triggered on the next payments window.