> Connect Tolt to record affiliate commissions in Tolt every time a Plandalf invoice is paid, one transaction per line item.

Source: https://plandalf.com/docs/automations/tolt

Automations

# Tolt

If your affiliate program runs in Tolt, connect it so Plandalf records each paid invoice in Tolt and credits the partner who referred the buyer. If you'd rather run affiliates in Plandalf itself, see [Affiliates](https://plandalf.com/docs/affiliates/start).

**Before you start**

You need a Tolt program with Tolt's script on your site, and Plandalf products linked to Stripe products: Tolt needs a Stripe product ID (`prod_…`) for each item it records.

## Get your Tolt details

Field

Where to find it

**API Key**

Your secret key from Tolt's API settings. The **Get your Tolt API key** link in the connect window opens the page. Don't use the public `pk_…` key from your site's script.

**Program ID**

Starts with `prg_`. Copy it from your program's address in Tolt, or type `window.tolt_data.program_id` in the browser console on your site.

**Own partner id** (optional)

Starts with `part_`. If your own newsletter links go through a Tolt partner, copy that partner's ID from **Tolt → Partners**. Plandalf then counts those visits as direct, not affiliate.

## Connect Tolt

In Plandalf, open **Automations → Marketplace** and click **Connect** on Tolt. Paste the **API Key** and **Program ID**, add your own partner ID if you have one, and click **Connect**. Plandalf can't check a Tolt key in advance, so a wrong key shows up as an error the first time a Tolt step runs.

## Pass Tolt's referral IDs into checkout

Tolt's script knows which partner sent the visitor. Save those IDs on the checkout by adding this once, on every page that opens a Plandalf checkout:

```html
<script>
  plandalf("configure", {
    properties: {
      tolt_click_id: () => window.tolt_data?.click_id || window.tolt_referral || null,
      tolt_partner_id: () => window.tolt_data?.partner_id || null,
      tolt_program_id: () => window.tolt_data?.program_id || null
    }
  });
</script>
```

Plandalf reads each value when the checkout opens, so it works even if Tolt's script loads a moment later. Sequences see them as `{{trigger.session_properties.tolt_click_id}}` and `{{trigger.session_properties.tolt_partner_id}}`.

## Steps you can add

Step

What it does

Fields

**Find or Create Customer**

Registers the buyer in Tolt against the referring partner. Skipped when no partner ID reached the checkout.

Email, External customer id, Partner id (all required), Click id, Name

**Create Transactions From Invoice**

Records the paid invoice in Tolt, one transaction per line item. Only works after **Invoice Paid**. Skipped when the checkout has no Tolt click ID.

Invoice id (required), Tolt customer id, Click id

Set **External customer id** to the Stripe customer ID, `{{trigger.stripe_customer_id}}`. If you map Plandalf's own customer number by mistake, Plandalf swaps in the Stripe ID. For **Tolt customer id**, pick `id` from the Find or Create Customer step: it's Tolt's own ID, not the Stripe one.

If Tolt already has a customer with that email, Find or Create Customer looks them up in your **Program ID** and returns that record. Tolt ignores a transaction it has already recorded, so rerunning the step is safe.

## Set it up with the template

Open **Automations → Templates**, click **\+ Add** on **Record Tolt referral commission** and pick the checkout your affiliates promote. It builds the sequence with every field above filled in: an **Invoice Paid** trigger, then both Tolt steps. Turn it on once you've tested it.

To test end to end, open a Tolt referral link in a private window, buy through the checkout and check the sale in Tolt. With a test card, turn on **Run on test purchases** first. The steps still write to your real Tolt account, so use a test partner.

**Pick one route**

If Tolt also gets these payments through its own Stripe connection, the same sale can be credited twice. Use one route per checkout.

## Common errors

What you see

What to do

A 401 or authorization error

The key is wrong or it's the public `pk_…` key. Edit the connection in **My apps** and paste the secret key.

Find or Create Customer is skipped

No partner ID reached the checkout: the buyer didn't use a referral link, or the configuration above is missing.

Create Transactions From Invoice is skipped

The checkout has no Tolt click ID. Check the configuration and that Tolt's script runs on the page.

Tolt answers "Invalid ID"

Set **Tolt customer id** to `id` from the Find or Create Customer step.

"program\_id missing or email not in program"

Add or correct the **Program ID** on the connection.

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
