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
}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
}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
}