Skip to main content

REST API: Purchase and sales sync

How to get changes to purchase invoices, purchase delivery notes and sales invoices to keep a synchronised copy.

Keep a synchronised copy of purchase invoices, purchase delivery notes and sales invoices. Each call returns what has been created, updated and deleted since the previous one.

GET /integration/purchases/invoices/changes
GET /integration/purchases/deliveries/changes
GET /integration/sales/invoices/changes

If you need to fetch new documents and mark them as processed, use Retrieving data for billing systems instead.


Before you start

Base URL: https://app.tspoonlab.com/recipes/api

Headers

  • rememberme · required — Session token returned by the login.

  • order · optional — Cost center id (Cost centers). Defaults to the user's active cost center.

Login — Returns the token as plain text.

curl https://app.tspoonlab.com/recipes/api/login \
-d [email protected] \
-d password=XXXXXXX

Permissions — The purchase endpoints require permission to view purchase orders; the sales endpoint, permission to view sales.

Dates — Returned as milliseconds since 1970 (epoch).

Responses may include fields other than the documented ones. Use only the documented fields.


How sync works

  1. First call without cursor: returns every document in inserts. To start from a given day, send changedSince.

  2. While hasMore is true, call again with the cursor you received.

  3. Store the last cursor. On the next sync, call with it: you will only receive what has changed.

Store a separate cursor for each endpoint.

Common parameters

  • cursor string · optional — Cursor from the previous call. When sent, changedSince and $filter are ignored.

  • changedSince date · optional — Changes since this day, as YYYY-MM-DD. Cannot be later than today.

  • $filter string · optional — Filter on each endpoint's fields (see Filter). It is stored in the cursor: send it only on the first call.

  • rows integer · optional — Changes per page, from 1 to 100. Defaults to 100.

  • includeInternal boolean · optional — false excludes internal vendors or customers. Defaults to true.

includeInternal, onlyValidated, idVendor and idCustomer are not stored in the cursor: send them with the same value on every call.

Response

{
"inserts": [ … ],
"updates": [ … ],
"deletes": [
{ "id": "3515834441676562996102020009", "deletedAt": 1767268800000 }
],
"cursor": "MjAyNi0wMS0wMSAxMjowMDowMC4wfDM1MTU4MzQ0NDE2NzY1NjI5OTYxMDIwMjAwMDk",
"hasMore": false
}
  • inserts array — Documents created since the cursor. On the first load, all of them.

  • updates array — Documents created before and updated after. Each document appears once, in its current state.

  • deletes array — Deleted documents: id string and deletedAt date.

  • cursor string — For the next call. null if the first load returns nothing.

  • hasMore boolean — true if more changes are available.

Good to know

  • Changes from the last 5 minutes arrive on the next call.

  • deletes is not filtered: ignore any id you don't have.

  • A document that stops matching the filter does not appear in deletes.

  • The same id can appear in both updates and deletes on one page: apply the most recent one by comparing updatedAt and deletedAt.

  • Changes to vendor or customer data (name, tax id, accounts…) do not mark their documents as updated.

Filter

OData syntax: eq, ne, gt, ge, lt, le, in, and, or, not (…), parentheses, year(), month() and contains().

  • Dates: YYYY-MM-DD without quotes. All operators allowed.

  • Ids: number without quotes. Only eq, ne and in.

  • Text: in single quotes. Only eq, ne, in and contains(). Case- and accent-sensitive.

curl -G https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/changes \
-H "rememberme: $TOKEN" \
--data-urlencode '$filter=year(date) eq 2026 and idVendor in (3515834441676562996102020004, 3515834441676562996102020005)'

Errors — An invalid cursor, changedSince or $filter, or rows out of range, returns 400 with code, message and params.


Purchase invoices

GET /integration/purchases/invoices/changes

Query parameters — The common ones, plus:

  • onlyValidated boolean · optional — true returns only validated invoices. Defaults to false.

  • idVendor string · optional — Only invoices from this vendor.

$filter fields: date, dateAccounting (date), idVendor (id), invoiceNum, documentNum (text).

Example

curl "https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/changes?changedSince=2026-01-01" \
-H "rememberme: $TOKEN"

Response — Each invoice in inserts and updates:

{
"id": "3515834441676562996102020001",
"invoiceNum": "F-2026-0042",
"documentNum": "000123",
"date": 1767225600000,
"dateAccounting": null,
"dateDue": 1769904000000,
"createdAt": 1767268800000,
"updatedAt": 1767268800000,
"idVendor": "3515834441676562996102020004",
"vendor": "García Distribution",
"codeVendor": "P001",
"accountVendor": "40000001",
"nif": "B12345678",
"inEuropeanUnion": false,
"inVies": false,
"country": "ES",
"paid": false,
"validated": true,
"locked": false,
"comment": null,
"codePaymentType": "TRANSF",
"base": 100.0,
"taxes": 10.0,
"total": 110.0,
"listTaxes": [
{ "id": "3515834441676562996102020006", "type": 0, "base": 100.0, "percent": 10.0, "total": 10.0 }
],
"listCostTypeTaxes": [ … ],
"listDeliveries": [ … ]
}
  • id string — Invoice id.

  • invoiceNum string — Vendor's invoice number.

  • documentNum string — Internal document number.

  • date, dateAccounting, dateDue date — Invoice date, accounting date (if null, use date) and due date.

  • createdAt, updatedAt date — Created and last updated.

  • idVendor, vendor, codeVendor, accountVendor, nif string — Vendor: id, name, code, ledger account and tax id.

  • inEuropeanUnion, inVies boolean — Intra-EU vendor and registered in VIES.

  • country string — Vendor's country.

  • paid, validated, locked boolean — Paid, validated and locked.

  • comment string — Comment.

  • codePaymentType string — Payment method code.

  • idCostTypeVendor, costTypeVendor, codeCostTypeVendor, accountCostTypeVendor, accountAuxCostTypeVendor string — Vendor's default cost account: id, name, code, ledger account and auxiliary account.

  • idBusinessLine, businessLine, codeBusinessLine string — Business line.

  • idDocument, extDocument string — Attached document: id and extension.

  • base, taxes, total number — Tax base, taxes and total. total includes withholding.

  • listTaxes array — Taxes: id, type, base, percent and total. type: 0 VAT · 1 shipping · 2 discount · 3 other · 4 withholding.

  • listCostTypeTaxes array — VAT by cost account, calculated from received lines: account id and descr (null if the lines have none) and listTaxes (type, base, percent, total).

  • listDeliveries array — The invoice's delivery notes, with the fields in Purchase delivery notes (without createdAt or updatedAt).


Purchase delivery notes

Received delivery notes only.

GET /integration/purchases/deliveries/changes

Query parameters — The common ones, plus:

  • idVendor string · optional — Only delivery notes from this vendor.

$filter fields: date, dateSent (date), idVendor (id), deliveryNum, deliveryFor (text).

Example

curl "https://app.tspoonlab.com/recipes/api/integration/purchases/deliveries/changes?changedSince=2026-01-01" \
-H "rememberme: $TOKEN"

Response — Each delivery note in inserts and updates:

{
"id": "3515834441676562996102020002",
"deliveryNum": "A-7781",
"deliveryFor": "PO-0153",
"date": 1767225600000,
"dateFormatted": "2026/01/01",
"dateSent": 1767139200000,
"dateSentFormatted": "2025/12/31",
"createdAt": 1767268800000,
"updatedAt": 1767268800000,
"idVendor": "3515834441676562996102020004",
"vendor": "García Distribution",
"locked": false,
"baseCalculated": 100.0,
"base": 100.0,
"taxes": 10.0,
"total": 110.0,
"listTaxes": [ … ],
"listDeliveries": [
{
"id": "3515834441676562996102020007",
"position": 0,
"idComponent": "3515834441676562996102020008",
"component": "Plum tomato",
"quantity": 20.0,
"unit": "kg",
"cost": 5.0,
"hasFormat": true,
"quantityFormat": 4.0,
"unitFormat": "5 kg box",
"costFormat": 25.0,
"iva": 10.0
}
],
"listSent": [ … ]
}
  • id string — Delivery note id.

  • deliveryNum string — Delivery note number.

  • deliveryFor string — Delivery note reference, usually the order number.

  • date date — Received date; if none, the sent date. dateFormatted string — The same, as YYYY/MM/DD.

  • dateSent date — Order sent date. dateSentFormatted string — The same, as YYYY/MM/DD.

  • createdAt, updatedAt date — Created and last updated.

  • idVendor, vendor, codeVendor, accountVendor, nif string — Vendor: id, name, code, ledger account and tax id.

  • vendorType, vendorTypeCode string, vendorTypeInternal boolean — Vendor type: name, code and whether it is internal.

  • locked boolean — Locked.

  • sentBy, receivedBy string — Who placed the order and who received it.

  • idCostType, costType, codeCostType, accountCostType, accountAuxCostType string — Delivery note's cost account. When assigned per line, it is on each line.

  • idBusinessLine, businessLine, codeBusinessLine string — Business line.

  • baseCalculated number — Base calculated from received lines, with 5 decimals.

  • base, taxes, total number — Base, taxes (including shipping, discounts and other) and total.

  • listTaxes array — Taxes: id, type, base, percent and total. type: 0 VAT · 1 shipping · 2 discount · 3 other.

  • listDeliveries array — Received lines.

  • listSent array — Lines of the order as sent.

Each received line (listDeliveries):

  • id string — Line id. position integer — Order.

  • idComponent, component, codeComponent string — Product: id, name and code.

  • codeVendorComponent string — Vendor's product code.

  • comment string — Comment.

  • quantity number, idUnit, unit string — Quantity in the product's base unit.

  • cost number — Cost per base unit. Line amount: quantity × cost.

  • hasFormat boolean — Whether it was bought in a format (e.g. boxes).

  • quantityFormat number, idUnitFormat, unitFormat string, costFormat number — Format: quantity, unit and price per format. null if hasFormat is false.

  • idStore, store string — Store.

  • iva number — VAT %.

  • idCostType, costType, codeCostType, accountCostType, accountAuxCostType string — Line's cost account.

  • idBusinessLine, businessLine, codeBusinessLine string — Line's business line.

  • listTypes array — Product families: id and descr.

  • recibido boolean — Always true.

Each line of the order as sent (listSent): the same product, comment and format fields as a received line, with quantity, idUnit and unit in the purchase unit and cost as the purchase price.


Sales invoices

GET /integration/sales/invoices/changes

Query parameters — The common ones, plus:

  • idCustomer string · optional — Only invoices for this customer.

$filter fields: date, dateAccounting, dateDue (date), idCustomer (id), invoiceNum, documentNum (text).

Example

curl "https://app.tspoonlab.com/recipes/api/integration/sales/invoices/changes?changedSince=2026-01-01" \
-H "rememberme: $TOKEN"

Response — Each invoice in inserts and updates:

{
"id": "3515834441676562996102020003",
"invoiceNum": "V-2026-0010",
"documentNum": "000045",
"date": 1767225600000,
"dateAccounting": null,
"dateDue": 1769904000000,
"createdAt": 1767268800000,
"updatedAt": 1767268800000,
"idCustomer": "3515834441676562996102020010",
"customer": "Hotel Mediterráneo",
"codeCustomer": "C015",
"accountCustomer": "43000015",
"nif": "A87654321",
"paid": false,
"locked": false,
"base": 500.0,
"taxes": 50.0,
"total": 550.0,
"listTaxes": [ … ],
"listCostTypeTaxes": [ … ],
"listDeliveries": [ … ]
}
  • id string — Invoice id.

  • invoiceNum string — Invoice number.

  • documentNum string — Document number.

  • date, dateAccounting, dateDue date — Invoice date, accounting date (if null, use date) and due date.

  • createdAt, updatedAt date — Created and last updated.

  • idCustomer, customer, codeCustomer, accountCustomer, nif string — Customer: id, name, code, ledger account and tax id.

  • paid, locked boolean — Paid and locked.

  • comment string — Comment.

  • codePaymentType string — Payment method code.

  • idCostTypeVendor, costTypeVendor, codeCostTypeVendor, accountCostTypeVendor, accountAuxCostTypeVendor string — Customer's default cost account: id, name, code, ledger account and auxiliary account.

  • idDocument, extDocument string — Attached document: id and extension.

  • base, taxes, total number — Tax base, taxes and total.

  • listTaxes array — Taxes: id, type, base, percent and total. type: 0 VAT · 1 shipping · 2 discount · 3 other.

  • listCostTypeTaxes array — VAT by cost account, calculated from sent lines: account id and descr (null if the lines have none) and listTaxes (type, base, percent, total).

  • listDeliveries array — The invoice's sales delivery notes.

Each sales delivery note (listDeliveries):

  • id string — Delivery note id.

  • invoiceNum string — Delivery note number.

  • date date — Delivery note date.

  • idCustomer, customer, customerCode, nif string — Customer: id, name, code and tax id.

  • address, cp, city string — Customer's address, postcode and city.

  • contact, phone, contactAux, phoneAux, mail, mailAux, mailCC, web string — Customer contacts.

  • customerType, customerTypeCode string, customerTypeInternal boolean — Customer type: name, code and whether it is internal.

  • base number — Base of the sent lines.

  • listLines, listLinesPending array — Sent lines and lines pending shipment.

Each line (listLines, listLinesPending):

  • id string — Line id. position integer — Order within the list, from 0.

  • idComponent, component, codeComponent string — Product sold.

  • idMenu, menu, codeMenu string — Menu sold.

  • codeCustomerProduct string — Customer's sales code for the product.

  • idCustomerGroup, customerGroup string — Product group.

  • comment string — Comment. On lines without product or menu, the sales product name.

  • sent boolean — Sent.

  • quantity number, idUnit, unit string — Quantity and unit.

  • cost number — Unit sale price excluding VAT.

  • costRecipe number — Unit recipe cost.

  • iva number — VAT %.

  • listTypes array — Product families: id and descr.

Need help? Message us from the support chat in the bottom-right corner.

Did this answer your question?