Get All Sales Reps
This GET endpoint retrieves a list of sales representatives with pagination support. You can specify the page number and the number of items per page using query parameters, along with various filters.
Endpoint
- URL:
/api/salesRep?page={page}&limit={limit} - Method:
GET
Query Parameters
| Parameter | Type | Description |
|---|---|---|
page | int | The page number to retrieve. Default is 1. |
limit | int | The number of items per page. Default and max is 10. |
email | string | Filter sales reps by email address using a case-insensitive regex match. |
status | string | Filter sales reps by status (e.g., "active", "inactive"). |
company | string | Filter sales reps by company ID. |
id:in | string | Filter sales reps by a list of IDs (comma-separated). |
company:in | string | Filter sales reps by a list of company IDs (comma-separated). |
date_created:min | string | Filter sales reps created on or after this date (format: YYYY-MM-DD). |
date_created:max | string | Filter sales reps created on or before this date (format: YYYY-MM-DD). |
date_modified:min | string | Filter sales reps modified on or after this date (format: YYYY-MM-DD). |
date_modified:max | string | Filter sales reps modified on or before this date (format: YYYY-MM-DD). |
metafields | object | Filter sales reps by specific metafield criteria. Example: metafields:<key> |
metafields-in | object | Filter sales reps by a list of values for a metafield. Example: metafields-in:<key> |
Note: For metafields and metafields-in, replace <key> with the specific metafield you want to filter by. The queries allow filtering sales reps based on associated metafield values.
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
accessToken | string | Access token for authentication. (required) |
Request Body
No request body is needed for this GET operation.
Response
- Status Code: 200 OK
Sample Response Body
A successful response will return a list of sales representatives with pagination details:
{
"success": true,
"data": [
{
"id": "66a5023524b16685e42a1eda",
"email": "salesrep@example.com",
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1234567890",
"company": "665434c100e82884676936b9",
"status": "active",
"salesRepCompanies": [
"665434c100e82884676936b9",
"665434c100e82884676936ba"
],
"metaFields": [],
"createdAt": "2024-07-27T14:20:37.573Z",
"updatedAt": "2024-08-03T10:29:32.489Z"
}
],
"pagination": {
"page": 1,
"total": 15,
"count": 10
}
}
Success Response
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
data | array | List of sales rep objects. |
pagination | object | Pagination details for the response data. |
Sales Rep Object (data[])
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the sales rep. |
email | string | Email address of the sales rep. |
firstName | string | First name of the sales rep. |
lastName | string | Last name of the sales rep. |
phoneNumber | string | Contact number of the sales rep. |
company | string | Primary company ID associated with the sales rep. |
status | string | Current status of the sales rep (e.g., "active"). |
salesRepCompanies | array | Array of company IDs assigned to the sales rep. |
metaFields | array | Additional metadata related to the sales rep. |
createdAt | string (ISO 8601) | Timestamp of when the sales rep was created. |
updatedAt | string (ISO 8601) | Timestamp of the last update to the sales rep data. |
Pagination Object (pagination)
| Field | Type | Description |
|---|---|---|
page | int | Current page number of the response data. |
total | int | Total number of records available. |
count | int | Number of records returned on this page. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | Invalid query parameters or request format. |
| 401 Unauthorized | The access token is invalid or missing. |
| 403 Forbidden | You do not have permission to access this resource. |
| 500 Internal Server Error | An error occurred on the server. |
Sample Error Response
{
"success": false,
"message": "Error message describing what went wrong"
}
Notes
- Make sure the
accessTokenis valid and has the necessary permissions (READ_WRITE_CUSTOMER scope) to access sales rep data. - Adjust the
pageandlimitquery parameters to control pagination according to your needs. - Use the various filter parameters to narrow down the results based on specific criteria.
- Date filters accept dates in
YYYY-MM-DDformat and will be converted to date objects for comparison. - Only accessible to authorized users with sufficient access rights.
Examples
Example 1: Get first page of sales reps
GET /api/salesRep?page=1&limit=10
Example 2: Filter by email
GET /api/salesRep?email=john@example.com
Example 3: Filter by company and status
GET /api/salesRep?company=665434c100e82884676936b9&status=active
Example 4: Filter by multiple IDs
GET /api/salesRep?id:in=66a5023524b16685e42a1eda,66a5023524b16685e42a1edb
Example 5: Filter by date range
GET /api/salesRep?date_created:min=2024-01-01&date_created:max=2024-12-31