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

# Generating API Keys

> Create API keys that allow partner sites to send conversion events back to TyrionURL for attribution.

## What are A/B Testing API Keys?

An API Key is a credential that you generate in TyrionURL's Settings and embed in a partner website (a landing page, checkout page, or lead form). When a visitor on that partner site completes a conversion event (purchase, sign-up, form submission), the site uses your API key to send that event back to TyrionURL.

TyrionURL matches the event to the A/B test variant that originally sent the visitor — giving you true conversion data, not just click data.

***

## When to Use API Keys

* You've set up an A/B test and want to know which variant converted better (not just which got more clicks)
* Your destination URLs are on third-party sites or your own web properties that you can instrument
* You want to track revenue amounts attributed to specific short links or A/B test variants

***

## Generating an API Key

<Steps>
  <Step title="Go to Settings">
    From your dashboard, click your profile icon or navigate to **Settings**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/docs-tyrionurl/images/api-keys-settings.png" alt="Settings page with API keys section" />
    </Frame>
  </Step>

  <Step title="Open the API Keys Section">
    Locate the **A/B Testing API Keys** section in Settings.
  </Step>

  <Step title="Click Generate New Key">
    Click **Generate API Key**. TyrionURL creates a unique key and displays it once.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/docs-tyrionurl/images/api-keys-reveal.png" alt="Generated API key with one-time reveal" />
    </Frame>

    <Warning>
      The API key is shown only once. Copy it immediately and store it securely (e.g., in your site's environment variables). You cannot retrieve it again after closing this dialog.
    </Warning>
  </Step>

  <Step title="Copy and Store the Key">
    Copy the API key and add it to your partner site's environment configuration.

    ```
    TYRIONURL_API_KEY=tyrion_abtest_xxxxxxxxxxxxxxxxxxxxxxxx
    ```
  </Step>
</Steps>

***

## Managing API Keys

From the API Keys section in Settings, you can:

| Action                 | Description                                                    |
| ---------------------- | -------------------------------------------------------------- |
| **View active keys**   | See a list of all generated keys (key values are masked)       |
| **Revoke a key**       | Permanently invalidate a key — useful if it's been compromised |
| **Generate a new key** | Create an additional key for a different integration           |

***

## API Endpoints for Key Management

| Endpoint                         | Description                                  |
| -------------------------------- | -------------------------------------------- |
| `GET /api/abtest/keys`           | List all API keys for the authenticated user |
| `POST /api/abtest/keys/generate` | Generate a new API key                       |
| `DELETE /api/abtest/keys/:id`    | Revoke a specific API key                    |

***

## Security Best Practices

<Check>Store API keys in environment variables — never hardcode them into source code or commit them to version control.</Check>
<Check>Use one API key per integration or partner site so you can revoke individual keys without disrupting others.</Check>
<Check>Rotate keys periodically, especially after personnel changes in teams with access to the key.</Check>
<Check>Restrict key usage to server-side code only — never expose your API key in client-side JavaScript.</Check>

***

## Next Step: Using the Key for Conversion Tracking

Once you've generated and stored your API key, the next step is embedding it in your partner site to send conversion events.

→ See: [Tracking Conversions](/ab-testing/tracking-conversions)

***

## Related Pages

<CardGroup cols={2}>
  <Card title="A/B Testing Setup" icon="flask" href="/ab-testing/setup">
    Configure traffic splitting before setting up tracking.
  </Card>

  <Card title="Tracking Conversions" icon="coins" href="/ab-testing/tracking-conversions">
    Send purchase and lead events to TyrionURL.
  </Card>
</CardGroup>
