Backend API: Delete a category
Edit on GitHubThe categories resource of the Backend API lets Back Office integrations delete categories. This document describes how to delete a category and how the category tree changes as a result.
Installation
The endpoints are provided by the Category and ProductCategory modules. For details on installing the category capability, see Install the Category Management feature.
Delete a category
To delete a category, send the request:
DELETE /categories/{{category_key}}
| PATH PARAMETER | DESCRIPTION |
|---|---|
| {{category_key}} | Key of the category to delete. The key is matched case-insensitively. To get it, retrieve categories. |
Deleting a category behaves as in the Back Office:
- The child categories of the deleted category are moved under its parent category.
- All additional-parent placements of the deleted category are removed together with their URLs; the subtrees below those placements are moved under the respective parent.
- The product assignments of the deleted category are removed.
- The root category cannot be deleted.
Request
| HEADER KEY | HEADER VALUE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| Authorization | string | ✓ | Alphanumeric string that authorizes the Back Office user to send requests to protected resources. Get it by authenticating as a Back Office user. |
Request sample: delete a category
DELETE https://glue-backend.mysprykershop.com/categories/gaming-laptops
Response
If the category is deleted successfully, the endpoint returns the 204 No Content status code.
Possible errors
| STATUS | CODE | REASON |
|---|---|---|
| 404 | N/A | The category with the specified key doesn’t exist. |
| 422 | N/A | The category is the root category. The root category cannot be deleted. |
| 401 | N/A | The Authorization header is missing, or the access token is invalid or expired. |
| 403 | N/A | The authenticated Back Office user is not allowed to access the categories resource. |
To view generic errors and status codes of the Backend API, see Backend API request and response reference.
Thank you!
For submitting the form