Create or update an order or invoice by its id in your system
const url = 'https://api.motenya.app/v1/products/example/sync/orders/erp/C-1042';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"storeId":"example","number":"example","contactId":"example","clientId":"example","subscriptionId":"example","periodStart":"2026-11-21T09:30:00Z","periodEnd":"2026-11-21T09:30:00Z","status":"pending","statusRaw":"example","paymentStatus":"unpaid","paidAt":"2026-11-21T09:30:00Z","dueAt":"2026-11-21T09:30:00Z","currency":"RON","subtotal":"149.90","shipping":"149.90","tax":"149.90","discount":"149.90","total":"149.90","paymentMethod":"example","billingAddress":{"label":"example","line1":"example","line2":"example","city":"example","region":"example","postalCode":"example","country":"example"},"shippingAddress":{"label":"example","line1":"example","line2":"example","city":"example","region":"example","postalCode":"example","country":"example"},"placedAt":"2026-11-21T09:30:00Z","items":[{"catalogItemId":"example","catalogItemExternalId":"example","sku":"example","name":"example","quantity":1,"unitPrice":"149.90","rowTotal":"149.90","options":[{"label":"example","value":"example"}]}],"custom":"example","storeExternalId":"example","contactExternalId":"example","clientExternalId":"example","subscriptionExternalId":"example","contactEmail":"example","contactName":"example","shipments":[{"carrierCode":"example","carrierName":"example","trackingNumber":"example","state":"pending","deliveredAt":"2026-11-21T09:30:00Z","externalId":"C-1042","history":[{"at":"2026-11-21T09:30:00Z","status":"example","location":"example"}]}],"documents":[{"kind":"invoice","number":"example","amount":"149.90","reason":"example","issuedAt":"2026-11-21T09:30:00Z","externalId":"C-1042"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.motenya.app/v1/products/example/sync/orders/erp/C-1042 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "storeId": "example", "number": "example", "contactId": "example", "clientId": "example", "subscriptionId": "example", "periodStart": "2026-11-21T09:30:00Z", "periodEnd": "2026-11-21T09:30:00Z", "status": "pending", "statusRaw": "example", "paymentStatus": "unpaid", "paidAt": "2026-11-21T09:30:00Z", "dueAt": "2026-11-21T09:30:00Z", "currency": "RON", "subtotal": "149.90", "shipping": "149.90", "tax": "149.90", "discount": "149.90", "total": "149.90", "paymentMethod": "example", "billingAddress": { "label": "example", "line1": "example", "line2": "example", "city": "example", "region": "example", "postalCode": "example", "country": "example" }, "shippingAddress": { "label": "example", "line1": "example", "line2": "example", "city": "example", "region": "example", "postalCode": "example", "country": "example" }, "placedAt": "2026-11-21T09:30:00Z", "items": [ { "catalogItemId": "example", "catalogItemExternalId": "example", "sku": "example", "name": "example", "quantity": 1, "unitPrice": "149.90", "rowTotal": "149.90", "options": [ { "label": "example", "value": "example" } ] } ], "custom": "example", "storeExternalId": "example", "contactExternalId": "example", "clientExternalId": "example", "subscriptionExternalId": "example", "contactEmail": "example", "contactName": "example", "shipments": [ { "carrierCode": "example", "carrierName": "example", "trackingNumber": "example", "state": "pending", "deliveredAt": "2026-11-21T09:30:00Z", "externalId": "C-1042", "history": [ { "at": "2026-11-21T09:30:00Z", "status": "example", "location": "example" } ] } ], "documents": [ { "kind": "invoice", "number": "example", "amount": "149.90", "reason": "example", "issuedAt": "2026-11-21T09:30:00Z", "externalId": "C-1042" } ] }'Idempotent: the first call creates it, later calls with the same source and external id update the fields sent. References to other records can use their ids in the same source (…ExternalId). A new external id first matches an order by number in the same store (or among orders without one). Send subscriptionExternalId for a subscription’s invoice, and paymentStatus/paidAt to record a payment. shipments and documents replace what this source sent before.
Requires crm:write.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The system the record comes from, named by you: e.g. magento2:casa-verde, stripe, erp.
Example
erpThe system the record comes from, named by you: e.g. magento2:casa-verde, stripe, erp.
The record’s id in that system.
Example
C-1042The record’s id in that system.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Required unless the order bills a subscription; null takes a subscription’s invoice out of its store.
The order or invoice number; unique per store, or among orders without a store.
Makes the order a subscription’s invoice. On create, fills the customer, store, currency and a line for the plan unless given.
The billing period a subscription invoice covers.
Example
2026-11-21T09:30:00ZISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00ZThe store’s own status code, kept as is.
Null or omitted: not tracked, which counts as paid in lifetime value and revenue.
Now, when paid without one; unpaid or void clears it.
Example
2026-11-21T09:30:00ZISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00ZDefaults to the subscription’s or the store’s currency.
Example
RONA decimal amount as a string, e.g. “149.90”.
Example
149.90A decimal amount as a string, e.g. “149.90”.
Example
149.90A decimal amount as a string, e.g. “149.90”.
Example
149.90A decimal amount as a string, e.g. “149.90”.
Example
149.90A decimal amount as a string, e.g. “149.90”.
Example
149.90object
ISO 3166-1 alpha-2, e.g. RO.
object
ISO 3166-1 alpha-2, e.g. RO.
ISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00Zobject
A decimal amount as a string, e.g. “149.90”.
Example
149.90Defaults to quantity × unit price.
Example
149.90object
Custom field values keyed by field key; null clears one. See GET /products/{productId}/custom-fields.
object
The catalog item, by its id in the same source.
A decimal amount as a string, e.g. “149.90”.
Example
149.90A decimal amount as a string, e.g. “149.90”.
Example
149.90object
The store, by its id in the same source.
The contact, by its id in the same source.
The client, by its id in the same source.
The subscription it bills, by its id in the same source.
For buyers without an id (guest checkout): the contact with this email, created when new.
Replaces the shipments this source sent for the order; others’ stay.
object
ISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00ZThe record’s id in that system.
Example
C-1042object
ISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00ZReplaces the invoices and credit memos this source sent for the order; others’ stay.
object
A decimal amount as a string, e.g. “149.90”.
Example
149.90ISO-8601 date-time, e.g. 2026-11-21T09:30:00Z.
Example
2026-11-21T09:30:00ZThe record’s id in that system.
Example
C-1042Responses
Section titled “Responses”Success
object
False when an existing record was updated (found by external id, or matched).
object
Null only for a subscription’s invoice.
object
object
object
object
object
object
object
object
object
object
Example
{ "record": { "status": "pending", "paymentStatus": "unpaid", "shipments": [ { "state": "pending" } ], "documents": [ { "kind": "invoice" } ] }}Invalid request
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Missing, invalid, revoked or expired API key
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Missing scope, API turned off, published article without publish scope, or account suspended
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Not found, or outside the knowledge bases this key may use
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Slug or translation already exists
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Rejected by validation (e.g. unknown language or category)
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Rate limited; see Retry-After
object
object
object
Example
{ "error": { "code": "SLUG_TAKEN" }}Internal error