> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mercoa.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server.

# Download Invoices

GET https://api.mercoa.com/entityGroup/{entityGroupId}/invoices/download

Get a URL to download invoices for an entity group as a CSV/JSON file.

Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/entity-group/invoice/download

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `entityGroupId` (string, required) — Entity Group ID or Entity Group ForeignID

### Query parameters

- `format` (enum, optional) — Format of the file to download. Defaults to CSV.
  - Allowed values: `CSV`, `JSON`
- `startDate` (datetime, optional) — Start date filter. Defaults to CREATED_AT unless specified the dateType is specified
- `endDate` (datetime, optional) — End date filter. Defaults to CREATED_AT unless specified the dateType is specified
- `dateType` (enum, optional) — Type of date to filter by if startDate and endDate filters are provided. Defaults to CREATED_AT.
  - Allowed values: `INVOICE_DATE`, `DEDUCTION_DATE`, `DUE_DATE`, `SETTLEMENT_DATE`, `CREATED_AT`, `UPDATED_AT`
- `orderBy` (enum, optional) — Field to order invoices by. Defaults to CREATED_AT.
  - Allowed values: `AMOUNT`, `DUE_DATE`, `CREATED_AT`, `UPDATED_AT`, `DEDUCTION_DATE`, `INVOICE_DATE`, `SETTLEMENT_DATE`, `INVOICE_NUMBER`, `VENDOR_NAME`, `PAYER_NAME`
- `orderDirection` (enum, optional) — Direction to order invoices by. Defaults to asc.
  - Allowed values: `ASC`, `DESC`
- `search` (string, optional) — Find invoices by vendor name, invoice number, check number, or amount. Partial matches are supported.
- `metadata` (object, optional) — Filter invoices by metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored.
  - `key` (string, required)
  - `value` (string or list of string, required) — If multiple values are provided, the filter will match if any of the values match (OR filter). To filter for the absence of a key, use the value 'NULL'. To filter for the presence of a key, use the value 'NOT NULL'.
- `lineItemMetadata` (object, optional) — Filter invoices by line item metadata. Each filter will be applied as an AND condition. Duplicate keys will be ignored.
  - `key` (string, required)
  - `value` (string or list of string, required) — If multiple values are provided, the filter will match if any of the values match (OR filter). To filter for the absence of a key, use the value 'NULL'. To filter for the presence of a key, use the value 'NOT NULL'.
- `lineItemGlAccountId` (string, optional) — Filter invoices by line item GL account ID. Each filter will be applied as an OR condition. Duplicate keys will be ignored.
- `payerId` (string, optional) — Filter invoices by payer ID or payer foreign ID.
- `vendorId` (string, optional) — Filter invoices by vendor ID or vendor foreign ID.
- `creatorUserId` (string, optional) — Filter invoices by the ID or foreign ID of the user that created the invoice.
- `approverId` (string, optional) — Filter invoices by assigned approver user ID. Only invoices with all upstream policies approved will be returned.
- `approverAction` (enum, optional) — Filter invoices by approver action. Needs to be used with approverId. For example, if you want to find all invoices that have been approved by a specific user, you would use approverId and approverAction=APPROVE.
  - Allowed values: `NONE`, `APPROVE`, `REJECT`
- `invoiceId` (string, optional) — Filter invoices by invoice ID or invoice foreign ID.
- `status` (enum, optional) — Invoice status to filter on
  - Allowed values: `UNASSIGNED`, `DRAFT`, `NEW`, `APPROVED`, `SCHEDULED`, `PENDING`, `PAID`, `ARCHIVED`, `REFUSED`, `CANCELED`, `FAILED`
- `paymentType` (list of enum, optional) — Filter invoices by recurring status
  - Allowed values: `oneTime`, `recurring`
- `invoiceTemplateId` (string, optional) — Filter invoice by invoice template ID
- `excludePayables` (boolean, optional) — Return only invoices that are receivable by the entity.
- `excludeReceivables` (boolean, optional) — Return only invoices that are payable by the entity.
- `returnPayerMetadata` (boolean, optional) — Whether to return payer metadata in the response
- `returnVendorMetadata` (boolean, optional) — Whether to return vendor metadata in the response

## Response

### 200

- `url` (string, required)
- `mimeType` (string, 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)

## Examples

**Response**

```json
{
  "url": "https://mercoa.com/download/bulk-invoices.csv",
  "mimeType": "text/csv"
}
```

**SDK Code**

```python Default
import requests

url = "https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download"

querystring = {"format":"CSV","excludeReceivables":"true"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```typescript Default
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entityGroup.invoice.download("entg_8545a84e-a45f-41bf-bdf1-33b42a55812c", {
    format: "CSV",
    excludeReceivables: true
});

```

```go Default
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=true"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=true")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=true")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=true', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=true");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Default
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entityGroup/entg_8545a84e-a45f-41bf-bdf1-33b42a55812c/invoices/download?format=CSV&excludeReceivables=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()
```