Skip to main content

Create Multiple CPNs

Creates many customer part numbers (CPNs) in one request. The CPNs can belong to one or more companies.

HTTP Request​

  • URL: /cpn/multiple
  • 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 field:

FieldTypeRequiredDescription
partNumbersArrayYesList of CPNs to create. See Part Number Object.

Part Number Object​

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/multiple' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"partNumbers": [
{
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a35",
"cpn": "ACME-VLV-0042"
},
{
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a36",
"cpn": "ACME-VLV-0043"
}
]
}'

Response​

  • 200 OK: The CPNs were created successfully.
  • 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, a record is missing a field, a company was not found or is locked, or there were no new CPNs to create.

Sample JSON Response​

{
"success": true,
"message": "Inserted 2 CPN records successfully",
"data": [
{
"id": "69021dec6f3d8d4a6ebf8dba",
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a35",
"cpn": "ACME-VLV-0042"
},
{
"id": "69021dec6f3d8d4a6ebf8dbb",
"companyId": "683808ee2b054dc60961637c",
"productId": "687a84a7958d6a5c0d0c7a36",
"cpn": "ACME-VLV-0043"
}
]
}

Response Details​

FieldTypeDescription
successBooleanWhether the request was successful.
messageStringNumber of CPNs created.
dataArrayThe created CPNs, each with id, companyId, productId and cpn.

Notes​

  • Records for products or variants that do not exist are skipped.
  • Records for a company and product that already have a CPN are skipped. If every record is skipped, the API returns All entries already exist.
  • If any company in the request is locked or not found, no CPNs are created.