Get All Companies
Retrieves a paginated list of companies. Each company includes its company group and its billing and shipping addresses. Use the query parameters to filter the results.
HTTP Request
- URL:
/companies - Method:
GET - Headers:
accessToken: Required. Your API access token.
- Required scope:
READ_COMPANYorREAD_WRITE_COMPANY
Query Parameters
| Parameter | Type | Description |
|---|---|---|
page | Integer | Page number to retrieve. Default is 1. |
limit | Integer | Number of companies per page. Default is 10. |
name | String | Filter by company name. Partial, case-insensitive match. |
email | String | Filter by company email. Partial, case-insensitive match. |
status | String | Filter by status: pending, active or inactive. |
id | String | Return only the company with this ID. |
id:in | String | Comma-separated list of company IDs. |
companyGroup | String | Filter by company group ID. |
parentId | String | Return the direct sub-companies of this company (the members of its corporate). A company with several parents appears under each parent's filter. Indirect descendants are not returned; walk the tree by repeating the call with each child's ID. A company that has no corporate returns an empty list. |
date_created:min | String | Companies created on or after this date (ISO 8601). |
date_created:max | String | Companies created on or before this date (ISO 8601). |
date_modified:min | String | Companies updated on or after this date (ISO 8601). |
date_modified:max | String | Companies updated on or before this date (ISO 8601). |
metafields:{code} | String | Filter by a metafield value, e.g. metafields:erp_id=12543. |
metafields-in:{code} | String | Filter by a list of metafield values, e.g. metafields-in:erp_id=12543,12544. |
cURL Example
curl --location '<BASE_URL>/companies?status=active&page=1&limit=20' \
--header 'accessToken: <ACCESS_TOKEN>'
Response
- 200 OK: The companies were returned successfully.
- 400 Bad Request: The access token is missing or invalid, or a filter value is not valid.
Sample JSON Response
{
"success": true,
"data": [
{
"id": "66b9b3b166169eecd60e5ba8",
"entityId": 22,
"name": "Keystone Building Supply",
"email": "purchasing@keystonebuild.com",
"phoneNumber": "9085551234",
"status": "active",
"logo": null,
"isLock": false,
"priceLists": [],
"companyGroup": {
"_id": "66a6dd927d6c18df2d9eb836",
"name": "Wholesale",
"priceList": "66ad153dbf8641f96544341d",
"status": true,
"createdAt": "2024-07-29T00:08:50.416Z",
"updatedAt": "2024-10-03T11:07:39.111Z"
},
"shippingMethods": [],
"paymentMethods": [],
"paymentAccess": { "mode": "inherit", "methods": [] },
"paymentTerms": [],
"isSubCompany": false,
"parents": [],
"parentId": null,
"parentIds": [],
"isTaxExempt": false,
"taxExemptFileUrl": null,
"warehouses": [],
"metaFields": [],
"createdBy": {
"id": "64f0a70c6212cdcbe89a2402",
"name": "ERP integration",
"type": "api"
},
"createdAt": "2024-08-12T07:03:13.111Z",
"updatedAt": "2024-10-09T13:05:59.036Z",
"shippingAddress": [],
"billingAddress": [
{
"id": "66b9b3b166169eecd60e5ba9",
"company": "66b9b3b166169eecd60e5ba8",
"type": "billing",
"firstName": "John",
"lastName": "Doe",
"address1": "102 East Green Milton Road",
"city": "Elizabeth",
"state": { "name": "New Jersey", "code": "NJ" },
"country": { "name": "United States", "code": "US" },
"zipcode": "07202",
"isDefaultAddress": true,
"status": true,
"metaFields": [],
"createdAt": "2024-08-12T07:03:13.111Z",
"updatedAt": "2024-08-12T07:03:13.111Z"
}
]
}
],
"pagination": {
"page": 1,
"total": 1,
"count": 1
}
}
Response Details
Company Data
Each item in data has the same fields as the company returned by Get Company. The hierarchy fields are:
| Field | Type | Description |
|---|---|---|
isSubCompany | Boolean | true when the company has at least one parent. Read-only: it follows parentIds and cannot be set through the API. |
parents | Array | IDs of every company that has this company as a direct sub-company. Same values and order as parentIds. |
parentId | String | Deprecated. Use parentIds. Returns the first parent in parentIds (parentIds[0], the oldest link), or null. A company can have several parents, so this is not "the" parent. |
parentIds | Array | Same as parents. Prefer this name in new integrations. Oldest link first. |
See Corporate Hierarchy and Access for how companies are linked.
Pagination Details
| Field | Type | Description |
|---|---|---|
page | Number | Current page number. |
total | Number | Total number of companies matching the filters. |
count | Number | Number of companies on this page. |