Record an order or a subscription's invoice
const url = 'https://api.motenya.app/v1/products/example/orders';const options = { method: 'POST', 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","sku":"example","name":"example","quantity":1,"unitPrice":"149.90","rowTotal":"149.90","options":[{"label":"example","value":"example"}]}],"custom":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.motenya.app/v1/products/example/orders \ --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", "sku": "example", "name": "example", "quantity": 1, "unitPrice": "149.90", "rowTotal": "149.90", "options": [ { "label": "example", "value": "example" } ] } ], "custom": "example" }'Needs a store, unless subscriptionId makes it a subscription’s invoice. The number must be unique in its store, or among orders without one (ORDER_NUMBER_TAKEN otherwise).
Requires crm:write.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Required unless the order bills a subscription; null takes a subscription’s invoice out of its 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.90Defaults to the sum of the items (a subscription invoice: the plan’s amount).
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.
Responses
Section titled “Responses”Success
object
Null only for a subscription’s invoice.
object
object
object
object
object
object
object
object
object
object
Example
{ "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