Create a category
POST /api/category/v1/category
creates a hierarchy of categories. You may create a single category and, if necessary, add additional subcategories to the request body to create a category hierarchy.
Request schema
Method |
URL |
POST |
/api/category/v1/category |
*indicates required parameters
Field |
Value Type |
Description |
*Authorization |
String |
Enter: Bearer access token. |
*Upc-Selected-Company |
Integer |
Company’s ID. Use the value returned in the id field received in response to the following request: GET /api/auth/v1/companies . |
X-User-Id |
Text |
Enter the email address of the user being impersonated. This value is required if you are using a two-legged token. If you are using a three-legged token, then this field is not required. |
Request body
Field |
Value Type |
Description |
*name |
String |
Name of the category to be created. |
description |
String |
Description of the category. |
children |
Array |
An array of subcategories. A name should be set for each subcategory, while the description field is optional. |
Sample request body
{
"name": "Screws & Bolts",
"description": "Screws & Bolts",
"children": [
{
"name": "Socket Head Screws"
}
]
}
Response schema
Response body
201 response
Field |
Value Type |
Description |
id |
Integer |
Created category ID. |
parentId |
Integer |
Parent category ID. |
name |
String |
Created category name. |
description |
String |
Created category description. |
level |
Integer |
Category level in the category hierarchy (children have greater levels). Note that the levels returned from this API are null. This is because the levels are not stored in the database and are instead calculated programmatically when fetching categories (see Get all categories). |
children |
Array of categories |
An array of subcategories, containing the same parameters as the main category (id, parentId, name, description, and level) for each. |
Sample response body
{
"id": 1289,
"parentId": null,
"name": "Screws & Bolts",
"description": "Screws & Bolts",
"level": null,
"children": [
{
"id": 1290,
"parentId": 1289,
"name": "Socket Head Screws",
"description": "null",
"level": null,
"children": null
}
]
}