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

# Get your API keys

> Find your test and live keys and set the webhook and callback addresses for your website.

Your **API keys** tell Afara which merchant account a payment belongs to. You paste one of them into your website's payment widget, and Afara does the rest.

## Find your keys

**1. Open Settings**

Log in to the [merchant portal](https://merchant.afarapartners.com/login) and click the **gear icon** at the top right.

**2. Open the API Keys tab**

Select **API Keys**. Under **API Configurations** you will see four keys.

**3. Copy the one you need**

Use the **copy** button next to a key. Use the **eye** icon to reveal a hidden key.

| Key | Starts with | Where it goes |
| - | - | - |
| Test Public Key | `TPK_` | Your website's payment widget while you are testing. |
| Live Public Key | `PK_` | Your website's payment widget once you go live. |
| Test Secret Key | `TSK_` | Your server only. Never your website. |
| Live Secret Key | `SK_` | Your server only. Never your website. |

> [!WARNING]
>
> Your **secret keys** can authorise actions on your account. Never put them on your website, in a mobile app, in screenshots, or in a public GitHub repository. Public keys are safe to place on your website.

> [!TIP]
>
> Always take your keys from **Settings > API Keys** and check the prefix before you paste. The key box on the **Get started** page is labelled "Test API Keys" but can show your live keys, so do not rely on it.

## Set your webhook and callback addresses

Further down the same tab, under **Webhooks & Callback**, there are four fields. Each takes a full address that starts with `https://`.

| Field | What it is for |
| - | - |
| Test Webhook URL | Where Afara sends payment notifications while you are testing. |
| Webhook URL | Where Afara sends payment notifications for real payments. |
| Test Callback URL | Where your customer is sent after paying, in test mode. |
| Callback URL | Where your customer is sent after paying, in live mode. |

Click **Update** to save. You need to fill in at least one of them. Learn more in [Webhooks](https://docs.afarapay.com/payments/webhooks.md).

## If a key is exposed

Click **Regenerate Keys** at the top of the API Keys tab to create new keys. The old keys stop working, so update your website straight away.

> [card] [Add the payment widget](https://docs.afarapay.com/widget/add-to-your-website.md)
>
> Paste your public key into your website and take your first test payment.

> [card] [Set up webhooks](https://docs.afarapay.com/payments/webhooks.md)
>
> Get notified the moment a customer pays.


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