API reference

Orders

Orders from every channel (WhatsApp, Instagram, your storefront, the dashboard and the API) in one place. Scope: orders.

An order starts pending with its stock reserved. It becomes paid when the customer pays its payment link, then fulfilled when you ship it. It can be cancelled at any point, which releases the stock and refunds a paid order.

The order object

{
"id": "0199ed2a-6b1e-7c40-9a3f-1d2e8b4c7a10",
"orderNumber": 42,
"channel": "whatsapp",
"status": "paid",
"customerId": "…",
"customerName": "Ana López",
"customerPhone": "50370000000",
"customerEmail": null,
"shippingAddress": "Col. Escalón, San Salvador",
"notes": null,
"subtotalCents": 5000,
"discountCode": "BIENVENIDA",
"discountAmountCents": 500,
"totalCents": 4500,
"currency": "USD",
"paidAt": "2026-10-12T15:10:00.000Z",
"refundStatus": null,
"items": [
{ "id": "…", "productId": "…", "variantId": "…", "titleSnapshot": "Camisa Oxford - M", "priceCentsSnapshot": 2500, "quantity": 2, "lineTotalCents": 5000 }
],
"createdAt": "2026-10-12T15:04:05.000Z",
"updatedAt": "2026-10-12T15:10:00.000Z"
}
Field
orderNumber Sequential per business: show it as #42.
channel web, whatsapp, instagram or messenger.
status pending, paid, fulfilled or cancelled.
items[].titleSnapshot Title and price are frozen at purchase time.
refundStatus For a paid order that was cancelled: pending, succeeded or failed.

GET/orders

Lists orders, newest first.

Query
status pending, paid, fulfilled or cancelled.
q Order number (42 or #42), or customer name, phone or email.
limit 1–100, default 20.
cursor From the previous page.
curl "https://api.malla.fun/orders?status=paid&limit=20" \
-H "Authorization: Bearer $MALLA_API_KEY"

List items include itemsCount instead of items; fetch one order for its lines.

GET/orders/:id

const order = await malla.orders.retrieve(id)

POST/orders

Places an order. The customer is matched by phone (or created), stock is reserved, and the order starts pending. Answers 201. Then create a payment link to collect.

Body
customer.phone Required. With country code; punctuation is fine.
customer.name, customer.email Optional.
items 1–100 lines of { variantId, quantity }.
discountCode Optional.
notes, shippingAddress Optional.
curl -X POST "https://api.malla.fun/orders" \
-H "Authorization: Bearer $MALLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer": { "phone": "+503 7000 0000", "name": "Ana López" },
"items": [{ "variantId": "VARIANT_ID", "quantity": 2 }],
"discountCode": "BIENVENIDA",
"shippingAddress": "Col. Escalón, San Salvador"
}'

Errors: 409 out_of_stock, 422 invalid_items (unknown variant or inactive product), 422 invalid_discount.

POST/orders/quote

Prices a cart without creating anything: each line with its availability, the discount and the totals. Use it to show a total before placing the order.

const quote = await malla.orders.quote({ items: [{ variantId, quantity: 3 }], discountCode: 'BIENVENIDA' })
quote.lines[0].available // false if there isn't enough stock
quote.discountError // why the code didn't apply, or null
quote.totalCents

PATCH/orders/:id

Changes the status by hand. Only two transitions are allowed here; pending → paid happens through payment.

status
fulfilled A paid order was shipped.
cancelled Releases the stock. A paid order is refunded to the customer.
curl -X PATCH "https://api.malla.fun/orders/ORDER_ID" \
-H "Authorization: Bearer $MALLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "fulfilled" }'

Related events: order.created, order.paid, order.fulfilled, order.cancelled, order.refunded.