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

# Create API Token

> Create a new API token for authentication

## Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer qwoty_your_token`
</ParamField>

## Request Body

<ParamField body="name" type="string" required>
  A descriptive name for the API token
</ParamField>

<ParamField body="expires_at" type="string">
  Optional expiration date in ISO 8601 format (e.g., "2024-12-31T23:59:59Z")
</ParamField>

<ParamField body="permissions" type="object">
  Optional permissions configuration for the token
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the operation was successful
</ResponseField>

<ResponseField name="data" type="object">
  The created API token object

  <Expandable title="Token Object">
    <ResponseField name="id" type="string">
      Unique identifier for the token
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the token
    </ResponseField>

    <ResponseField name="token" type="string">
      The actual token value (only returned on creation)
    </ResponseField>

    <ResponseField name="expires_at" type="string">
      Expiration date of the token
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Creation timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://qwoty.app/api/tokens \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "Production API Token",
      "expires_at": "2025-12-31T23:59:59Z"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://qwoty.app/api/tokens', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Production API Token',
      expires_at: '2025-12-31T23:59:59Z',
    }),
  })

  const data = await response.json()
  ```

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

  response = requests.post(
      'https://qwoty.app/api/tokens',
      json={
          'name': 'Production API Token',
          'expires_at': '2025-12-31T23:59:59Z'
      }
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "id": "tok_123abc",
      "name": "Production API Token",
      "token": "qwoty_live_abc123def456...",
      "expires_at": "2025-12-31T23:59:59Z",
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Invalid request data",
    "details": {
      "name": ["Required field"]
    }
  }
  ```
</ResponseExample>
