Contents
Create Category - Plugixa Inventory
POST /plugixa-inventory/v1/categories
Create a category to group items.
The user needs the plugixa_inventory_create capability (administrators have every inventory capability). With Pro Roles and permissions enforcing, their role must also allow creating categories.
Request
POST https://your-site.example/wp-json/plugixa-inventory/v1/categories
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Must not be blank. At most 255 characters. |
code |
string |
No | Turned to upper case. Letters, digits, - and _ only. Must be unique among live categories. At most 50 characters. |
description |
string |
No | HTML. Tags not allowed in a WordPress post are removed. |
status |
string |
No | published (the default) or unpublished. |
Only name is required.
{
"name": "Office supplies",
"code": "office",
"description": "<p>Paper, toner and desk items.</p>"
}
Responses
201 Created. data is the new category.
{
"success": true,
"data": {
"id": 3,
"code": "OFFICE",
"name": "Office supplies",
"description": "<p>Paper, toner and desk items.</p>",
"status": "published",
"created_by": 1,
"modified_by": 1,
"created_at": "2026-11-12 09:30:00",
"modified_at": "2026-11-12 09:30:00",
"deleted_at": null
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The new category’s id |
data.code |
string |
The code, in upper case. Empty when none was given |
data.status |
string |
published or unpublished |
data.created_at |
string |
UTC datetime |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_inventory_missing_name |
name is missing or blank. |
422 |
plugixa_inventory_invalid_choice |
status is not one of the allowed values. data.allowed lists them. |
422 |
plugixa_inventory_too_long |
A text field is longer than its column. data.field names it and data.max gives the limit. |
422 |
plugixa_inventory_invalid_code |
code contains a character other than letters, digits, - and _. |
409 |
plugixa_inventory_duplicate_code |
Another live category already uses this code. |
500 |
plugixa_inventory_insert_failed |
The database refused to save the category. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-inventory/v1/categories" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Office supplies","code":"office","description":"<p>Paper, toner and desk items.</p>"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-inventory/v1/categories');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Office supplies',
'code' => 'office',
'description' => '<p>Paper, toner and desk items.</p>',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-inventory/v1/categories', {
method: 'POST',
headers: { 'Authorization': auth, 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Office supplies',
code: 'office',
description: '<p>Paper, toner and desk items.</p>',
}),
});
const { data } = await response.json();
Quick Links
Share