Delete Multiple CPNs
This API endpoint allows bulk deletion of multiple Customer Part Numbers (CPNs) associated with a company.
It ensures that only valid CPN records are deleted and performs corresponding cleanup in Elasticsearch.
Endpoint Details
- URL:
/api/cpn/multiple - Method:
POST - Authentication: Bearer Token (required)
Authentication Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be set to application/json. |
accessToken | string | A valid access token is required. |
Request Body
The request body must be a JSON object containing the list of CPN IDs to be deleted.
| Field | Type | Description |
|---|---|---|
cpnIds | array | An array of valid CPN document IDs to be deleted. |
Sample Request
{
"cpnIds": [
"69021dec6f3d8d4a6ebf8dba",
"69021dec6f3d8d4a6ebf8dbb",
"69021dec6f3d8d4a6ebf8dbc"
]
}
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | CPNs were successfully deleted. |
Sample Success Response
{
"success": true,
"message": "Deleted 3 CPN records successfully"
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Invalid request or company is locked. |
| 401 | Missing or invalid authentication token. |
| 404 | No valid CPN records found. |
| 500 | Unexpected server error. |
Notes
- All provided CPN IDs must exist in the database.
- If any associated company is locked (
isLock: true), the operation is aborted. - The corresponding CPN entries in Elasticsearch are removed for data consistency.
- Nonexistent CPN IDs will not trigger partial success; an error is returned if none are valid.