Skip to main content

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

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

Request Body

The request body must be a JSON object containing the list of CPN IDs to be deleted.

FieldTypeDescription
cpnIdsarrayAn array of valid CPN document IDs to be deleted.

Sample Request

{
"cpnIds": [
"69021dec6f3d8d4a6ebf8dba",
"69021dec6f3d8d4a6ebf8dbb",
"69021dec6f3d8d4a6ebf8dbc"
]
}

Response

Success Response

Status CodeDescription
200 OKCPNs were successfully deleted.

Sample Success Response

{
"success": true,
"message": "Deleted 3 CPN records successfully"
}

Error Responses

Status CodeDescription
400Invalid request or company is locked.
401Missing or invalid authentication token.
404No valid CPN records found.
500Unexpected 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.