Contents
Create Warehouse - Plugixa Inventory
POST /plugixa-inventory/v1/warehouses
Create a warehouse: any place stock is kept.
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 warehouses.
Request
POST https://your-site.example/wp-json/plugixa-inventory/v1/warehouses
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 warehouses. At most 50 characters. |
address |
string |
No | HTML. Tags not allowed in a WordPress post are removed. |
status |
string |
No | published (the default) or unpublished. |
Only name is required. A new warehouse holds nothing.
{
"name": "Main warehouse",
"code": "main",
"address": "<p>12 Harbour Road, Leeds</p>"
}
Responses
201 Created. data is the new warehouse.
{
"success": true,
"data": {
"id": 1,
"code": "MAIN",
"name": "Main warehouse",
"address": "<p>12 Harbour Road, Leeds</p>",
"custom_fields": null,
"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 warehouse’s id |
data.code |
string |
The code, in upper case |
data.custom_fields |
object|null |
The Pro custom field values, when custom fields are defined for warehouses |
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 warehouse already uses this code. |
500 |
plugixa_inventory_insert_failed |
The database refused to save the warehouse. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-inventory/v1/warehouses" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Main warehouse","code":"main","address":"<p>12 Harbour Road, Leeds</p>"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-inventory/v1/warehouses');
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' => 'Main warehouse',
'code' => 'main',
'address' => '<p>12 Harbour Road, Leeds</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/warehouses', {
method: 'POST',
headers: { 'Authorization': auth, 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Main warehouse',
code: 'main',
address: '<p>12 Harbour Road, Leeds</p>',
}),
});
const { data } = await response.json();
Quick Links
Share