> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tolt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Track signups

> Turn a referred visitor into a customer that belongs to the partner who sent them.

When a referred visitor creates an account, tell Tolt once. Tolt links the click cookie to a new customer and binds that customer to the partner.

&#x20;tolt.js
tolt.signup(email)
&#x20;Tolt

Created in Tolt

**customer**cus\_3VbH…emailjane\@example.compartner"sam"statuslead

Returned to your app

**result**customer\_idcus\_3VbH…partner\_idpart\_8fKq…click\_id8537db0b…program\_idprg\_YxLm…

Bind once, every renewal pays. Jane's later payments keep crediting Sam.

> [tab] Browser
>
> Call `tolt.signup()` right after your own signup succeeds. Pass the user's email (or your user id). It resolves with Tolt's customer id, `cus_...`. It waits for the click to be recorded, and `?.` skips it if an ad blocker stopped the script. If your signup completes as the page loads, for example on an OAuth callback, check `window.tolt` first and wait for the `toltScriptLoaded` event if it isn't there yet.
>
> ```js theme={"system"}
> const result = await window.tolt?.signup(user.email);
>
> if (result?.customer_id) {
>   // Save it on your user. You'll need it to record payments.
>   await saveToltCustomerId(user.id, result.customer_id);
> }
> ```
>
> `tolt.signup()` never throws. Visitors without a referral, or a repeat signup, resolve without a `customer_id`, so always check `result?.customer_id`.
>
> With [`@tolt/tracking`](https://docs.tolt.com/sdks/tracking), for example in React, wait for `init()` first:
>
> ```ts theme={"system"}
> import { init, signup } from "@tolt/tracking";
>
> // Call after your own signup succeeds. init() resolves once
> // tolt.js has loaded, and does nothing after the first call.
> async function trackSignup(user: { id: string; email: string }) {
>   await init({ publicKey: "YOUR_PUBLIC_KEY" });
>   const result = await signup(user.email);
>   if (result?.customer_id) {
>     await saveToltCustomerId(user.id, result.customer_id);
>   }
> }
> ```

> [tab] Server
>
> Create the customer from your backend. First send the tracking data from the browser along with your signup request:
>
> ```js theme={"system"}
> // null when the visitor wasn't referred
> const tracking = (await window.tolt?.ready()) ?? null;
>
> await fetch("/api/signup", {
>   method: "POST",
>   headers: { "Content-Type": "application/json" },
>   body: JSON.stringify({ email, password, tolt: tracking }),
> });
> ```
>
> Then, if `tolt.partner_id` is set, create the customer with your API key:
>
> ```ts TypeScript theme={"system"}
> import { ToltApiClient } from "@tolt/api";
>
> const tolt = new ToltApiClient({ token: process.env.TOLT_API_KEY! });
>
> const { data: customer } = await tolt.customers.create({
>   email: "jane@example.com",
>   customer_id: "user_1042", // your own user id
>   partner_id: "part_8fKq2LmZx7RtYw3nVbHc5dPj",
>   click_id: "8537db0b-efeb-416c-ae68-07e6e2863a33",
> });
> // Save customer.id (cus_...) on your user
> ```
>
> ```python Python theme={"system"}
> import os
> from tolt import ToltApi
>
> client = ToltApi(token=os.environ["TOLT_API_KEY"])
>
> res = client.customers.create(
>     email="jane@example.com",
>     customer_id="user_1042",  # your own user id
>     partner_id="part_8fKq2LmZx7RtYw3nVbHc5dPj",
>     click_id="8537db0b-efeb-416c-ae68-07e6e2863a33",
> )
> # Save res.data.id (cus_...) on your user
> ```
>
> ```bash cURL theme={"system"}
> curl -X POST https://platform.tolt.com/v2/customers \
>   -H "Authorization: Bearer $TOLT_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "email": "jane@example.com",
>     "customer_id": "user_1042",
>     "partner_id": "part_8fKq2LmZx7RtYw3nVbHc5dPj",
>     "click_id": "8537db0b-efeb-416c-ae68-07e6e2863a33"
>   }'
> ```
>
> `partner_id` (or `link_id`) is required. `click_id` is optional and must belong to that partner. A duplicate email returns `409 already_exists`.

## What gets created

idTolt's customer id (`cus_...`). Use it as `customer_id` on transactions.
partner\_idSam. Fixed from now on.
status`lead` until the first payment, then `active`.
customer\_idYour own id, only when you set it via the API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.