Warehouses
Warehouses
Physical or logical stock locations for inventory tracking.
The Warehouse object
Attributes
{
"id": "wh_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Main warehouse",
"is_default": true,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
}Create a warehouse
/warehousesCreate a warehouse
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Body parameters
Warehouse display name.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.warehouses.create({
name: "Main warehouse",
is_default: true
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "wh_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Main warehouse",
"is_default": true,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
}List warehouses
/warehousesRetrieve a paginated list of the entity's warehouses, excluding deleted ones. Results are ordered newest first (created_at descending, ties broken by id) and use cursor-based pagination.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Query parameters
Number of results per request.
Default: 10
Opaque cursor to fetch the next page of results. Reuse only with the same effective ordering. Use the value from pagination.next_cursor in the previous response.
Opaque cursor to fetch the previous page of results. Reuse only with the same effective ordering. Use the value from pagination.prev_cursor in the previous response.
Whether to include the total count of items in pagination.total.
Default is true.
When false, pagination.total returns -1 for better performance.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.warehouses.list({
limit: 20,
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Pagination metadata including cursors and result counts
{
"data": [
{
"id": "wh_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Main warehouse",
"is_default": true,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
},
{
"id": "wh_6595a27b5d35015c3ef0c3fe",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Retail store",
"is_default": false,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
}
],
"pagination": {
"total": 2,
"next_cursor": null,
"prev_cursor": null,
"has_more": false
}
}Get a warehouse
/warehouses/{id}Get a warehouse
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Warehouse identifier (wh_ prefix).
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.warehouses.get('WAREHOUSES_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "wh_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Main warehouse",
"is_default": true,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
}Update a warehouse
/warehouses/{id}Update a warehouse
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Warehouse identifier (wh_ prefix).
Body parameters
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.warehouses.update('WAREHOUSES_ID', {
name: "Central warehouse"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "wh_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fc",
"name": "Central warehouse",
"is_default": true,
"created_at": "2024-06-01T09:00:00.000Z",
"updated_at": "2024-06-01T09:00:00.000Z",
"deleted_at": null
}Delete a warehouse
/warehouses/{id}Delete a warehouse
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Warehouse identifier (wh_ prefix).
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
await sdk.warehouses.delete('WAREHOUSES_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log('Deleted successfully');