Send orders from your server

If your store isn't on a connected sales platform, your system sends each sale to Clakta through the Orders API. Here is what to send and the mistakes to avoid.

If your store runs on Shopify, WooCommerce, Stripe or another connected sales platform, you don't need this: the connection sends your sales for you. This article is for stores whose system sends orders itself, and it needs a developer.

The script can't create orders: sales only reach Clakta from your server, through the Orders API.

The request

Create the key in Team settings → API keys and keep it on your server: it can write to your data. Every option is in the API reference.

What to send

Main fields

FieldWhat it is
projectIdThe id or slug of the project the order belongs to.
orderIdThe order's id in your system.
platformFree text, such as shopify or the name of your own checkout.
paymentMethodcredit_card, debit_card, pix, boleto, paypal, apple_pay, google_pay, samsung_pay, stripe_link or other.
statuspaid, pending, rejected, refunded or canceled.
currencyThree-letter code, such as USD. The project currency if you leave it out.
totalPriceNumber in the main unit: 10.4 means $10.40.
productsEach with id, name, quantity and price.
createdAtDate and time of the order. Now, if you leave it out.
approvedDate, refundedAtOptional dates.

The tracking object

This is what links the order to the ad. Send the values your site captured when the visitor arrived:

FieldWhat it is
clktThe ad click parameter from the first page. Without it the order can never be credited to an ad.
utm_*The campaign UTM tags, kept for reports.
sessionIdThe visit the order belongs to. Ignored in privacy-friendly projects.
domainThe site where the purchase happened. Required in privacy-friendly projects with more than one domain.

Save these values on the cart or checkout when the shopper starts checkout, so your server still has them when the payment is approved.

Privacy-friendly projects

The order is the same, with one strict rule: customer can only contain ip and userAgent. Sending id, name, email, phone, gender, dateOfBirth or address makes Clakta reject the order.

Clakta uses the IP, the browser and the domain to find the visits from the same day. sessionId is ignored.

Updating an order

Refunds and status changes use a PATCH:

You can change status, paymentMethod, platform, currency, totalPrice, createdAt, approvedDate and refundedAt, and you have to send at least one of them.

Tips

Related articles