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
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be set to application/json. |
accessToken | string | A valid access token is required. |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the CPN to be updated. |
Request Body
The request body must be in JSON format and should contain the following fields:
| Field | Type | Description |
|---|---|---|
cpn | string | The updated Customer Part Number value. |
Sample Request Body
{
"cpn": "UPDATED-CPN-123"
}
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The CPN was updated successfully. |
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | object | Contains 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 Code | Description |
|---|---|
| 400 Bad Request | Invalid data or missing parameters. |
| 401 Unauthorized | Invalid or missing access token. |
| 403 Forbidden | Access denied. |
| 404 Not Found | The specified CPN record does not exist. |
| 500 Internal Server Error | An unexpected server error occurred. |
Notes
- The
idmust be a valid MongoDB ObjectId. - Only the
cpnfield can be updated. - Ensure you provide a valid access token with the necessary permissions.