Orders
Orders
Order management for e-commerce integrations.
Receive, store, and process orders from external platforms into invoices.
The Order object
Attributes
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "pending",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Create a new order
/ordersCreate a new order manually or from an external source.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Body parameters
Order source platform
Possible values: "shopify", "woocommerce", "magento", "custom", "manual"
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.orders.create({
order_integration_id: "oint_6595a27b5d35015c3ef0c3fd",
source: "manual",
source_id: "manual-001",
currency_code: "EUR",
total: 100,
total_with_tax: 122,
items: [
{
name: "Payload Adapter Kit",
quantity: 2,
price: 50,
gross_price: 61,
total: 100,
total_with_tax: 122,
tax_rate: 22
}
]
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "pending",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Start order packing-list PDF export
/orders/export/pdfStart a background job that prints order packing lists for the warehouse: one page per order with the ship-to address, payment and shipping method and an item list (SKU, name, quantity, no prices) with a tick box per line.
Select orders either with order_ids (1-500) or with date_from + date_to (maximum 1 year, matched on the order date in the entity time zone; deleted and cancelled orders are skipped). Send exactly one of the two; anything else is a 400.
output single_pdf (default) produces one PDF; zip produces a ZIP with one PDF per order.
A single_pdf export holds at most 500 orders and a zip export at most 2000; larger selections fail, so use zip or a shorter date range.
When using a user access token, you will receive an email with a download link when the export is ready. When using an API key, poll the job status endpoint for progress.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Body parameters
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.orders.startOrdersPdfExport({
order_ids: [
"ord_clx1234567890",
"ord_clx0987654321"
]
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Export job ID
{
"id": "expjob_clx1234567890",
"status": "pending",
"message": "Export started. You will receive an email when ready."
}List all orders
/ordersRetrieve a paginated list of orders with optional filtering and sorting.
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.
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.
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, status, source, source_id, customer_name, customer_email, payment_status, order_integration_id, ordered_at, 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
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.
When true, returns only soft-deleted (trashed) items. Default false excludes deleted items.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.orders.list({
limit: 20,
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Pagination metadata including cursors and result counts
{
"data": [
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "pending",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}
],
"pagination": {
"total": 1,
"next_cursor": null,
"prev_cursor": null,
"has_more": false
}
}Get order by ID
/orders/{id}Retrieve a single order by its unique identifier.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
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.orders.get('ORDERS_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "pending",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Get order packing-list PDF export job status
/orders/export/pdf/{jobId}Check the status and progress of an order packing-list PDF export job.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Export job ID
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.orders.getOrdersPdfExportJob("expjob_clx1234567890", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Export job ID
{
"id": "expjob_clx1234567890",
"status": "processing",
"progress": 12,
"total_docs": 40,
"file_url": null,
"file_name": "orders-2026-01-01_2026-01-31.pdf",
"error": null,
"result": null
}Update an order
/orders/{id}Update an existing order. Only the provided fields will be updated.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Unique resource identifier. Prefix depends on the resource, for example inv_, cus_, or ent_.
Body parameters
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.orders.update('ORDERS_ID', {
customer_name: "Updated Customer Name",
customer_email: "updated@example.com"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "pending",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Delete an order
/orders/{id}Soft delete an order by its unique identifier.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
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.orders.delete('ORDERS_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log('Deleted successfully');Process or retry an order
/orders/{id}/processProcess a pending order or resume failed processing. For refunded orders, retry only reconciliation of the existing document; uncertain outcomes after the document was voided remain blocked for manual reconciliation.
Polish B2B issuance returns 422 KSEF_AUTH_FAILED when KSeF rejects the entity's KSeF token; no number is used.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
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.orders.processOrder('ORDERS_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "invoiced",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": "inv_7595a27b5d35015c3ef0c3fe",
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": "2024-01-15T12:00:00.000Z",
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Cancel an order
/orders/{id}/cancelCancel a pending order. Already invoiced orders cannot be cancelled.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
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.orders.cancelOrder('ORDERS_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "cancelled",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": true,
"cancelled_at": "2024-01-15T12:00:00.000Z",
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": null,
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": null,
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Reissue an order invoice
/orders/{id}/reissueCredit the existing invoice and create a new one with current order items. Only available when order items have changed after initial processing.
Polish B2B issuance returns 422 KSEF_AUTH_FAILED when KSeF rejects the entity's KSeF token; no number is used.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
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.orders.reissueOrder('ORDERS_ID', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "ord_6595a27b5d35015c3ef0c3fd",
"entity_id": "ent_6595a27b5d35015c3ef0c3fd",
"order_integration_id": "oint_6595a27b5d35015c3ef0c3fd",
"source": "manual",
"source_id": "manual-001",
"source_order_number": null,
"status": "invoiced",
"paid": false,
"paid_at": null,
"fulfilled": false,
"fulfilled_at": null,
"cancelled": false,
"cancelled_at": null,
"refunded": false,
"refunded_at": null,
"customer_name": null,
"customer_email": null,
"customer": null,
"billing_address": null,
"shipping_address": null,
"customer_id": null,
"currency_code": "EUR",
"total": 100,
"total_with_tax": 122,
"total_discount": 0,
"total_shipping": 0,
"items": [
{
"name": "Payload Adapter Kit",
"quantity": 2,
"price": 50,
"gross_price": 61,
"total": 100,
"total_with_tax": 122,
"tax_rate": 22
}
],
"payment_status": "unpaid",
"payment_method": null,
"payment_gateway": null,
"invoice_id": "inv_8595a27b5d35015c3ef0c3ff",
"estimate_id": null,
"process_after": null,
"transactions": [],
"complete": false,
"items_changed_after_processing": false,
"raw_data": null,
"source_event_id": null,
"error": null,
"ordered_at": null,
"processed_at": "2024-01-16T12:00:00.000Z",
"metadata": {},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-09-01T00:00:00.000Z",
"deleted_at": null
}Download completed order packing-list PDF export
/orders/export/pdf/{jobId}/downloadDownload a completed order packing-list export through the authenticated API. Returns a PDF for single_pdf exports and a ZIP archive for zip exports. When the export file is kept in object storage instead of on the API server, responds with a 302 redirect to the storage URL (the same URL the job status endpoint reports as file_url). Returns 404 when the job is not completed or its file is no longer available.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Export job ID
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const blob = await sdk.orders.downloadOrdersPdfExport("expjob_clx1234567890", {
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');