Skip to content

Warehouses

Warehouses

Physical or logical stock locations for inventory tracking.

The Warehouse object

object

Attributes

idstring
Other attributes
entity_idstring
namestring
is_defaultboolean
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
Examplejson
{
  "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

POST/warehouses

Create a warehouse

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Body parameters

namestringrequired

Warehouse display name.

Other parameters
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);
Example:

Returns

idstring
Other parameters
entity_idstring
namestring
is_defaultboolean
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "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

GET/warehouses

Retrieve 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_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Query parameters

limitintegeroptional

Number of results per request.

Default: 10

next_cursorstringoptional

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.

prev_cursorstringoptional

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.

include_total_countbooleanoptional

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

dataarray of objects
paginationobject

Pagination metadata including cursors and result counts

json
{
  "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

GET/warehouses/{id}

Get a warehouse

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstring<resource-id>required

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

idstring
Other parameters
entity_idstring
namestring
is_defaultboolean
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "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

PATCH/warehouses/{id}

Update a warehouse

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstring<resource-id>required

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);
Example:

Returns

idstring
Other parameters
entity_idstring
namestring
is_defaultboolean
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "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

DELETE/warehouses/{id}

Delete a warehouse

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstring<resource-id>required

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');