Credit Notes
Credit Notes
Credit note management operations.
Create, retrieve, and list credit notes with flexible querying.
Credit notes are issued by Entities to Customers and contain line items with optional taxes.
Unlike invoices, credit notes do not have a due date.
The Credit Note object
Attributes
Date the credit note was created (ISO 8601 datetime at midnight UTC)
Document issuer (entity) information
Customer information snapshot stored on the document. Null means no customer. When present, known customer fields are returned with null for omitted values.
Note for the document. If not provided, defaults to entity's document-type-specific note setting. Pass empty string to explicitly set no note.
Document total before tax in the currency's major unit. For EUR, 29.90 means €29.90, not 2,990 cents.
Document total after tax in the currency's major unit. For EUR, 29.90 means €29.90, not 2,990 cents.
Applied taxes summary
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.
{
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}Create a new credit note
/credit-notesCreate a new credit note with line items.
This is the recommended endpoint for normal credit note creation. Use it when Space Invoices should calculate line totals, taxes, discounts, document totals, numbering, fiscalization, customer handling, payments, and lifecycle hooks from the supplied business inputs.
Send credit-note line quantities and prices as positive values. Space Invoices stores credit notes as positive amounts and applies the credit-note sign in display, reporting, and fiscalization where required.
Customer is optional - can be omitted for retail/convenience store sales where customer information isn't needed, or added inline without referencing a customer_id.
The credit note number is auto-generated based on the entity's number format settings.
Taxes are calculated automatically based on the tax rates provided.
For a Hungarian entity with NAV dispatch enabled, creating a non-draft credit note maps it to a NAV Online Számla submission; data that cannot be mapped responds 422 NAV_INVOICE_DATA_INVALID with an issues array.
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.
Query parameters
Comma-separated list of relations to include in the response.
Available relations:
- document_relations - Linked documents with their related document summaries
Usage:?include=document_relations
Body parameters
Line items for the credit note. At least one item is required.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.create({
items: [
{
name: "Thermal Shielding Panel - Defective return",
quantity: 1,
price: 850
}
]
}, undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}Create credit note with pre-calculated totals
/credit-notes/customUnavailable for Spanish entities, including drafts; use the standard document routes. Spanish fiscalization input is not accepted. Advanced endpoint for importing credit notes that already have authoritative pre-calculated totals. Do not use this for normal credit note creation. Prefer the standard create endpoint unless your integration must preserve exact external totals from an ERP, OCR, migration, or accounting system.
The caller provides total, total_with_tax, total_discount, and taxes at the document level, and total/total_with_tax on each line item.
When calculation_mode is omitted, Space Invoices preserves pass-through behavior and accepts the supplied totals as-is.
When calculation_mode is provided, Space Invoices validates the supplied totals against that calculation mode before creating the document.
Portugal: ordinary custom creation is unavailable (422). Dedicated manual recovery requires pt.manual: true, an active manual series, and the original paper-document reference; the manual flag alone is insufficient. This does not enable importing invoices issued by another invoicing system.
All other logic (numbering, fiscalization, customer handling, payments, lifecycle hooks) is identical to the standard create endpoint.
For a Hungarian entity with NAV dispatch enabled, creating a non-draft credit note maps it to a NAV Online Számla submission; data that cannot be mapped responds 422 NAV_INVOICE_DATA_INVALID with an issues array.
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.
Query parameters
Comma-separated list of relations to include in the response.
Available relations:
- document_relations - Linked documents with their related document summaries
Usage:?include=document_relations
Body parameters
Line items with pre-calculated totals. At least one item is required.
Pre-calculated document total (before tax).
Pre-calculated document total (after tax).
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.createCustom({
total: 850,
total_with_tax: 1037,
taxes: [
{
rate: 22,
base: 850,
amount: 187
}
],
items: [
{
name: "Thermal Shielding Panel - Defective return",
quantity: 1,
price: 850,
total: 850,
total_with_tax: 1037,
taxes: [
{
rate: 22
}
]
}
]
}, undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}List all credit notes
/credit-notesRetrieve a paginated list of credit notes with optional filtering and sorting.
Supports cursor-based pagination, flexible JSON querying with MongoDB-style operators, full-text search, 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, number, customer_id, date, customer, customer.name, customer.email, customer.address, customer.city, customer.country, total, total_with_tax, items.name, items.description, payments.type, payments.date, document_relations.relation_type, document_relations.target_type, metadata, created_at, updated_at, paid_in_full, voided_at, total_paid
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.
Comma-separated list of relations to include in the response.
Available relations:
- payments - Payment records linked to this credit note
- document_relations - Linked documents (invoices, advance invoices, etc.)
Usage:?include=payments?include=payments,document_relations
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.creditNotes.list({
limit: 20,
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Pagination metadata including cursors and result counts
{
"data": [
{
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"pagination": {
"total": 1,
"next_cursor": null,
"prev_cursor": null,
"has_more": false
}
}Get credit note by ID
/credit-notes/{id}Retrieve a single credit note by its unique identifier. Returns the complete credit note details including all line items, customer information, and calculated totals.
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_.
Query parameters
Comma-separated list of relations to include in the response.
Available relations:
- payments - Payment records linked to this credit note
- document_relations - Linked documents (invoices, advance invoices, etc.)
Usage:?include=payments?include=payments,document_relations
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.get('cre_6595a27b5d35015c3ef0c3fd', undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}Update a credit note
/credit-notes/{id}Update an existing credit note.
Creates a version snapshot before applying changes.
Cannot update voided or FURS-fiscalized credit notes. Italian invoices and credit notes are immutable once issued, including pending or rejected SdI submissions; use the supported correction flow. Draft item edits use rate-level VAT rounding, and edits or finalization based on a concurrently changed Italian draft fail with 422 until reloaded.
If items are provided, they replace all existing items.
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.creditNotes.update('cre_6595a27b5d35015c3ef0c3fd', {
note: "Refund processed. Equipment returned to inventory.",
change_reason: "Added confirmation note after refund"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cre_jkl012",
"number": "CN-2025-0004",
"date": "2025-01-15T00:00:00.000Z",
"date_service": "2025-01-01",
"date_service_to": "2025-01-15",
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": {
"name": "Horizon Launch Systems Inc.",
"address": "100 Rocket Row",
"city": "Houston",
"state": "TX",
"post_code": "77058",
"country": "USA",
"tax_number": "74-1234567"
},
"note": "Credit note for defective thermal panels and returned EVA toolkit.",
"total": 3900,
"total_with_tax": 4758,
"taxes": [
{
"rate": 22,
"total": 858
}
],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 4758,
"paid_in_full": false,
"payment_terms": null,
"items": [
{
"id": "item_jkl012_1",
"name": "Thermal Shielding Panel - Manufacturing defect",
"description": "Panels failed thermal cycling test at 1400C",
"quantity": 2,
"price": 850,
"gross_price": null,
"total": 1700,
"total_with_tax": 2074,
"taxes": [
{
"rate": 22,
"tax_id": "tax_abc123"
}
],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_jkl012",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
},
{
"id": "item_jkl012_2",
"name": "EVA Toolkit - Standard return",
"description": null,
"quantity": 1,
"price": 2200,
"gross_price": null,
"total": 2200,
"total_with_tax": 2684,
"taxes": [
{
"rate": 22,
"tax_id": "tax_abc123"
}
],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_jkl012",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}Void a credit note
/credit-notes/{id}/voidVoid a credit note for technical reasons (duplicate, error, etc.). For FURS-fiscalized credit notes, automatically submits technical cancellation to FURS. All linked payments are soft-deleted, reversing their effect on invoice totals. Voiding a system-created void credit note atomically reactivates its source invoice and restores the invoice's released advance allocations; the operation fails without side effects if their original balances are 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
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.creditNotes.void('cre_6595a27b5d35015c3ef0c3fd', {
reason: "Duplicate credit note created by mistake"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cn_abc123",
"voided_at": "2026-01-20T12:00:00.000Z"
}Get credit note version history
/credit-notes/{id}/versionsRetrieve the version history for a credit note. Each version represents the document state before an update was applied.
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.creditNotes.getVersions('cre_6595a27b5d35015c3ef0c3fd', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"versions": [
{
"id": "ver_abc123",
"document_type": "credit_note",
"document_id": "cre_6595a27b5d35015c3ef0c3fd",
"version": 2,
"snapshot": {
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"furs": null,
"fina": null,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
},
"changed_fields": [
"note"
],
"user": {
"id": "usr_123",
"name": "Alex Carter",
"email": "alex.carter@starward.example"
},
"reason": "Added confirmation note after refund",
"created_at": "2025-01-15T10:30:00.000Z"
},
{
"id": "ver_xyz789",
"document_type": "credit_note",
"document_id": "cre_6595a27b5d35015c3ef0c3fd",
"version": 1,
"snapshot": {
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"furs": null,
"fina": null,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
},
"changed_fields": [
"items"
],
"user": {
"id": "usr_123",
"name": "Alex Carter",
"email": "alex.carter@starward.example"
},
"reason": "Corrected refund amounts",
"created_at": "2025-01-14T15:00:00.000Z"
}
],
"count": 2
}Get specific credit note version
/credit-notes/{id}/versions/{version}Retrieve a specific version snapshot of a credit note.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Credit Note ID
Version number
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.getVersion('cre_6595a27b5d35015c3ef0c3fd', 1, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Version record ID
{
"id": "ver_abc123",
"document_type": "credit_note",
"document_id": "cre_6595a27b5d35015c3ef0c3fd",
"version": 1,
"snapshot": {
"id": "cre_abc123",
"number": "CN-2025-0001",
"date": "2025-01-15T00:00:00.000Z",
"date_service": null,
"date_service_to": null,
"issuer": {
"name": "Starward Equipment Co.",
"address": "1 Launchpad Way",
"city": "Cape Canaveral",
"country": "United States"
},
"customer_id": null,
"customer": null,
"note": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"currency_code": "USD",
"entity_id": "ent_abc123",
"date_year": 2025,
"shareable_id": null,
"voided_at": null,
"deleted_at": null,
"metadata": {},
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"total_paid": 0,
"total_due": 850,
"paid_in_full": false,
"furs": null,
"fina": null,
"payment_terms": null,
"items": [
{
"id": "item_abc123",
"name": "Thermal Shielding Panel - Defective return",
"description": null,
"quantity": 1,
"price": 850,
"gross_price": null,
"total": 850,
"total_with_tax": 850,
"taxes": [],
"discounts": [],
"type": null,
"unit": null,
"credit_note_id": "cre_abc123",
"total_converted": null,
"total_with_tax_converted": null,
"metadata": {},
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
}
],
"created_at": "2025-01-15T00:00:00.000Z",
"updated_at": "2025-01-15T00:00:00.000Z"
},
"changed_fields": [
"items"
],
"user": {
"id": "usr_123",
"name": "Alex Carter",
"email": "alex.carter@starward.example"
},
"reason": "Corrected refund amounts",
"created_at": "2025-01-14T15:00:00.000Z"
}Preview next document number
/documents/next-numberPreview the next auto-generated document number for the specified type without incrementing the sequence. Useful for showing users what number will be assigned before creating a document.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Query parameters
Document type
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
Optional business unit scope for unit-specific numbering sequences.
Business premise name (FURS or FINA). If provided with electronic_device_name, returns fiscalization-format number.
Electronic device name (FURS or FINA). Required if business_premise_name is provided. When provided, returns fiscalization-format number.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.documents.getNextNumber({
type: "invoice"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"number": "2026-00042"
}Render credit note preview
/credit-notes/renderRender an HTML preview of a credit note without saving to the database. Perfect for displaying live previews in credit note creation/edit forms. Supports both partial mode (allows incomplete data for drafts) and complete mode (validates all required fields).
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Query parameters
Document template design to use. When not specified, uses the entity's configured template.
Possible values: "modern", "classic", "condensed", "minimal", "fashion"
Locale for number and date formatting (decimal separators, date order). When not specified, uses the entity's configured locale. For example, 'sl-SI' formats decimals with commas (5,5%) and dates as DD. MM. YYYY.
Language for document labels and translations (e.g., 'Invoice', 'Tax', 'Total'). When not specified, uses the same value as locale. Use this to get entity-locale formatting with different-language labels — for example, a Slovenian entity (sl-SI formatting with commas) but English labels.
Whether to treat the document as partial (allows incomplete data) or complete (validates all required fields)
Possible values: "true", "false"
Default: "true"
Override UPN QR enabled setting for preview
Possible values: "true", "false"
Override UPN QR display mode for preview
Possible values: "qr_only", "full_slip"
Override EPC QR enabled setting for preview
Possible values: "true", "false"
Override Croatian HUB3 PDF417 barcode enabled setting for preview
Possible values: "true", "false"
Override HUB3 purpose code for preview
Override HUB3 Croatian reference model for preview
Override Swiss QR-bill enabled setting for preview
Possible values: "true", "false"
Body parameters
Preview only: id of the stored document being edited. The preview shows that document's stored number (and reuses its issued snapshot where supported). Omit when creating.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.renderCreditNotePreview({
items: [
{
name: "Refund - Mission Planning Services",
quantity: 1,
price: 150
}
],
customer: {
name: "Nebula Propulsion Labs"
}
}, undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Preview document calculation
/documents/calculateCalculate document totals, taxes, and transaction type without creating the document. Useful for showing live totals in forms or validating data before submission.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Query parameters
Document type
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
Body parameters
Document line items to calculate. At least one item is required.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.documents.calculateDocumentPreview({
items: [
{
name: "Mission Planning Services",
quantity: 10,
price: 100,
taxes: [
{
rate: 22
}
]
}
]
}, {
type: "invoice"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"items": [
{
"name": "Mission Planning Services",
"description": null,
"type": null,
"price": 100,
"gross_price": null,
"quantity": 10,
"unit": null,
"taxes": [
{
"name": "VAT",
"rate": 22,
"base": 1000,
"amount": 220
}
],
"discounts": [],
"total": 1000,
"total_with_tax": 1220,
"total_converted": null,
"total_with_tax_converted": null
}
],
"total": 1000,
"total_with_tax": 1220,
"total_discount": 0,
"taxes": [
{
"name": "VAT",
"rate": 22,
"base": 1000,
"amount": 220,
"reverse_charge": false
}
],
"transaction_type": "domestic",
"currency_code": "EUR",
"exchange_rate": null,
"total_converted": null,
"total_with_tax_converted": null,
"rounding_correction": null
}Render HTML
/documents/{id}/htmlRender a saved document by its ID as HTML. The document type is automatically detected from the ID prefix (inv_, est_, cre_, adv_). The output is styled for professional presentation and optimized for display in web applications.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document identifier. Prefix depends on the document type: inv_, est_, crn_, adv_, dln_ or po_ (purchase order).
Query parameters
Document template design to use. When not specified, uses the entity's configured template.
Possible values: "modern", "classic", "condensed", "minimal", "fashion"
Locale for number and date formatting (decimal separators, date order). When not specified, uses the entity's configured locale. For example, 'sl-SI' formats decimals with commas (5,5%) and dates as DD. MM. YYYY.
Language for document labels and translations (e.g., 'Invoice', 'Tax', 'Total'). When not specified, uses the same value as locale. Use this to get entity-locale formatting with different-language labels — for example, a Slovenian entity (sl-SI formatting with commas) but English labels.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.invoices.renderHtml('cre_6595a27b5d35015c3ef0c3fd', undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Render PDF
/documents/{id}/pdfRender a saved document by its ID as PDF. The document type is automatically detected from the ID prefix (inv_, est_, cre_, adv_). The output is styled for professional presentation and optimized for printing. Ideal for downloads and archival.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document identifier. Prefix depends on the document type: inv_, est_, crn_, adv_, dln_ or po_ (purchase order).
Query parameters
Document template design to use. When not specified, uses the entity's configured template.
Possible values: "modern", "classic", "condensed", "minimal", "fashion"
Locale for number and date formatting (decimal separators, date order). When not specified, uses the entity's configured locale. For example, 'sl-SI' formats decimals with commas (5,5%) and dates as DD. MM. YYYY.
Language for document labels and translations (e.g., 'Invoice', 'Tax', 'Total'). When not specified, uses the same value as locale. Use this to get entity-locale formatting with different-language labels — for example, a Slovenian entity (sl-SI formatting with commas) but English labels.
Finalize a draft document
/documents/{id}/finalizeFinalize a draft document by assigning a document number, running fiscalization (if applicable), and optionally sending it electronically. Only draft documents can be finalized. Draft advance invoices must first have payments covering their full total. After finalization, the document cannot be deleted. For a Hungarian invoice, credit note or advance invoice whose entity has NAV dispatch enabled, finalizing maps it to a NAV Online Számla submission; data that cannot be mapped responds 422 NAV_INVOICE_DATA_INVALID with an issues array.
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
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
Body parameters
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.documents.finalizeDocument("inv_clx1234567890", {
e_invoicing: {
send_enabled: true
}
}, undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);nullDelete a draft document
/documents/{id}Delete a draft document. Only draft documents can be deleted. Finalized documents cannot be deleted - use void instead.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
await sdk.documents.delete("inv_clx1234567890", undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log('Deleted successfully');Permanently delete a document
/documents/{id}/permanentPermanently delete a soft-deleted document. Only documents in the trash can be permanently deleted. Only draft documents and estimates can be permanently deleted.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
await sdk.documents.permanentDeleteDocument("inv_clx1234567890", undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log('Deleted successfully');Return an unaccepted KSeF document to draft
/credit-notes/{id}/ksef/recoverNo request body. Archives the previous attempt and returns the document to draft only after definitive authority rejection, no dispatch, or verified empty cancelled session. Accepted, duplicate and unresolved ambiguous submissions remain immutable. Repeated completed recovery is idempotent. Returns 422 KSEF_AUTH_FAILED if KSeF rejects the entity's token.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.recoverCreditNoteFromKsef("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"submission_id": "submission-id",
"status": "reserved",
"revision": 0,
"error_code": "error-code",
"error_message": "error-message",
"ksef_number": "ksef-number",
"invoice_hash": "invoice-hash",
"upo_available": true,
"recovery_available": true
}Get KSeF submission status
/credit-notes/{id}/ksefRead persisted KSeF lifecycle state and reconcile pending authority results. Polling is rate limited. This does not resend invoices. When KSeF rejects the entity's token or is unavailable, this read returns the stored state (error_code KSEF_AUTH_FAILED for a rejected token) instead of failing.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.getCreditNoteKsefState("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"submission_id": "submission-id",
"status": "reserved",
"revision": 0,
"error_code": "error-code",
"error_message": "error-message",
"ksef_number": "ksef-number",
"invoice_hash": "invoice-hash",
"upo_available": true,
"recovery_available": true
}Submit or resume a KSeF invoice
/credit-notes/{id}/ksef/submitSubmit an issued Polish B2B invoice or credit note within the supported KSeF scope: standard online documents from active-VAT sellers, or domestic documents from VAT-exempt sellers whose invoice tax clause states the exemption's legal basis. See the Poland compliance guide for currency and scope rules. Advances, offline24 and domestic totals above PLN 15,000 are outside this route. KSeF is required unless an explicit exemption reason is configured; disabling KSeF does not bypass that obligation. Uses the existing reservation on repeat calls. Ambiguous dispatches reconcile without resending; rejected invoices are terminal. Returns 422 with code KSEF_AUTH_FAILED when KSeF rejects the entity's KSeF token; the submission stays queued with error_code KSEF_AUTH_FAILED and resumes automatically once the token is replaced. No request body.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.creditNotes.submitCreditNoteToKsef("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"submission_id": "submission-id",
"status": "reserved",
"revision": 0,
"error_code": "error-code",
"error_message": "error-message",
"ksef_number": "ksef-number",
"invoice_hash": "invoice-hash",
"upo_available": true,
"recovery_available": true
}Download verified KSeF UPO
/credit-notes/{id}/ksef/upoDownload the authority receipt after verified acceptance. Returns 409 while the receipt is pending.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const blob = await sdk.creditNotes.getCreditNoteKsefUpo("inv_6595a27b5d35015c3ef0c3fd", {
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');Download credit note as XRechnung XML
/credit-notes/{id}/xrechnungDownload a finalized German credit note as XRechnung XML. Requires a German entity with XRechnung enabled. The stored validation result is used when it is still current for the document; otherwise the current document is re-validated at export time.
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.creditNotes.downloadCreditNoteXRechnung('cre_6595a27b5d35015c3ef0c3fd', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Download credit note as ZUGFeRD PDF
/credit-notes/{id}/zugferdDownload a finalized German credit note as a ZUGFeRD/Factur-X PDF with embedded CII XML. Requires a German entity with ZUGFeRD enabled. The stored validation result is used when it is still current for the document; otherwise the current document is re-validated at export time.
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 blob = await sdk.creditNotes.downloadCreditNoteZugferd('cre_6595a27b5d35015c3ef0c3fd', {
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');Fiscalize an old credit note (deprecated)
/credit-notes/{id}/fiscalizeDeprecated. Use POST /documents/{id}/fiscalize instead. Manually fiscalize a credit note that was created before FURS was enabled. Creates or reuses a dedicated "OLD" device under an existing active FURS premise, assigns a new sequential FURS number (Premise-OLD-N), and submits to FURS with SubsequentSubmit=true and SpecialNotes=#OLDINV;. The original credit note number remains unchanged.
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.creditNotes.fiscalizeCreditNote('cre_6595a27b5d35015c3ef0c3fd', {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"id": "cre_abc123",
"furs": {
"country_code": "SI",
"status": "success",
"fiscalized_at": "2026-01-20T12:00:00.000Z",
"data": {
"zoi": "a1b2c3d4e5f6...",
"eor": "EOR-12345",
"business_premise_name": "P1",
"electronic_device_name": "OLD",
"invoice_number": "1"
}
}
}Fiscalize a document or retry fiscalization
/documents/{id}/fiscalizeManually fiscalize a document. Retries failed FURS/FINA fiscalization, submits Slovenian FURS documents that were intentionally skipped and now need late fiscalization, or uses the old-FURS flow for no-status pre-FURS documents. For first FURS submission, payment_amount overrides only PaymentAmount; invoice totals and taxes are unchanged. On retries with stored payloads, repeat the same amount or omit it; a different resolved FURS amount is rejected.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
Body parameters
nullRegister fiscalized document output
/documents/{id}/register-outputAtomically reserve the next output number for a successfully FURS- or FINA-fiscalized document. The first output is the unmarked original; output two and later are rendered with their number. Preview operations must not call this endpoint.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.documents.registerDocumentOutput("inv_clx1234567890", undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"print_count": 2,
"fiscalization_provider": "furs"
}Restore a deleted document
/documents/{id}/restoreRestore a soft-deleted document from the trash. The document will be returned to its original state.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Path parameters
Document ID
Query parameters
Document type. Optional — automatically inferred from the document ID prefix.
Possible values: "invoice", "estimate", "credit_note", "advance_invoice", "delivery_note", "purchase_order"
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.documents.restoreDocument("inv_clx1234567890", undefined, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);null