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

# api_keys.create()

> Mint a new Mesa API key.

Create a new API key for programmatic access.

**Required scope: `admin`**

```python theme={null}
key = await mesa.api_keys.create(
    name="ci-key",
    scopes=["read", "write"],
    repo_ids=["repo_123"],
    expires_in_seconds=3600,
)

print(key.id)
print(key.key)  # only returned once
```

## Options

<ParamField path="org" type="str | None">
  Organization override.
</ParamField>

<ParamField path="name" type="str | None">
  Human-readable key name.
</ParamField>

<ParamField path="scopes" type="list[str] | None">
  Permission scopes. Supported scopes are `read`, `write`, and `admin`. When omitted, the API defaults to `['read', 'write']`.
</ParamField>

<ParamField path="repo_ids" type="list[str] | None">
  Restrict the key to specific repository IDs. Omit to allow all repositories in the organization.
</ParamField>

<ParamField path="expires_in_seconds" type="int | None">
  Server-side TTL in seconds. The API accepts values from `100` through `31536000`.
</ParamField>

## Response

<ResponseField name="id" type="str">
  API key ID.
</ResponseField>

<ResponseField name="key" type="str">
  Plaintext API key. Store it immediately; it is shown only once.
</ResponseField>

<ResponseField name="name" type="str | None">
  API key name, or null when unnamed.
</ResponseField>

<ResponseField name="scopes" type="list[str]">
  Scopes granted to this key.
</ResponseField>

<ResponseField name="repo_ids" type="list[str] | None">
  Repository allowlist, or null when the key is not repo-scoped.
</ResponseField>

<ResponseField name="tags" type="dict[str, str]">
  User-defined API key tags.
</ResponseField>

<ResponseField name="created_at" type="datetime">
  Creation time.
</ResponseField>
