For the complete documentation index, see llms.txt. This page is also available as Markdown.

Offers

Offer methods live under SL.client.offers. They all return promises and work with the Offer object.

The expected flow is a single, short-lived pass: generate (or fetch) → display → claim. Keep the time between generating and claiming as short as possible.

generate()

Generates fresh offers for the current reader. Takes no arguments.

Returns an array of Offer objects.

const offers = await SL.client.offers.generate();

fetch({ uuid })

Fetches a single offer by its uuid.

  • uuid (required) — the offer's uuid.

Returns a single Offer object, including the recommendable field.

Use fetch to spotlight a specific offer — for example, one that is contextual to the content surrounding it. It is not meant as an extra step between generate and claim: offers you just generated can be claimed directly.

Always check recommendable before displaying a fetched offer. When it's false, don't show it — claims to it will be discarded.

const offer = await SL.client.offers.fetch({ uuid: "offer_recommendation_9f8e7d6c5b4a" });

if (offer.recommendable) {
  // render the offer in your UI
}

claim({ email, uuid })

Claims an offer for the reader.

  • uuid (required) — the offer's uuid.

  • email — the reader's email address. Required for lead offers, not required for click or action offers.

The return value depends on the offer's conversion_type:

  • lead offers return { response: "ok" }.

  • click and action offers return { redirect_url }.

For click and action offers, the redirect URL is already included in the Offer object. Browsers only allow opening a new tab for a short moment after a click, so don't make the reader wait for a network roundtrip: redirect or open the new tab immediately using the offer's redirect_url, then call claim — it's what registers the claim with SparkLoop.