Get document counts
GET /v3/connect/invoices/counts returns company-wide Sales and Purchase document counts for usage reporting. The route retains the historical word invoices, but document counts is the canonical term.
This endpoint supports AE, SA, MY, BE, and DE. The company-onboarding POST documented in this section supports UAE only.
This is usage reporting, not an immutable billing ledger: date ranges use the document's latest processing update date.
Endpoint and base URL
GET https://prod.gets.complyance.io/v3/connect/invoices/countsThere is no separate sandbox hostname. Select sandbox or production data with X-Environment.
Authentication and headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | API key for the ISV workspace. The workspace is resolved from this key. |
X-Environment | No | sandbox or production. Defaults to production. |
Accept | No | Use application/json. |
Keep the key server-side and do not send workspaceId.
Counts do not accept simulation. The behavior of companies onboarded in simulation remains undocumented until Engineering confirms it.
Where companyId comes from
companyId is a system-generated opaque value. Obtain it from either:
data.companyIdin a successful UAE onboarding response; ordata[].idfrom the Company List API,GET /v3/connect/companies.
Do not substitute sourceName, sourceVersion, sourceId, or branchId.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
countryCode | string | Yes | AE, SA, MY, BE, or DE. |
companyId | string | No | Return one managed company. When omitted, return every managed company for the selected country. |
documentType | string | No | sales or purchase. Omit it to return both. Values are lowercase. |
from | string | No | Inclusive start date in YYYY-MM-DD. Must be provided with to. |
to | string | No | Inclusive end date in YYYY-MM-DD. Must be provided with from. |
When dates are omitted, counts are all-time. The date range uses the selected country's local calendar-day boundaries: from at local 00:00:00.000 through to at local 23:59:59.999. It filters updatedAt, with createdAt as fallback, not the document issue date.
The endpoint does not accept sourceName, sourceVersion, sourceId, or branchId as filters. Supplying one returns 400 CONNECT_VALIDATION_ERROR.
Request examples
One onboarding company, both document types
This example uses data.companyId returned by the onboarding walkthrough.
curl --get 'https://prod.gets.complyance.io/v3/connect/invoices/counts' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-Environment: sandbox' \
--header 'Accept: application/json' \
--data-urlencode 'countryCode=AE' \
--data-urlencode 'companyId=66b9f0a1c2d3e4f567890123'All companies, both document types
curl --get 'https://prod.gets.complyance.io/v3/connect/invoices/counts' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-Environment: sandbox' \
--header 'Accept: application/json' \
--data-urlencode 'countryCode=AE'Sales documents in a date range
curl --get 'https://prod.gets.complyance.io/v3/connect/invoices/counts' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-Environment: sandbox' \
--header 'Accept: application/json' \
--data-urlencode 'countryCode=AE' \
--data-urlencode 'companyId=66b9f0a1c2d3e4f567890123' \
--data-urlencode 'documentType=sales' \
--data-urlencode 'from=2026-07-01' \
--data-urlencode 'to=2026-07-31'Purchase documents in a date range
curl --get 'https://prod.gets.complyance.io/v3/connect/invoices/counts' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-Environment: sandbox' \
--header 'Accept: application/json' \
--data-urlencode 'countryCode=AE' \
--data-urlencode 'companyId=66b9f0a1c2d3e4f567890123' \
--data-urlencode 'documentType=purchase' \
--data-urlencode 'from=2026-07-01' \
--data-urlencode 'to=2026-07-31'Success response
The shape is stable for every documentType value.
{
"success": true,
"data": {
"totalCount": 25,
"salesCount": 17,
"purchaseCount": 8,
"companies": [
{
"companyId": "66b9f0a1c2d3e4f567890123",
"totalCount": 20,
"salesCount": 14,
"purchaseCount": 6
},
{
"companyId": "66b9f0a1c2d3e4f567890456",
"totalCount": 5,
"salesCount": 3,
"purchaseCount": 2
}
]
},
"meta": {
"requestId": "01K1EXAMPLE000000000000000",
"timestamp": "2026-08-14T12:00:00.000Z",
"filters": {
"countryCode": "AE",
"environment": "sandbox",
"companyId": null,
"documentType": null,
"from": null,
"to": null
}
}
}Response fields
| Field | Type | Description |
|---|---|---|
success | boolean | true. |
data.totalCount | number | Sales plus Purchase documents across the returned companies. |
data.salesCount | number | Sales documents across the returned companies. |
data.purchaseCount | number | Purchase documents across the returned companies. |
data.companies | array | Company-level count rows. |
data.companies[].companyId | string | Stable public company identifier. |
data.companies[].totalCount | number | Sales plus Purchase documents for the company. |
data.companies[].salesCount | number | Sales documents for the company. |
data.companies[].purchaseCount | number | Purchase documents for the company. |
meta.requestId | string | Request identifier for support and troubleshooting. |
meta.timestamp | string | ISO 8601 response timestamp. |
meta.filters | object | Normalized applied filters. |
meta.filters always includes countryCode, environment, companyId, documentType, from, and to. Unused optional values are null.
Zero counts and inactive companies
Managed companies with no matching documents remain in data.companies with all counts set to 0. Inactive managed companies remain visible so historical usage is preserved.
When the workspace has no managed companies for the selected country, the response keeps the same shape:
{
"success": true,
"data": {
"totalCount": 0,
"salesCount": 0,
"purchaseCount": 0,
"companies": []
},
"meta": {
"requestId": "01K1EXAMPLE000000000000000",
"timestamp": "2026-08-14T12:00:00.000Z",
"filters": {
"countryCode": "AE",
"environment": "sandbox",
"companyId": null,
"documentType": null,
"from": null,
"to": null
}
}
}Counting rules
- A document counts only when its canonical user-facing status resolves to
VALIDthrough the existing country status mapping. - Sales and Purchase use the same workspace, country, environment, company, status, and date boundaries.
- Omitting
documentTypereturns both types. documentType=salescounts only Sales and keeps Purchase fields at0.documentType=purchasecounts only Purchase and keeps Sales fields at0.totalCountalways equalssalesCount + purchaseCountat aggregate and company levels.- Results are company-wide and scoped to the workspace from the API key.
- A non-empty unknown, cross-workspace, unmanaged, or wrong-country
companyIdreturns403 CONNECT_COMPANY_ACCESS_DENIED; a blank value returns400 CONNECT_COMPANY_ID_REQUIRED.
Whether VALID credit notes and debit notes are included in Sales or Purchase counts remains a Product publication dependency.
Errors
Count errors contain error.code and error.message; this contract does not define error.retryable, error.details, or meta.workspaceId.
{
"success": false,
"error": {
"code": "CONNECT_INVALID_DOCUMENT_TYPE",
"message": "documentType must be sales or purchase."
},
"meta": {
"requestId": "01K1EXAMPLE000000000000000",
"timestamp": "2026-08-14T12:00:00.000Z"
}
}| HTTP status | Code | Description |
|---|---|---|
400 | CONNECT_VALIDATION_ERROR | A required parameter is missing or malformed, or an unsupported filter was supplied. |
400 | CONNECT_COMPANY_ID_REQUIRED | companyId was supplied empty. |
400 | CONNECT_INVALID_DOCUMENT_TYPE | documentType is not sales or purchase. |
400 | CONNECT_INVALID_ENVIRONMENT | X-Environment is unsupported. |
400 | CONNECT_UNSUPPORTED_COUNTRY | Counts are unsupported for the requested country. |
400 | CONNECT_DATE_RANGE_INCOMPLETE | Only one of from or to was supplied. |
400 | CONNECT_INVALID_DATE_RANGE | from is later than to. |
401 | CONNECT_AUTH_CONTEXT_MISSING | The key is missing, invalid, or did not provide a workspace context. |
403 | CONNECT_ISV_ACCESS_DENIED | The workspace cannot use Connect APIs. |
403 | CONNECT_COMPANY_ACCESS_DENIED | The company is unknown, cross-workspace, unmanaged, or associated with another country. |
429 | CONNECT_RATE_LIMIT_EXCEEDED | The 120-requests-per-minute workspace limit was exceeded. Honor Retry-After. |
502 | CONNECT_COMPANY_LOOKUP_FAILED | Managed companies could not be resolved. |
502 | CONNECT_TRANSACTION_COUNT_LOOKUP_FAILED | Document counts could not be retrieved. |
See Errors and troubleshooting for caller actions.
Rate limit
The endpoint allows 120 requests per minute per workspace. A 429 response includes Retry-After; back off for that rate-limit interval.
Related pages
Next step: Review error recovery and support information.