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

# Create API Key

> Create a new API key with optional resource permissions

## Overview

Creates a new API key for the authenticated user. The plaintext key is returned **only once** in this response -- store it securely.

Optionally restrict the key to specific services, tools, or spending limits using the `permissions` field.

**Auth:** A dashboard session (`Authorization: Bearer <jwt>`) or an API key (`danube-api-key`). An agent can manage keys with its own key.

## Body Parameters

**name** `string` *required*

Display name for the API key (e.g., "Production", "Agent Key")

**permissions** `object`

Optional resource-based permissions. If omitted or null, the key has unrestricted access.

**Permissions object**

**allowed\_services** `array`

Service UUIDs this key can access. `null` = all services.

**allowed\_tools** `array`

Tool UUIDs this key can access. `null` = all tools.

**max\_spend\_per\_call\_cents** `integer`

Maximum cost per single tool call in cents.

**max\_spend\_per\_day\_cents** `integer`

Maximum daily spend for this key in cents.

**require\_confirmation** `boolean`

When true, a call that writes, sends, spends or deletes answers 409 `confirmation_required` with a `confirm_token` until it is repeated with that token (the consent handshake).

**agent\_name** `string`

Name of the agent this key belongs to, shown in the dashboard and the audit log

**agent\_type** `string`

One of `coding_agent`, `assistant`, `workflow`, `service`, `other`

**purpose** `string`

One line on what the key is for

**org\_id** `string`

The organization the key belongs to. The caller must be a member (`404` for an unknown organization, `403` for one you do not belong to). Calls made with the key run in that organization's context without a `danube-org-id` header, and its owners and admins can revoke it. Omitted, the key belongs to your personal organization. See [Organizations](https://docs.danubeai.com/organizations/overview.md#organization-keys-and-limits).

## Response

**id** `string`

API key UUID

**key** `string`

The plaintext API key (shown once only -- store securely)

**key\_prefix** `string`

First 8 characters of the key (for identification)

**name** `string`

Display name

**created\_at** `string`

ISO 8601 creation timestamp

**last\_used** `string`

Last usage timestamp (null on creation)

**permissions** `object`

Resource permissions (null = unrestricted)

**org\_id** `string`

The organization the key belongs to

## Example

```bash cURL theme={null}
curl -X POST "https://api.danubeai.com/v1/api-keys" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Key",
    "permissions": {
      "allowed_services": ["service_uuid_1"],
      "allowed_tools": null
    }
  }'
```

```python Python SDK theme={null}
from danube import DanubeClient

client = DanubeClient(api_key="YOUR_API_KEY")
new_key = client.api_keys.create(
    name="Production Key",
    permissions={
        "allowed_services": ["service_uuid_1"],
        "allowed_tools": None,
    }
)
print(f"Key: {new_key.key}")  # Store this securely!
```

```typescript TypeScript SDK theme={null}
import { DanubeClient } from 'danube';

const client = new DanubeClient({ apiKey: 'YOUR_API_KEY' });
const newKey = await client.apiKeys.create({
  name: 'Production Key',
  permissions: {
    allowedServices: ['service_uuid_1'],
    allowedTools: null,
  }
});
console.log(`Key: ${newKey.key}`);  // Store this securely!
```

```json theme={null}
{
  "id": "abc123",
  "key": "3q2xJd0eK9mPzV5tR8wYs1uB4nC7fH6gLsA2iDoXk5U",
  "key_prefix": "3q2xJd0e",
  "name": "Production Key",
  "created_at": "2026-02-28T10:00:00Z",
  "last_used": null,
  "permissions": {
    "allowed_services": ["service_uuid_1"],
    "allowed_tools": null
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.