Skip to main content

Create CPN

Creates a customer part number (CPN) that links a company's own part number to one of your products or variants. Each company can have one CPN per product or variant.

HTTP Request​

  • URL: /cpn
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_CUSTOMERPARTNUMBER or READ_WRITE_CUSTOMERPARTNUMBER

Request Body​

The request body is a JSON object with the following fields:

FieldTypeRequiredDescription
companyIdStringYesID of the company. The company must not be locked.
productIdStringYesID of the product or variant.
cpnStringYesThe customer part number.

cURL Example​

curl --location '<BASE_URL>/cpn' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a35",
"cpn": "ACME-VLV-0042"
}'

Response​

  • 200 OK: The CPN was created successfully.
  • 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, a field is missing or invalid, the company was not found or is locked, the product or variant was not found, or a CPN already exists for this company and product.

Sample JSON Response​

{
"success": true,
"message": "Created successfully",
"data": {
"_id": "69021dec6f3d8d4a6ebf8dba",
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a35",
"cpn": "ACME-VLV-0042",
"createdBy": {
"id": "66a0f138a8323b0b86b0f1dc",
"name": "ERP Connector",
"type": "api"
},
"createdAt": "2025-10-29T14:02:52.118Z",
"updatedAt": "2025-10-29T14:02:52.118Z"
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the CPN was created.
messageStringResult message.
dataObjectThe new CPN. The fields are the same as in Get All CPNs.

Notes​

  • If the company already has a CPN for the product or variant, the API returns CPN already exists for this company/product. Use Update CPN to change it.