Creates a category of materials, products or resources.
v1/categories/add.php
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Whose category: "materials", "products" or "resources" |
| name | string | Yes | Name |
A new category is placed at the end of the list of categories of this type.
You do not have to create a category in advance. In the categories field of v1/materials/add, v1/materials/edit, v1/products/add, v1/products/edit, v1/resources/add and v1/resources/edit you can pass a category as an object { name: ... } without an id: if there is no category with that name yet, it is created; if there is, the existing one is used.
Example request
{
"type": "materials",
"name": "Wood"
}
Example response
{
"success": true,
"category_id": 14
}
Errors
| Error | Reason |
|---|---|
| No type in input | type is missing |
| Invalid type value. Must be one of: materials, products, resources | Invalid type |
| No name in input | name is missing |
| Name must not be empty | Empty name |
| Name must be a string | name is not a string |
| name is too long: maximum 200 characters | Name longer than 200 characters |