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

# Create API Key

> Create a new API key for a user.

## Request

<Warning>
  No `Authorization` header is required for this endpoint. The full API key is returned only once.
</Warning>

### Query Parameters

<ParamField query="name" type="string" required>
  A name for the API key (for your reference).
</ParamField>

<ParamField query="user_id" type="string" required>
  The user ID to create the key for.
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the key was created successfully.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Key details">
    <ResponseField name="key_id" type="string">
      Unique identifier for the API key.
    </ResponseField>

    <ResponseField name="api_key" type="string">
      The generated API key. It is returned only on creation.
    </ResponseField>

    <ResponseField name="user_id" type="string">
      The user ID the key belongs to.
    </ResponseField>

    <ResponseField name="name" type="string">
      The name you gave the key.
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 timestamp of when the key was created.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

<CodeGroup>
  ```python Python SDK theme={null}
  from entityml import EntityMLClient

  client = EntityMLClient()
  created = client.api_keys.create(name="my-api-key", user_id="YOUR_USER_ID")
  print(created)
  ```

  ```bash CLI theme={null}
  entityml api-keys create \
    --name my-api-key \
    --user-id YOUR_USER_ID
  ```

  ```bash Raw HTTP (cURL) theme={null}
  curl -X POST "https://api.entityml.com/api/v1/keys?name=my-api-key&user_id=YOUR_USER_ID"
  ```
</CodeGroup>

### Example response

```json theme={null}
{
  "success": true,
  "data": {
    "key_id": "uuid-string",
    "api_key": "pk_generated_api_key",
    "user_id": "user-uuid",
    "name": "my-api-key",
    "created_at": "2025-01-15T10:30:00Z"
  }
}
```
