Skip to content

Items

The Item object

object

Attributes

item_idstring
track_inventoryboolean
Examplejson
{
  "item_id": "item_6595a27b5d35015c3ef0c3fd",
  "track_inventory": true,
  "quantity_on_hand": 6,
  "total_value": 30,
  "average_unit_cost": 5,
  "layers": [
    {
      "movement_id": "invm_6595a27b5d35015c3ef0c3fd",
      "occurred_at": "2024-06-01T09:00:00.000Z",
      "unit_cost": 5,
      "quantity_remaining": 6
    }
  ],
  "warehouses": [
    {
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
      "warehouse_name": "Main warehouse",
      "quantity_on_hand": 4,
      "total_value": 20
    },
    {
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fe",
      "warehouse_name": "Retail store",
      "quantity_on_hand": 2,
      "total_value": 10
    }
  ]
}

Create a new item

POST/items

Create a new product or service item for use in invoices. Items can include pricing, tax information (inline or by reference), and unit details. All fields except name are optional.

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
descriptionstringoptionalnullable
pricenumberoptional

Net price per unit before tax in the item's currency major unit; for EUR, 29.90 means €29.90, not 2,990 cents. Provide either price OR gross_price, not both.

gross_pricenumberoptional

Gross price per unit including tax in the item's currency major unit; for EUR, 29.90 means €29.90, not 2,990 cents. If provided, net price is calculated. Provide either price OR gross_price, not both.

taxesarray of objectsoptionalnullable

Taxes for the item. Provide rate to auto-create, or classification to lookup existing tax.

metadataobjectoptionalnullable

Custom string key-value data for your own use, with up to 50 properties. Keys are opaque and may contain periods. Useful for storing external IDs, tags, or integration data.

Other parameters
tax_idsarray of stringsoptional
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.create({
  name: "Satellite Communication Module",
  price: 1500
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);
Example:

Returns

idstring
namestring
descriptionstringnullable
pricenumber

Per-unit net price (before tax). Always stores net price.

gross_pricenumbernullable

Per-unit gross price (includes tax). Only present if user originally sent gross price.

metadatastringnullable
Other parameters
tax_idsarray of strings
total_taxnumber
entity_idstring
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "id": "item_6595a27b5d35015c3ef0c3fd",
  "name": "Satellite Communication Module",
  "description": null,
  "translations": {},
  "price": 1500,
  "gross_price": null,
  "unit": null,
  "e_invoicing": null,
  "price_with_tax": 1500,
  "categories": [],
  "track_inventory": false,
  "sku": null,
  "usage": null,
  "barcode": null,
  "purchase_price": null,
  "total_tax": 0,
  "tax_ids": [],
  "entity_id": "ent_6595a27b5d35015c3ef0c3fd",
  "metadata": {},
  "deleted_at": null,
  "created_at": "2024-01-01T00:00:00.000Z",
  "updated_at": "2024-09-01T00:00:00.000Z"
}
Example:

Import items from a file

POST/items/import

Upsert items by SKU from a CSV/XLSX file, with optional starting stock recorded as adjustment_in movements. All-or-nothing: if any row in the file has an error, nothing is written and the full row report is returned with a 422.

Preset fields:
- classification: one of product, service, advance
- usage: sale, purchase or both (sales and purchases); when updating, leave empty to keep the current value
- track_inventory: yes or no
- price / gross_price: fill exactly one, not both
- tax_rate: must equal an existing tax rate of the entity (e.g. 22)
- categories: separate multiple values with ;
- stock_date: YYYY-MM-DD, defaults to today when empty
- stock_warehouse: name of an existing warehouse, defaults to the default warehouse when empty
- sku: matches an existing item to update it; leave empty to always create a new item

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

filestring<binary>required

CSV or XLSX file to import

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
import fs from 'fs';

const sdk = new SpaceInvoices('YOUR_API_KEY');

// Read file as Buffer
const fileBuffer = fs.readFileSync('/path/to/image.png');
const file = new File([fileBuffer], 'image.png', { type: 'image/png' });

const response = await sdk.items.importItems({
  file
}, { entity_id: 'YOUR_ENTITY_ID' });

console.log(response);

Returns

total_rowsinteger
createdinteger
updatedinteger
skippedinteger
errorsinteger
json
{
  "total_rows": 2,
  "created": 1,
  "updated": 1,
  "skipped": 0,
  "errors": 0,
  "stock_movements": 1,
  "committed": true,
  "rows": [
    {
      "row": 1,
      "sku": "SKU-1001",
      "name": "Glass of red wine",
      "action": "create",
      "stock": "create",
      "messages": []
    },
    {
      "row": 2,
      "sku": "SKU-1002",
      "name": "Sparkling water",
      "action": "update",
      "stock": "none",
      "messages": []
    }
  ]
}

List all items

GET/items

Retrieve a paginated list of items (products and services) with optional filtering and sorting. Supports cursor-based pagination, flexible JSON querying with MongoDB-style operators, full-text search, and sorting.

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.

order_byoptional

Sort by one field or provide a repeated array for multi-column ordering. Prefix a field with - for descending order. When paginating, reuse cursors only with the same effective ordering.

querystring<json>optional

JSON query object for filtering results. Supports MongoDB-style operators.

Array columns (such as an item's categories) compare as sets: a direct value asks whether the list contains it, contains takes an array and requires all of them, in matches any of them, and notIn matches none. Scalar operators such as gt do not apply and are ignored.

Supported operators:
- equals or direct value - Exact match (default)
- gte - Greater than or equal
- lte - Less than or equal
- gt - Greater than
- lt - Less than
- in - Value in array
- notIn - Value not in array
- contains - String contains (case-insensitive)
- startsWith - String starts with
- endsWith - String ends with
- between - Value between two numbers/dates [min, max]

Allowed fields: id, name, description, price, unit, categories, track_inventory, usage, created_at, updated_at

Examples:
- {"total": {"gte": 1000}} - Invoices over 1000
- {"customer.name": {"contains": "Acme"}} - Customer name contains "Acme"
- {"date": {"between": ["2025-01-01", "2025-12-31"]}} - Date range

searchstringoptional

Full-text search query to filter results across multiple fields.
Searches are case-insensitive and match partial strings.
Searches across all text fields including names, descriptions, addresses, and metadata values.

deletedbooleanoptional

When true, returns only soft-deleted (trashed) items. Default false excludes deleted items.

categoriesstringoptional

Comma-separated categories. Returns items in *any* of them, which is what a point-of-sale category chip filters by. Shorthand for the equivalent query operator form, kept because a filter row should not have to build JSON.

usagestringoptional

Items for this side: items with this usage, items without a usage, and inventory-tracked items. Use sale for pickers on sales documents and purchase for pickers on expenses and purchase orders. Omit to list every item.

Possible values: "sale", "purchase"

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.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": "item_7595a27b5d35015c3ef0c3fe",
      "name": "Orbital Navigation License",
      "description": "Annual software license for orbital trajectory planning",
      "translations": {
        "name": {
          "de-DE": "Orbitale Navigationslizenz"
        },
        "description": {
          "de-DE": "Jaehrliche Softwarelizenz fuer die Planung von Orbitaltrajektorien"
        }
      },
      "price": 5000,
      "gross_price": null,
      "unit": null,
      "e_invoicing": null,
      "price_with_tax": 6100,
      "categories": [],
      "track_inventory": false,
      "sku": null,
      "usage": null,
      "barcode": null,
      "purchase_price": null,
      "total_tax": 1100,
      "tax_ids": [
        "tax_6595a27b5d35015c3ef0c3fd"
      ],
      "entity_id": "ent_6595a27b5d35015c3ef0c3fd",
      "metadata": {
        "category": "software",
        "unit": "license"
      },
      "deleted_at": null,
      "created_at": "2024-01-01T00:00:00.000Z",
      "updated_at": "2024-09-01T00:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 1,
    "next_cursor": null,
    "prev_cursor": null,
    "has_more": false
  }
}

List item categories in use

GET/items/categories

Every category currently assigned to an item on this entity, alphabetically. Categories are free text on the item, so this is derived from the catalog rather than a managed list — use it to build a filter row without paging the whole catalog to discover the values.

Header parameters

entity_idstringoptional

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

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.categories({
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

dataarray of strings
json
{
  "data": [
    "by the glass",
    "food",
    "wine"
  ]
}

Download an items import template

GET/items/import/template

Download a starter CSV or XLSX file with the import's column headers and one filled-in example row that previews with zero errors. Column headers are always the English identifiers; the example row's free-text values (name, description, unit, category) are localized via the language parameter. The CSV has localized # comment lines above the header describing the preset fields below; the XLSX has a localized "Instructions" sheet plus notes on the relevant header cells.

Preset fields:
- classification: one of product, service, advance
- usage: sale, purchase or both (sales and purchases); when updating, leave empty to keep the current value
- track_inventory: yes or no
- price / gross_price: fill exactly one, not both
- tax_rate: must equal an existing tax rate of the entity (e.g. 22)
- categories: separate multiple values with ;
- stock_date: YYYY-MM-DD, defaults to today when empty
- stock_warehouse: name of an existing warehouse, defaults to the default warehouse when empty
- sku: matches an existing item to update it; leave empty to always create a new item

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

formatstringrequired

Template file format.

Possible values: "csv", "xlsx"

languagestringoptionalnullable

Language for the example row's free-text values (name, description, unit, category). Defaults to the entity locale when omitted. Column headers are always the English identifiers documented below.

Possible values: "en", "de", "sl", "it", "fr", "es", "pt", "nl", "pl", "hr", "sv", "fi", "et", "bg", "cs", "sk", "nb", "is", "hu", "null"

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const blob = await sdk.items.getItemsImportTemplate({
  format: "csv"
}, {
  entity_id: "YOUR_ENTITY_ID"
});

const arrayBuffer = await blob.arrayBuffer();
const { writeFile } = await import('node:fs/promises');
await writeFile('download.bin', Buffer.from(arrayBuffer));
console.log('Saved download.bin');

Update an item

PATCH/items/{id}

Update an existing product or service item. Only the provided fields are updated. Pricing and taxes are recalculated consistently with item creation rules.

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

Body parameters

namestringoptional
descriptionstringoptionalnullable

Free-form description of the item. Omit to keep the current value; send null to clear it.

pricenumberoptional

Net price per unit before tax in the item's currency major unit; for EUR, 29.90 means €29.90, not 2,990 cents. Provide either price OR gross_price, not both.

gross_pricenumberoptional

Gross price per unit including tax in the item's currency major unit; for EUR, 29.90 means €29.90, not 2,990 cents. If provided, net price is calculated. Provide either price OR gross_price, not both.

taxesarray of objectsoptionalnullable

Taxes for the item. Provide rate to auto-create, or classification to lookup existing tax.

metadataobjectoptionalnullable

Custom string key-value data for your own use, with up to 50 properties. Keys are opaque and may contain periods. Useful for storing external IDs, tags, or integration data.

Other parameters
tax_idsarray of stringsoptional
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.update('itm_6595a27b5d35015c3ef0c3fd', {
  name: "Satellite Communication Module v2"
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);
Example:

Returns

idstring
namestring
descriptionstringnullable
pricenumber

Per-unit net price (before tax). Always stores net price.

gross_pricenumbernullable

Per-unit gross price (includes tax). Only present if user originally sent gross price.

metadatastringnullable
Other parameters
tax_idsarray of strings
total_taxnumber
entity_idstring
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "id": "item_6595a27b5d35015c3ef0c3fd",
  "name": "Satellite Communication Module v2",
  "description": null,
  "translations": {},
  "price": 1500,
  "gross_price": null,
  "unit": null,
  "e_invoicing": null,
  "price_with_tax": 1500,
  "categories": [],
  "track_inventory": false,
  "sku": null,
  "usage": null,
  "barcode": null,
  "purchase_price": null,
  "total_tax": 0,
  "tax_ids": [],
  "entity_id": "ent_6595a27b5d35015c3ef0c3fd",
  "metadata": {},
  "deleted_at": null,
  "created_at": "2024-01-01T00:00:00.000Z",
  "updated_at": "2024-09-02T00:00:00.000Z"
}
Example:

Delete an item

DELETE/items/{id}

Soft delete an item. The item will be moved to the trash and can be restored later.

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

await sdk.items.delete('itm_6595a27b5d35015c3ef0c3fd', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log('Deleted successfully');

Permanently delete an item

DELETE/items/{id}/permanent

Permanently delete a soft-deleted item. Only items in the trash can be permanently deleted.

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

await sdk.items.permanentDeleteItem('itm_6595a27b5d35015c3ef0c3fd', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log('Deleted successfully');

Delete an inventory movement

DELETE/items/{id}/inventory/movements/{movementId}

Delete an inventory movement

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

movementIdstring<resource-id>required

Inventory movement identifier.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

await sdk.items.deleteItemInventoryMovement('itm_6595a27b5d35015c3ef0c3fd', 'MOVEMENT_ID', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log('Deleted successfully');

Preview an items import

POST/items/import/preview

Parse and classify a CSV/XLSX file of items (and optional starting stock) without writing anything. Returns the same report shape as the commit endpoint, with committed: false.

Preset fields:
- classification: one of product, service, advance
- usage: sale, purchase or both (sales and purchases); when updating, leave empty to keep the current value
- track_inventory: yes or no
- price / gross_price: fill exactly one, not both
- tax_rate: must equal an existing tax rate of the entity (e.g. 22)
- categories: separate multiple values with ;
- stock_date: YYYY-MM-DD, defaults to today when empty
- stock_warehouse: name of an existing warehouse, defaults to the default warehouse when empty
- sku: matches an existing item to update it; leave empty to always create a new item

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

filestring<binary>required

CSV or XLSX file to import

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
import fs from 'fs';

const sdk = new SpaceInvoices('YOUR_API_KEY');

// Read file as Buffer
const fileBuffer = fs.readFileSync('/path/to/image.png');
const file = new File([fileBuffer], 'image.png', { type: 'image/png' });

const response = await sdk.items.preview({
  file
}, { entity_id: 'YOUR_ENTITY_ID' });

console.log(response);

Returns

total_rowsinteger
createdinteger
updatedinteger
skippedinteger
errorsinteger
json
{
  "total_rows": 3,
  "created": 1,
  "updated": 1,
  "skipped": 0,
  "errors": 1,
  "stock_movements": 1,
  "committed": false,
  "rows": [
    {
      "row": 1,
      "sku": "SKU-1001",
      "name": "Glass of red wine",
      "action": "create",
      "stock": "create",
      "messages": []
    },
    {
      "row": 2,
      "sku": "SKU-1002",
      "name": "Sparkling water",
      "action": "update",
      "stock": "none",
      "messages": []
    },
    {
      "row": 3,
      "sku": null,
      "name": null,
      "action": "error",
      "stock": "none",
      "messages": [
        "name is required"
      ]
    }
  ]
}

Restore a deleted item

POST/items/{id}/restore

Restore a soft-deleted item from the trash. Fails with 422 if a live item in the entity already uses the same SKU.

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.restoreItem('itm_6595a27b5d35015c3ef0c3fd', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

idstring
namestring
descriptionstringnullable
pricenumber

Per-unit net price (before tax). Always stores net price.

gross_pricenumbernullable

Per-unit gross price (includes tax). Only present if user originally sent gross price.

metadatastringnullable
Other parameters
tax_idsarray of strings
total_taxnumber
entity_idstring
deleted_atstring<date-time>nullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "id": "item_6595a27b5d35015c3ef0c3fd",
  "name": "Satellite Communication Module",
  "description": null,
  "translations": {},
  "price": 1500,
  "gross_price": null,
  "unit": null,
  "e_invoicing": null,
  "price_with_tax": 1500,
  "categories": [],
  "track_inventory": false,
  "sku": null,
  "usage": null,
  "barcode": null,
  "purchase_price": null,
  "total_tax": 0,
  "tax_ids": [],
  "entity_id": "ent_6595a27b5d35015c3ef0c3fd",
  "metadata": {},
  "deleted_at": null,
  "created_at": "2024-01-01T00:00:00.000Z",
  "updated_at": "2024-09-01T00:00:00.000Z"
}
Example:

Get item inventory

GET/items/{id}/inventory

Get item inventory

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.getItemInventory('itm_6595a27b5d35015c3ef0c3fd', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

item_idstring
track_inventoryboolean
json
{
  "item_id": "item_6595a27b5d35015c3ef0c3fd",
  "track_inventory": true,
  "quantity_on_hand": 6,
  "total_value": 30,
  "average_unit_cost": 5,
  "layers": [
    {
      "movement_id": "invm_6595a27b5d35015c3ef0c3fd",
      "occurred_at": "2024-06-01T09:00:00.000Z",
      "unit_cost": 5,
      "quantity_remaining": 6
    }
  ],
  "warehouses": [
    {
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
      "warehouse_name": "Main warehouse",
      "quantity_on_hand": 4,
      "total_value": 20
    },
    {
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fe",
      "warehouse_name": "Retail store",
      "quantity_on_hand": 2,
      "total_value": 10
    }
  ]
}

List item inventory movements

GET/items/{id}/inventory/movements

Retrieve a paginated list of an item's inventory movements. Results are ordered by occurred_at descending (most recent first, ties broken by id) and use cursor-based pagination. Optionally filter to a single warehouse (warehouse_id, matching source or destination) and/or a single originating document (document_id); both filters compose.

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

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.

warehouse_idstringoptional

Filter to movements where this warehouse is the source or destination.

document_idstringoptionalnullable

Filter to movements generated automatically by this document (e.g. the invoice or credit note whose finalization recorded them). Movements created manually through this endpoint have no document and never match.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.getItemInventoryMovements('itm_6595a27b5d35015c3ef0c3fd', undefined, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

dataarray of objects
paginationobject

Pagination metadata including cursors and result counts

json
{
  "data": [
    {
      "id": "invm_6595a27b5d35015c3ef0c3fe",
      "item_id": "item_6595a27b5d35015c3ef0c3fd",
      "type": "sale",
      "quantity": 4,
      "unit_cost": null,
      "cost_total": 20,
      "occurred_at": "2024-06-02T09:00:00.000Z",
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
      "destination_warehouse_id": null,
      "source_movement_id": null,
      "source_document_id": null,
      "document_id": "inv_6595a27b5d35015c3ef0c3fc",
      "document_type": "invoice",
      "note": null,
      "created_at": "2024-06-02T09:00:00.000Z",
      "updated_at": "2024-06-02T09:00:00.000Z"
    },
    {
      "id": "invm_6595a27b5d35015c3ef0c3fd",
      "item_id": "item_6595a27b5d35015c3ef0c3fd",
      "type": "purchase",
      "quantity": 10,
      "unit_cost": 5,
      "cost_total": 50,
      "occurred_at": "2024-06-01T09:00:00.000Z",
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
      "destination_warehouse_id": null,
      "source_movement_id": null,
      "source_document_id": null,
      "document_id": "exp_6595a27b5d35015c3ef0c400",
      "document_type": "expense",
      "note": null,
      "created_at": "2024-06-01T09:00:00.000Z",
      "updated_at": "2024-06-01T09:00:00.000Z"
    },
    {
      "id": "invm_6595a27b5d35015c3ef0c3fc",
      "item_id": "item_6595a27b5d35015c3ef0c3fd",
      "type": "purchase",
      "quantity": 4,
      "unit_cost": 4.5,
      "cost_total": 18,
      "occurred_at": "2024-05-28T09:00:00.000Z",
      "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
      "destination_warehouse_id": null,
      "source_movement_id": null,
      "source_document_id": null,
      "document_id": null,
      "document_type": null,
      "note": "Restocked from supplier invoice #4821",
      "created_at": "2024-05-28T09:00:00.000Z",
      "updated_at": "2024-05-28T09:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 3,
    "next_cursor": null,
    "prev_cursor": null,
    "has_more": false
  }
}

Create an inventory movement

POST/items/{id}/inventory/movements

Create an inventory movement

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

Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.

Body parameters

typestringrequired

Movement type for manually-recorded movements. purchase, sale and sale_return are recorded automatically by finalizing an expense, invoice, or credit note, respectively, and cannot be created through this endpoint. Use adjustment_in (with unit_cost) for opening stock, stock counts, or returns received without a credit note.

Possible values: "adjustment_in", "adjustment_out", "write_off", "transfer"

quantitynumberrequired

Movement quantity. Always positive; direction is determined by type.

Other parameters
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.items.createItemInventoryMovement('itm_6595a27b5d35015c3ef0c3fd', {
  type: "adjustment_in",
  quantity: 10,
  unit_cost: 5,
  note: "Opening stock count"
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);
Example:

Returns

idstring
Other parameters
item_idstring
quantitynumber
unit_costnumbernullable
occurred_atstring<date-time>
notestringnullable
created_atstring<date-time>
updated_atstring<date-time>
json
{
  "id": "invm_6595a27b5d35015c3ef0c3fd",
  "item_id": "item_6595a27b5d35015c3ef0c3fd",
  "type": "adjustment_in",
  "quantity": 10,
  "unit_cost": 5,
  "cost_total": 50,
  "occurred_at": "2024-06-01T09:00:00.000Z",
  "warehouse_id": "wh_6595a27b5d35015c3ef0c3fd",
  "destination_warehouse_id": null,
  "source_movement_id": null,
  "source_document_id": null,
  "document_id": null,
  "document_type": null,
  "note": "Opening stock count",
  "created_at": "2024-06-01T09:00:00.000Z",
  "updated_at": "2024-06-01T09:00:00.000Z"
}