> 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/api-reference/invoice/bulk/approve/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server. # Approve Bulk Invoices (Sync) POST https://api.mercoa.com/invoices/approve Content-Type: application/json Approve multiple invoices in bulk. This endpoint will process synchronously and return a list of invoices that were approved or failed to approve. Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/invoice/bulk/approve ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Query parameters - `emitWebhooks` (boolean, optional, default: false) — If true, webhooks will be emitted for each invoice that is approved. By default, webhooks are not emitted. ### Body (application/json) This endpoint expects a BulkInvoiceApprovalRequest. - `invoices` (list of ApprovalRequestWithId, required) ## Response ### 200 - `data` (list of BulkInvoiceApprovalFromObjectResponse, required) ## Errors ### 400 Bad Request - `errorName` ("BadRequest", required) - `content` (string, required) ### 401 Unauthorized - `errorName` ("Unauthorized", required) - `content` (string, required) ### 403 Forbidden - `errorName` ("Forbidden", required) - `content` (string, required) ### 404 Not Found - `errorName` ("NotFound", required) - `content` (string, required) ### 409 Conflict - `errorName` ("Conflict", required) - `content` (string, required) ### 500 Internal Server Error - `errorName` ("InternalServerError", required) - `content` (string, required) ### 501 Unimplemented - `errorName` ("Unimplemented", required) - `content` (string, required) ## Types ### ApprovalRequestWithId - `invoiceId` (string, required) — The ID or foreign ID of the invoice to approve - `userId` (string, required) — The ID or the Foreign ID of the user - `text` (string, optional) — Comment associated with this approval action. ### BulkInvoiceApprovalFromObjectResponse - `id` (string, optional) — The ID of the invoice that was approved. If the invoice was not approved, this will be undefined - `foreignId` (string, optional) — If provided, this is the foreign ID of the invoice that was approved. - `error` (string, optional) — The error message if the invoice was not approved ## Examples **Request** ```json { "invoices": [ { "invoiceId": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", "userId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "text": "This is a reason for my action" } ] } ``` **Response** ```json { "data": [ { "id": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9" }, { "id": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", "error": "Invoice approval failed" } ] } ``` **SDK Code** ```python FromObjects import requests url = "https://api.mercoa.com/invoices/approve" payload = { "invoices": [ { "invoiceId": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", "userId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "text": "This is a reason for my action" } ] } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```typescript FromObjects import { MercoaClient } from "@mercoa/javascript"; const client = new MercoaClient({ token: "YOUR_TOKEN" }); await client.invoice.bulk.approve({ body: { invoices: [{ invoiceId: "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", text: "This is a reason for my action", userId: "user_e24fc81c-c5ee-47e8-af42-4fe29d895506" }] } }); ``` ```go FromObjects package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mercoa.com/invoices/approve" payload := strings.NewReader("{\n \"invoices\": [\n {\n \"invoiceId\": \"in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9\",\n \"userId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"text\": \"This is a reason for my action\"\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)) } ``` ```ruby FromObjects require 'uri' require 'net/http' url = URI("https://api.mercoa.com/invoices/approve") 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 \"invoices\": [\n {\n \"invoiceId\": \"in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9\",\n \"userId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"text\": \"This is a reason for my action\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` ```java FromObjects import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mercoa.com/invoices/approve") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"invoices\": [\n {\n \"invoiceId\": \"in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9\",\n \"userId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"text\": \"This is a reason for my action\"\n }\n ]\n}") .asString(); ``` ```php FromObjects request('POST', 'https://api.mercoa.com/invoices/approve', [ 'body' => '{ "invoices": [ { "invoiceId": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", "userId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "text": "This is a reason for my action" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp FromObjects using RestSharp; var client = new RestClient("https://api.mercoa.com/invoices/approve"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"invoices\": [\n {\n \"invoiceId\": \"in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9\",\n \"userId\": \"user_e24fc81c-c5ee-47e8-af42-4fe29d895506\",\n \"text\": \"This is a reason for my action\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift FromObjects import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["invoices": [ [ "invoiceId": "in_26e7b5d3-a739-4b23-9ad9-6aaa085f47a9", "userId": "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "text": "This is a reason for my action" ] ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/invoices/approve")! 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() ```