Skip to main content

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

ParameterTypeDescription
pageintThe page number to retrieve. Default is 1.
limitintThe number of items per page. Default and max is 10.
emailstringFilter sales reps by email address using a case-insensitive regex match.
statusstringFilter sales reps by status (e.g., "active", "inactive").
companystringFilter sales reps by company ID.
id:instringFilter sales reps by a list of IDs (comma-separated).
company:instringFilter sales reps by a list of company IDs (comma-separated).
date_created:minstringFilter sales reps created on or after this date (format: YYYY-MM-DD).
date_created:maxstringFilter sales reps created on or before this date (format: YYYY-MM-DD).
date_modified:minstringFilter sales reps modified on or after this date (format: YYYY-MM-DD).
date_modified:maxstringFilter sales reps modified on or before this date (format: YYYY-MM-DD).
metafieldsobjectFilter sales reps by specific metafield criteria. Example: metafields:<key>
metafields-inobjectFilter 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

HeaderTypeDescription
accessTokenstringAccess 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

FieldTypeDescription
successbooleanIndicates if the request was successful.
dataarrayList of sales rep objects.
paginationobjectPagination details for the response data.

Sales Rep Object (data[])

FieldTypeDescription
idstringUnique identifier for the sales rep.
emailstringEmail address of the sales rep.
firstNamestringFirst name of the sales rep.
lastNamestringLast name of the sales rep.
phoneNumberstringContact number of the sales rep.
companystringPrimary company ID associated with the sales rep.
statusstringCurrent status of the sales rep (e.g., "active").
salesRepCompaniesarrayArray of company IDs assigned to the sales rep.
metaFieldsarrayAdditional metadata related to the sales rep.
createdAtstring (ISO 8601)Timestamp of when the sales rep was created.
updatedAtstring (ISO 8601)Timestamp of the last update to the sales rep data.

Pagination Object (pagination)

FieldTypeDescription
pageintCurrent page number of the response data.
totalintTotal number of records available.
countintNumber of records returned on this page.

Error Responses

Status CodeDescription
400 Bad RequestInvalid query parameters or request format.
401 UnauthorizedThe access token is invalid or missing.
403 ForbiddenYou do not have permission to access this resource.
500 Internal Server ErrorAn error occurred on the server.

Sample Error Response

{
"success": false,
"message": "Error message describing what went wrong"
}

Notes

  • Make sure the accessToken is valid and has the necessary permissions (READ_WRITE_CUSTOMER scope) to access sales rep data.
  • Adjust the page and limit query 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-DD format 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