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

# Creating an API key

> Create an API key to authenticate your requests

<Steps>
  <Step title="Open the API keys page">
    Navigate to the [API section](https://app.runa.io/api-keys) within your account dashboard. Click the "Create new API key" button to generate a new API key.

    <Frame caption="The API keys page is empty when you first open it.">
      <img src="https://mintcdn.com/runa/3fuhXTcDrFXCr5CT/assets/screenshots/api-key-page-empty.png?fit=max&auto=format&n=3fuhXTcDrFXCr5CT&q=85&s=14f9dbba8aeaba189d9df484a7d37094" alt="" width="2671" height="1335" data-path="assets/screenshots/api-key-page-empty.png" />
    </Frame>
  </Step>

  <Step title="Choose the environment">
    You now need to choose the environment to create the API key in. For this guide we will use the **playground** environment.

    <Frame caption="The environment modal is displayed when you click the 'Create new API key' button.">
      <img src="https://mintcdn.com/runa/3fuhXTcDrFXCr5CT/assets/screenshots/api-key-page-env-modal.png?fit=max&auto=format&n=3fuhXTcDrFXCr5CT&q=85&s=c34242251c41e9905c646a6cdf86969d" alt="" width="1146" height="642" data-path="assets/screenshots/api-key-page-env-modal.png" />
    </Frame>
  </Step>

  <Step title="Give the API key a name">
    You should give the API key a name that will help you identify it. This is helpful when managing multiple API keys. It's best practice to generate new keys for each use case and revoke them when they are no longer needed.

    <Frame caption="When creating a new API key, you will be asked to give it a name.">
      <img src="https://mintcdn.com/runa/3fuhXTcDrFXCr5CT/assets/screenshots/api-key-page-create-new.png?fit=max&auto=format&n=3fuhXTcDrFXCr5CT&q=85&s=a13981317db71f09d0bba450777e658f" alt="" width="1269" height="999" data-path="assets/screenshots/api-key-page-create-new.png" />
    </Frame>
  </Step>

  <Step title="Copy the API key">
    After the key is created it will be displayed to you only once. You should copy the key and store it securely. If you loose the key you will need to revoke it and generate a new one.

    <Frame caption="The API key is displayed to you only once.">
      <img src="https://mintcdn.com/runa/3fuhXTcDrFXCr5CT/assets/screenshots/api-key-page-created.png?fit=max&auto=format&n=3fuhXTcDrFXCr5CT&q=85&s=6e27211889bc6f8da369030c4e1f0494" alt="" width="1439" height="597" data-path="assets/screenshots/api-key-page-created.png" />
    </Frame>

    <Note>
      **Securing your API key**

      It is your responsibility to keep your API keys safe and secure. Anyone holding your key will be able to make requests to the API on your behalf.
      Review our [security best practices](/best-practices/security) for information on how to keep your API keys secure.
    </Note>
  </Step>
</Steps>

## The API keys page

Once you have created an API key you can view it on the [API keys page](https://app.runa.io/api-keys). You can also revoke any keys from this page. You can read more in the [authentication guide](/best-practices/authentication).

<Frame caption="The API keys page shows a list of all your API keys.">
  <img src="https://mintcdn.com/runa/3fuhXTcDrFXCr5CT/assets/screenshots/api-key-page-success.png?fit=max&auto=format&n=3fuhXTcDrFXCr5CT&q=85&s=21cef1fb74424a30d2d65a9ccc25dc76" alt="" width="2650" height="1278" data-path="assets/screenshots/api-key-page-success.png" />
</Frame>

## Using your API key

### The API key header

When making requests to the API you will need to include the API key in the request headers. It must be included in the `X-Api-Key` header for all requests.

```http theme={null}
X-Api-Key: YOUR_API_KEY
```

### Testing your API key

You can verify that your API key is working correctly by making a request to the [ping endpoint](/reference/2024-02-05/endpoint/utility/ping). This is a simple health check endpoint that requires authentication but doesn't perform any other operations.

```bash theme={null}
curl -X GET https://playground.runa.io/v2/ping \
  -H "X-Api-Key: YOUR_API_KEY"
```

If your API key is valid, you'll receive this response:

```json theme={null}
{
  "message": "pong"
}
```

If you receive an error, check that:

* You've copied the entire API key correctly
* You're using the correct environment URL (playground or production)
* The API key hasn't been revoked

<br />

<Card horizontal icon="arrow-right" title="Next step: Your first order" href="/getting-started/first-order/which-mode">
  Now that you have your API key, let's put it to use by making your first
  order. You'll learn about the different ordering modes available and choose
  the one that best suits your needs.
</Card>
