Server-side
@intrio/node
Reference for the @intrio/node server SDK: trackLead, trackSale, trackRefund, attributionFrom, retries and errors.
Available on Growth and above. On Free and Starter, use the tracking script, Stripe, Shopify or WooCommerce, which work on every plan. Keys created on Growth keep working after a downgrade.
npm install @intrio/nodeNode 18 or later (it uses the built-in fetch). ES modules only. The SDK is a thin wrapper over the Conversions API.
new Intrio(apiKey, options)#
import { Intrio } from "@intrio/node";
const intrio = new Intrio(process.env.INTRIO_API_KEY!, { retries: 2 });apiKeystringrequired- A secret key starting
pp_live_. Passing anything else throws immediately. options.baseUrlstring- Default
https://intrio.co. options.fetchtypeof fetch- Custom fetch, for tests or proxies.
options.retriesnumber- Retries after the first attempt for network errors, 429 and 5xx. Default 2, waiting 300 ms then 600 ms (doubling); there's no wait after the last attempt.
trackLead(input)#
Sends a signup.
idstringrequired- Unique event id, for example
signup_<user id>. programmestringrequired- Programme slug.
customer{ id, email?, name? }required- Your customer.
refstring | null- Partner code.
clickIdstring | null- Click id.
attributedAtDate | string | null- First-touch time;
attributionFromfills it from the cookie. Applies the attribution window without a click id. occurredAtDate- Defaults to now.
trackSale(input)#
Sends a payment (default) or an order.
idstringrequired- Unique id, for example the invoice id.
programmestringrequired- Programme slug.
amountnumberrequired- Integer minor units.
customer{ id, email?, name? }- Required for payments.
currencystring- Must match the workspace currency.
kind"payment" | "order"- Default
payment. ref, clickId, attributedAt, occurredAt- As for
trackLead.
trackRefund(input)#
idstringrequired- Unique id for the refund.
programmestringrequired- Programme slug.
refundsstringrequired- The
idof the payment or order being refunded. amountnumber- Refunded amount. Defaults to the full payment.
currency, occurredAt- As above.
Intrio.attributionFrom(source)#
Reads the partner from a form body (pp_ref, pp_click, pp_at) or, failing that, from a Cookie header containing pp_attr. Returns { ref, clickId, attributedAt }, or {} when there's nothing.
const { ref, clickId, attributedAt } = Intrio.attributionFrom({ body: req.body, cookie: req.headers.cookie });Results and errors#
Every method resolves to { status, message, referralId? } for recorded, unattributed, no_reward and duplicate. It throws IntrioError for other 4xx responses, and the last error once retries run out.
import { Intrio, IntrioError } from "@intrio/node";
try {
await intrio.trackSale({ id: invoice.id, programme: "app", customer: { id: user.id }, amount: 4900 });
} catch (e) {
if (e instanceof IntrioError) {
console.warn(e.status, e.code, e.message, e.fields);
} else {
throw e; // network failure after retries
}
}IntrioError
statusnumber- HTTP status.
codestring- The response's
errorfield, such asinvalid_api_keyorinvalid_request. For arejectedevent it'srejected(the result's status); readmessage. messagestring- Human-readable reason.
fieldsRecord<string, string[]>- Per-field validation errors for
invalid_request.
Last updated 20 November 2026. Building with an AI assistant? Point it at /docs/llms-full.txt.