Skip to main content

Update CPN

This PUT API allows you to update an existing Customer Part Number (CPN) record using its unique identifier. You can modify the CPN value and its active status.

Endpoint Details

  • URL: /api/cpn/{id}
  • Method: PUT
  • Authentication: Bearer Token (required)

Authentication

You must provide a valid accessToken in the request headers to authenticate and access this endpoint.

Authentication Headers

HeaderTypeDescription
Content-TypestringMust be set to application/json.
accessTokenstringA valid access token is required.

Path Parameters

ParameterTypeDescription
idstringThe unique identifier of the CPN to be updated.

Request Body

The request body must be in JSON format and should contain the following fields:

FieldTypeDescription
cpnstringThe updated Customer Part Number value.

Sample Request Body

{
"cpn": "UPDATED-CPN-123"
}

Response

Success Response

Status CodeDescription
200 OKThe CPN was updated successfully.

Success Response Body Structure

FieldTypeDescription
successbooleanIndicates if the request was successful.
messagestringMessage indicating the result of the operation.
dataobjectContains the updated CPN details.

Sample Response Body

{
"success": true,
"message": "Updated successfully",
"data": {
"_id": "68f9b47e43ecaa4383999bfc",
"companyId": "683825752b054dc60961d31b",
"productId": "687ab2dd37df295c08bc65fc",
"cpn": "UPDATED-CPN-123",
"createdBy": {
"name": "Axim Commerce",
"type": "admin"
},
"createdAt": "2025-10-23T04:52:13.736Z",
"updatedAt": "2025-10-31T05:25:30.246Z"
}
}

Error Responses

Status CodeDescription
400 Bad RequestInvalid data or missing parameters.
401 UnauthorizedInvalid or missing access token.
403 ForbiddenAccess denied.
404 Not FoundThe specified CPN record does not exist.
500 Internal Server ErrorAn unexpected server error occurred.

Notes

  • The id must be a valid MongoDB ObjectId.
  • Only the cpn field can be updated.
  • Ensure you provide a valid access token with the necessary permissions.