Skip to main content

Get All CPNs

This API endpoint retrieves a list of Customer Part Numbers (CPNs) from the server, allowing you to filter results by various criteria such as companyId, search, sorting, and pagination parameters.

HTTP Request

  • URL: /api/cpn
  • Method: GET
  • Headers:
    • accessToken: Required. This is your access token for authenticating the request.

Query Parameters

To effectively retrieve and manage Customer Part Numbers (CPNs), you can include the following query parameters:

ParameterTypeDescription
pageIntegerThe page number to retrieve; defaults to 1 if not specified.
limitIntegerThe number of items to retrieve per page; defaults to 10.
companyIdStringThe unique identifier of the company whose CPNs you want to retrieve.
searchStringSearch keyword to filter by CPN (case-insensitive partial match).
sortByStringField to sort by (e.g., cpn, createdAt, _id).
sortOrderStringSorting order: "asc" for ascending, "desc" for descending.

CURL Example

Below is a sample cURL command that demonstrates how to make a request to the API endpoint:

curl --location '<BASE_URL>/api/cpn?page=1&limit=10&companyId=<COMPANY_ID>&search=<SEARCH_TEXT>&sortBy=cpn&sortOrder=asc' --header 'accessToken: <ACCESS_TOKEN>'

Response

  • 200 OK: The request was successful, and the server returned a list of CPNs.
  • 4XX: Client errors indicating issues such as an invalid access token or missing parameters.
  • 5XX: Server errors indicating that something went wrong on the server's end.

Sample JSON Response

Below is an example of the JSON response you might receive from making a request to this endpoint:

{
"success": true,
"data": [
{
"_id": "69021dec6f3d8d4a6ebf8dba",
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a35",
"cpn": "testing",
"createdBy": {
"id": "69019a38743e239a3f8f8be7",
"name": "Evangeline Schmidt",
"email": "eva@gmail.com",
"type": "store"
},
"createdAt": "2025-10-29T14:00:12.567Z",
"updatedAt": "2025-10-29T14:01:17.363Z"
}
// Additional CPNs omitted for brevity...
],
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"pages": 10
}
}

Response Details

KeyTypeDescription
successBooleanIndicates if the request was successful.
dataArray of ObjectsList of Customer Part Numbers (CPNs).
paginationObjectProvides pagination details.

Customer Part Number (CPN) Data

FieldTypeDescription
_idStringThe unique identifier of the CPN.
companyIdStringThe unique identifier of the company associated with the CPN.
productIdStringThe product or variant ID associated with the CPN.
cpnStringThe Customer Part Number value.
createdByObjectInformation about the user who created the CPN.
createdAtStringDate and time when the record was created (ISO 8601 format).
updatedAtStringDate and time when the record was last updated (ISO 8601 format).

createdBy Object

FieldTypeDescription
idStringThe ID of the user who created it.
nameStringThe name of the creator.
emailStringThe email of the creator.
typeStringThe creator's user type (e.g. store).

Pagination Details

KeyTypeDescription
pageIntegerCurrent page number.
limitIntegerNumber of items returned per page.
totalIntegerTotal number of items available.
pagesIntegerTotal number of available pages.

Notes

  • Ensure that the accessToken provided is valid and not expired.
  • The search parameter performs a case-insensitive partial match on the cpn field.
  • The productId field can refer to either a product or a product variant.
  • Use pagination parameters (page, limit) for efficient data retrieval.
  • Sorting parameters (sortBy, sortOrder) allow flexible ordering of results.