# Check company document counts

Read valid sales and purchase document totals for your managed companies. You need an ISV API key and the country and environment you want to report on.

## Request the counts

```bash title="Read UAE sandbox usage"
curl --get 'https://prod.gets.complyance.io/v3/connect/invoices/counts' \
  --header "X-API-Key: ${COMPLYANCE_API_KEY}" \
  --header 'X-Environment: sandbox' \
  --data-urlencode 'countryCode=AE'
```

Read `data.totalCount`, `data.salesCount` and `data.purchaseCount` for the combined result and `data.companies[]` for each company. `salesCount` and `purchaseCount` are separate; `totalCount` combines them.

## Narrow the report

Add `companyId` using the identifier returned by onboarding. Add `documentType=sales` or `documentType=purchase` to select one direction.

For a date range, send both `from` and `to` in `YYYY-MM-DD`. These dates describe the latest processing update in the country’s local calendar, not the invoice issue date. Omit both for all-time counts.

## Read the result correctly

Counts include valid documents. Zero counts do not prove that no invoices were submitted: documents may still be processing or may have failed validation. Compare the relevant country, environment and dates before investigating a mismatch.

Use this endpoint for usage reporting. A later processing update can change which date range contains a document, so do not treat a past result as a fixed billing record.

## If something goes wrong

**Unexpected production totals:** send `X-Environment` explicitly. Omitting it defaults to production.

**`CONNECT_DATE_RANGE_INCOMPLETE`:** provide both dates or remove both.

**`CONNECT_COMPANY_ACCESS_DENIED`:** check that the company belongs to your workspace and the requested country. Source and branch identifiers are not company identifiers.

Next, see the [complete counts reference](https://docs.complyance.io/api-reference/connect/invoice-counts/) for supported countries and errors.

Source: https://docs.complyance.io/partner-platform/isv/invoice-counts/
