Initialize Widget
Initializes the Widget for the participant and the referral Program that the Widget token names. The request has no body. The token needs the widget:read scope. An affiliate or loyalty Program gets 400 INVALID_REQUEST. The response is not cached (Cache-Control: private, no-store).
Authorization
WidgetJWT HS256 with typ refref-widget+jwt, aud refref-widget, programId the referral Program of the Widget, sub the external ID of the participant, participantKind its kind (individual or group), optional email the contact email of the participant, mandatory iat and exp, lifetime at most 900 seconds. scope lists one or more Widget scopes separated by one space; widget:read gives Widget init, the referral and Reward reads, and the payout details read, and widget:payout gives the payout details save, for example "widget:read widget:payout". A token without the scope of an operation gets 403. Signed by the backend of the Program's Project with the Project secret. A Widget request names no Project and no Program; the token's Program gives both.
In: header
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/widget/init"{ "projectId": "string", "participantId": "string", "referralLinks": [ { "refCodeId": "string", "refCode": "string", "url": "string" } ], "status": "enrolled", "enrollmentId": "string", "programId": "string", "widgetConfig": { "theme": { "preset": "default", "brandColor": "string", "mode": "auto", "radius": 0, "font": "inherit", "density": "compact", "overrides": { "light": { "property1": "string", "property2": "string" }, "dark": { "property1": "string", "property2": "string" } } }, "launcher": { "style": "pill", "position": "bottom-right", "offsetX": 0, "offsetY": 0, "size": "sm", "mobile": "same", "icon": "gift", "text": "string" }, "share": { "platforms": [ "email" ], "iconStyle": "mono" }, "title": "string", "subtitle": "string", "shareMessage": "string", "helpText": "string", "termsUrl": "string", "showBadge": true, "showRefereeNames": true, "referralLink": "string", "referralCode": "string" }, "brand": { "name": "string", "logoUrl": "string", "logoDarkUrl": "string", "iconUrl": "string", "color": "string" }, "showBranding": true, "offer": { "referrer": [ { "eventType": "string", "purpose": "primary", "benefitKind": "cash", "calculation": "fixed", "fixedAmountMinor": "string", "rateBps": -9007199254740991, "currency": "string", "currencyExponent": -9007199254740991, "durationMode": "once", "durationMonths": -9007199254740991, "quantity": -9007199254740991, "unit": { "name": "string", "namePlural": "string" }, "maxRewardsPerBeneficiary": -9007199254740991 } ], "referee": [ { "eventType": "string", "purpose": "primary", "benefitKind": "cash", "calculation": "fixed", "fixedAmountMinor": "string", "rateBps": -9007199254740991, "currency": "string", "currencyExponent": -9007199254740991, "durationMode": "once", "durationMonths": -9007199254740991, "quantity": -9007199254740991, "unit": { "name": "string", "namePlural": "string" }, "maxRewardsPerBeneficiary": -9007199254740991 } ] }, "latestRewardAt": "string"}Identify Handle POST
Says to whom the handle of a browser belongs. The body has one of three forms. `{ handle, participant }`: this browser belongs to the participant. Send it once, at the identity moment (the creation of the account or the group), when the fact that counts comes later, for example a signup at email verification. A signup sent at account creation can send the handle in `identify` instead. Do not identify at sign-in, verification, or account linking. The call creates the participant when the Project does not have it, and enrolls it at sign-up: in each active referral Program whose `enrollAtSignup` is not false, where it was never enrolled, with its referral code. While the participant limit of the Workspace pauses new enrollments, it enrolls nothing. `{ handle, reference }`: this browser belongs to the person of a flow that starts before the account exists and can end on another device or in a hosted login, such as a magic link or a one-time code. `reference.key` is your key of the flow, unique in the Project and bound to its challenge (for example a digest of the magic-link token); a key is never used again. The call that names an unknown key creates its reference, which expires at `reference.expiresAt`: after the receipt and at most 90 days after it; the default is 24 hours after it. An expired reference gets 409. `{ reference, participant }`: the account of the flow exists. The reference resolves once to the participant, and the handles identified to it then belong to the participant. The same participant again returns the first result; another participant, or a reference that expired before it resolved, gets 409. A key that no handle named yet is created resolved, so the two calls can come in either order. It enrolls the participant at sign-up, as the first form does. A handle is identified once: the same target again returns the first identification, and another target gets 409. An unknown handle, or a handle of another Project, gets 404. `observedAt` is the time of the identity moment; the default is the receipt. A caller clock can run ahead: an `observedAt` up to 5 minutes after the receipt records the receipt, and a later one gets 400. The click window of a handle ends at its identification, also when its reference resolves later. A fact uses only the identifications and resolves that RefRef received at or before the fact; a fact never waits for one.
Intake Event POST
Accepts one canonical Event of any type. A purchase sends `type: "purchase"` and its economic facts in `purchase`; the server derives its key and time. A tenant-defined type, which starts with `custom_`, sends its `type`, `sourceEventId`, and `occurredAt`. Names without the prefix are reserved. A participant has one signup, so a `signup` can leave out `sourceEventId` and `occurredAt`: its key is then derived from the participant, and its time is the receipt. A second signup with another key gets 409. Every Event gets an attribution decision. The first Event of a qualifying type of the Project (by default `signup` and `purchase`) with an eligible touch creates the referral; a later Event of any type uses the referral, and the `referrer` and `referee` rules of its type then evaluate it. The `subject` rules of the Programs in which the participant is enrolled evaluate every Event. A type that is not built in, not a qualifying type of the Project, and not named by a benefit rule of the Project is refused with 422. An Event carries no browser data. Only a signup can carry `identify: { handle }`, which identifies the handle of the browser where the account was created to the participant of the signup, as POST /v1/identify does, in the same transaction. The handle comes from a browser cookie, so any string of at most 4096 characters is accepted. A failed identification never fails the Event: the response then has `identified: false`. A retry of a stored signup identifies no handle. A new signup, with or without `identify`, enrolls its participant at sign-up as POST /v1/identify does; a retry of a stored signup, or a signup dated before the Project's API source, enrolls no one. Every Event can carry `refCode`: the one referral code that the referee entered. It is part of the facts. The code counts when its owner was enrolled in the code's Program when the Event occurred (or when RefRef received it, for an Event dated after its receipt), the Program is active, and the owner is not the participant of the Event; otherwise RefRef ignores it. When the Event creates the referral, a code that counts wins over every click. A purchase under a policy that requires a new customer counts a code only on a first order, as it does a click.