Create a category
POST
/categories
const url = 'https://api.oletapp.com/your-store/v1/categories';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","parent_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.oletapp.com/your-store/v1/categories \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "parent_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }'A missing or foreign parent_id is refused with 404 NOT_FOUND. Nesting under a system category, or under a parent already at maximum depth, is refused with 400 VALIDATION_FAILED. Duplicate names are allowed.
Requires scope: catalog:write
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Media typeapplication/json
object
name
required
string
parent_id
string format: uuid
Examplegenerated
{ "name": "example", "parent_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}Responses
Section titled “Responses”Create a category
Media typeapplication/json
object
Examplegenerated
{ "data": { "depth": 1, "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "parent_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "version": "example" }}default
Section titled “default”An error response.
Media typeapplication/json
object
error
required
object
code
required
A machine-readable error code, e.g. VALIDATION_FAILED.
string
fields
Array<object>
object
field
required
string
message
required
string
message
required
A plain-English sentence describing what went wrong.
string
Example
{ "error": { "code": "UNAUTHORIZED" }}