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

# Create API Key

> Create a new API key

<Note>
  This endpoint requires **Bearer authentication** with your Supabase JWT.
</Note>

## Request

<ParamField body="name" type="string" required>
  Descriptive name for the key (e.g., "Production Server")
</ParamField>

<ParamField body="scopes" type="string[]" required>
  Array of permission scopes
</ParamField>

<ParamField body="allowed_ips" type="string[]">
  Optional IP whitelist
</ParamField>

## Response

<Warning>
  The full API key is only returned once. Store it securely!
</Warning>

<ResponseField name="id" type="string">
  Key identifier.
</ResponseField>

<ResponseField name="full_key" type="string">
  The complete API key. **Only shown once!**
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://prod.api.unleeshed.ai/partner/v1/api-keys" \
    -H "Authorization: Bearer YOUR_SUPABASE_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Production Server",
      "scopes": ["topics:submit", "topics:read", "personas:read"]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://prod.api.unleeshed.ai/partner/v1/api-keys', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${supabaseJwt}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Production Server',
      scopes: ['topics:submit', 'topics:read', 'personas:read']
    })
  });
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "success": true,
    "data": {
      "id": "key-new-123",
      "name": "Production Server",
      "full_key": "pk_live_abc123xxxxxxxxxxxxxxxxxxxxxxxx",
      "key_prefix": "pk_live_abc12",
      "scopes": ["topics:submit", "topics:read", "personas:read"],
      "created_at": "2026-01-30T15:00:00Z"
    }
  }
  ```
</ResponseExample>
