Developer docs

Send orders through the API

Send paid orders, with click ids and costs, from your own backend.

Updated

New to the API? Start with the introduction.

The request

Send each paid order once, when it is paid, to POST https://app.roasaurus.com/api/v1/orders with a key that has the write scope. The answer is 202 with what was stored and how many deliveries were queued; ROASaurus then sends the purchase to the store's ad platforms from the server.

curl -X POST https://app.roasaurus.com/api/v1/orders \
  -H "Authorization: Bearer rsk_…" -H "content-type: application/json" \
  -d '{
    "order_id": "10045", "name": "#10045", "total": 64.90, "currency": "EUR",
    "email": "buyer@example.com", "country": "NL",
    "visitor_id": "<value of the _tl cookie>",
    "click_ids": { "fbc": "fb.1.1732000000.AbC", "gclid": "Cj0KCQ…" },
    "client_ip": "203.0.113.7", "user_agent": "Mozilla/5.0 …",
    "items": [{ "sku": "SERUM-30", "name": "Vitamin C Serum", "quantity": 2, "price": 29.95 }],
    "shipping": 4.95, "tax": 11.26, "discount_codes": ["WELCOME10"]
  }'

Example values, fictional ROASaurus Demo Store.

Fields

FieldMeaning
order_id *Your order id (at most 128 characters). Sending the same id again updates the order.
total *The order total, a number.
currency *Three-letter code. Orders in another currency than the store's are converted at the ECB rate of the order's day.
nameThe order name shown in reports, such as #1001.
created_atISO 8601 time of the order; now when left out.
email, phone, first_name, last_name, city, state, zip, countryThe customer. Hashed before they are sent to ad platforms; used for matching and LTV.
customer_id, is_first_orderYour customer id, and whether this is the customer's first order when you know it.
visitor_idThe value of the _tl cookie on your store: links the order to the visitor's clicks.
click_idsAn object with the click ids you captured, such as {"fbc": "…", "fbp": "…", "gclid": "…", "ttclid": "…"}.
client_ip, user_agentThe buyer's IP address and browser, improving matching at the ad platforms.
landing_url, referrer, cart_tokenThe landing page with its UTMs (a fallback for attribution), the referrer and a cart token.
itemsUp to 500 lines: variant_id or id, product_id, sku, name, quantity, price, and optionally discount, grams, requires_shipping, vendor, line_id.
subtotal, discounts, shipping, taxMoney fields for profit. Without them the order counts at its total with no discounts, shipping or tax.
discount_codes, tags, customer_tags, gateway, sourceFor filters, cohorts and the order fee rules.
order_typeone_time, subscription_first or subscription_renewal.
financial_status, cancelled_atDefault paid; a cancellation time when the order was cancelled.
accepts_marketing, sms_marketingMarketing consent, used for audiences.
testtrue for a test order.
store{ "country", "timezone", "currency" } of the shop itself: the defaults for VAT, report days and the reporting currency.

Fields marked * are required. A request without them answers 422 with {"error", "code": "invalid_request", "errors": [...]}. While the store's tracking is paused, the answer is 202 with "stored": false.

Capturing the browser signals

The order is only as attributable as the signals it carries. Read these in the shopper's browser before the order is placed and pass them along with the order (for example as hidden fields or cart attributes):

  • the _tl cookie (the ROASaurus visitor id, set by the tracking script for visitors who consent);
  • the _fbc and _fbp cookies and the click ids in the landing URL (gclid, ttclid, msclkid and others);
  • the buyer's IP address and user agent, from your server's request.

Without them the order still counts in profit and is sent with the hashed customer details, but it cannot be credited to an ad click.

Other write endpoints

POST /api/v1/events sends offline events (calls, in-store sales), POST /api/v1/surveys post-purchase survey answers, and POST /api/v1/expenses costs for the P&L. Their fields are in the API reference. The WooCommerce plugin uses this same endpoint.

Every sale, traced to the ad that earned it

Server-side tracking, profit and lifetime value in one app. Free plan, no credit card.