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

# Start here 👉

> Add API key authentication, logging and events to your API in minutes.

Welcome to The Auth API documentation. Before you start, create your free account here: [https://app.theauthapi.com](https://app.theauthapi.com). You will need the follow these steps to make a successful request:

### Essential steps before doing anything else:

1. Create an [account](https://app.theauthapi.com)
2. Create a new Project (this could be the name of your API)
3. Generate a new 'Access Key' (sometimes referred to as a root key)
4. Copy your 'Access Key' and Project ID somewhere safe!

### Let's create your fist key

<Steps>
  <Step title="Create a key">
    Open your favourite terminal, copy this API creation code into it. Don't forget to replace `REPLACE_WITH_YOUR_PROJECT_ID` and `REPLACE_WITH_YOUR_ACCESS_KEY_FOUND_IN_YOUR_ACCOUNT` with your actual values!

    ```bash theme={null}
    curl --location 'https://api.theauthapi.com/api-keys/' \
    --header 'x-api-key: REPLACE_WITH_YOUR_ACCESS_KEY_FOUND_IN_YOUR_ACCOUNT' \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "name": "YOUR_API_KEY_NAME",
      "projectId": "REPLACE_WITH_YOUR_PROJECT_ID"
    }'
    ```

    <Accordion title="All the properties...">
      Here's an example of all the properties you can post to create a key:

      ```bash theme={null}
      curl --location 'https://api.theauthapi.com/api-keys/' \
      --header 'x-api-key: REPLACE_WITH_YOUR_ACCESS_KEY_FOUND_IN_YOUR_ACCOUNT' \
      --header 'Content-Type: application/json' \
      --data-raw '{
      "name": "YOUR_API_KEY_NAME",
      "projectId": "REPLACE_WITH_YOUR_PROJECT_ID",
      "customUserId": "OPTIONAL_STRING",
      "customAccountId": "OPTIONAL_STRING",
      "key": "OPTIONAL_STRING",
      "customMetaData": {},
      "expiry": "2050-01-01",
      "rateLimitConfigs": {
          "rateLimit": 10,
          "rateLimitTtl": 60
      }
      }'
      ```

      To automatically generate a key UID, you can remove the 'key' field.
    </Accordion>
  </Step>

  <Step title="Server Response">
    You should see a response similar to this:

    ```json theme={null}
    {
      "key": "OPTIONAL_STRING", //UID key name
      "name": "YOUR_API_KEY_NAME",
      "customMetaData": {},
      "customAccountId": "OPTIONAL_STRING",
      "customUserId": "OPTIONAL_STRING",
      "env": "live",
      "createdAt": "2024-07-17T13:18:22.153Z",
      "updatedAt": "2024-07-17T13:18:22.153Z",
      "isActive": true,
      "expiresAt": "2050-01-01T00:00:00.000Z",
      "rateLimitConfigs": { "rateLimit": 10, "rateLimitTtl": 60 },
      "creationContext": {}
    }
    ```
  </Step>

  <Step title="Now validate the key">
    Run this CURL command in your terminal to validate the key is valid. Don't forget to replace the `REPLACE_WITH_YOUR_ACCESS_KEY_FOUND_IN_YOUR_ACCOUNT` and `YOUR_API_KEY`!

    ```bash theme={null}
    curl --location --globoff --request POST 'https://api.theauthapi.com/api-keys/auth/YOUR_API_KEY' \
    --header 'x-api-key: REPLACE_WITH_YOUR_ACCESS_KEY_FOUND_IN_YOUR_ACCOUNT'
    ```
  </Step>

  <Step title="Server Response">
    You should see a response similar to this:

    ```json theme={null}
    {
      "key": "OPTIONAL_STRING",
      "name": "YOUR_API_KEY_NAME",
      "customMetaData": {},
      "customAccountId": "OPTIONAL_STRING",
      "customUserId": "OPTIONAL_STRING",
      "env": "live",
      "createdAt": "2024-07-17T13:18:22.153Z",
      "updatedAt": "2024-07-17T13:38:44.899Z",
      "isActive": true,
      "expiresAt": "2050-01-01T00:00:00.000Z",
      "rateLimitConfigs": { "rateLimit": 10, "rateLimitTtl": 60 },
      "creationContext": {}
    }
    ```
  </Step>
</Steps>

### What next?

Now you know how to create an API key, you can start to implement it into your API. Here are some tools to help you get started:

<CardGroup>
  <Card title="Build a express middleware in 2 minutes" icon="hand" href="&#x22;/guides/node-middlware-demo&#x22;" />

  <Card title="Using node?" icon="code" href="/libraries/npm-package">
    Install our Node TypeScript SDK
  </Card>

  <Card title="PHP, Go, Python etc" icon="square-code" href="https://github.com/thatapicompany/theauthapi-code-samples">
    Checkout our code samples
  </Card>
</CardGroup>
