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

# Quickstart

> Make your first API request and track your first conversion in a few minutes.

## 1. Get your API key

Log in to Tapfiliate and copy your API key from your [profile settings](https://app.tapfiliate.com/a/profile/). The [help center](https://support.tapfiliate.com/en/articles/12793297-how-to-find-account-id-and-api-key) shows where to find it, together with your account ID that tapfiliate.js needs.

<Warning>
  Your API key can approve commissions. Keep it on your server: never put it in frontend code, a public repository or a support ticket.
</Warning>

## 2. Make your first request

List the programs in your account:

```bash theme={null}
curl https://api.tapfiliate.com/1.6/programs/ \
  -H "X-Api-Key: YOUR_API_KEY"
```

A `200` response with a JSON array of programs means your key works. See [Authentication](/authentication) if you get `401` or `403`.

## 3. Track a conversion

Pick the way that matches where you know about the sale.

<Tabs>
  <Tab title="In the browser">
    Add tapfiliate.js to every page so clicks on affiliate links are detected:

    ```html theme={null}
    <script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
    <script type="text/javascript">
      (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
      (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

      tap('create', 'YOUR_ACCOUNT_ID');
      tap('detect');
    </script>
    ```

    Then report the sale on your thank-you page:

    ```js theme={null}
    tap('conversion', 'ORD123', 49.99);
    ```

    The conversion is only created when the visitor came through an affiliate. See [JavaScript tracking](/tracking/javascript) for customers, trials and multiple commissions.
  </Tab>

  <Tab title="From your server">
    Send the order with the affiliate's referral code, coupon or click ID:

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.tapfiliate.com/1.6/conversions/ \
        -H "X-Api-Key: YOUR_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "referral_code": "janejameson",
          "external_id": "ORD123",
          "amount": 49.99
        }'
      ```

      ```js Node.js theme={null}
      const response = await fetch('https://api.tapfiliate.com/1.6/conversions/', {
        method: 'POST',
        headers: {
          'X-Api-Key': process.env.TAPFILIATE_API_KEY,
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          referral_code: 'janejameson',
          external_id: 'ORD123',
          amount: 49.99,
        }),
      });

      if (!response.ok) {
        throw new Error(`Tapfiliate: ${response.status} ${await response.text()}`);
      }
      const conversion = await response.json();
      ```

      ```python Python theme={null}
      import os
      import requests

      response = requests.post(
          "https://api.tapfiliate.com/1.6/conversions/",
          headers={"X-Api-Key": os.environ["TAPFILIATE_API_KEY"]},
          json={"referral_code": "janejameson", "external_id": "ORD123", "amount": 49.99},
          timeout=10,
      )
      response.raise_for_status()
      conversion = response.json()
      ```

      ```php PHP theme={null}
      $ch = curl_init('https://api.tapfiliate.com/1.6/conversions/');
      curl_setopt_array($ch, [
          CURLOPT_POST => true,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_TIMEOUT => 10,
          CURLOPT_HTTPHEADER => [
              'X-Api-Key: ' . getenv('TAPFILIATE_API_KEY'),
              'Content-Type: application/json',
          ],
          CURLOPT_POSTFIELDS => json_encode([
              'referral_code' => 'janejameson',
              'external_id' => 'ORD123',
              'amount' => 49.99,
          ]),
      ]);
      $conversion = json_decode(curl_exec($ch), true);
      $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      curl_close($ch);
      ```
    </CodeGroup>

    `external_id` is your order ID. A second request with the same `external_id` is rejected with `400 Duplicate conversion`, so a retry never counts a sale twice. See [Create a conversion](/api-reference/conversions/create-a-conversion) for every field.
  </Tab>
</Tabs>

## 4. Check it in your dashboard

Open the conversions report in your Tapfiliate dashboard: the conversion appears there with its commission. Run a test like this before you launch your program, so you know tracking works end to end.

## Next steps

<CardGroup cols={2}>
  <Card title="API reference" icon="code" href="/api-reference/introduction">
    Pagination, rate limits and every endpoint.
  </Card>

  <Card title="Webhooks" icon="bolt" href="/automation/webhooks">
    React to new conversions and commissions.
  </Card>
</CardGroup>


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