---
title: "Create API Key"
method: POST
path: "/v4/organizations/{organizationId}/apikeys"
tags: ["Api Keys"]
---

# Create API Key

`POST /v4/organizations/{organizationId}/apikeys`

## Request

- Base URL: `https://cloudapi.cloud.couchbase.com`
- URL: `https://cloudapi.cloud.couchbase.com/v4/organizations/{organizationId}/apikeys`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/docs/v4/organizations/:organizationId/apikeys/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a new API key under an organization.

Organization Owners can create Organization and Project scoped API keys.

Project Owner and Project Creator can create project scoped keys.

To learn more, see [Organization, Project, and Database Access Overview](https://docs.couchbase.com/cloud/organizations/organization-projects-overview.html).

## Request body

- CreateAPIKeyRequest
  - `name` string, required: Name of the API key.
  - `description` string: Description for the API key.
  - `expiry` number, float: Expiry of the API key in number of days. Must be at least 0.01 days. If set to -1, the token will not expire.
  - `allowedCIDRs` string[]: List of inbound CIDRs for the API key. The system making a request must come from one of the allowed CIDRs.
  - `organizationRoles` APIKeyOrganizationRoles[], required
  - `resources` APIKeyResourcesItems[]: Resources are the resource level permissions associated with the API key. To learn more about Organization Roles, see [Organization Roles](https://docs.couchbase.com/cloud/organizations/organization-user-roles.html).
    - `type` string: Type of the resource.
    - `id` string, uuid, required: ID of the project.
    - `roles` string[], required: Project Roles associated with the API key. To learn more about Project Roles, see [Project Roles](https://docs.couchbase.com/cloud/projects/project-roles.html).

## Response `201`

Successfully created an API key under an organization.

- CreateAPIKeyResponse
  - `id` string, required: The id is a unique identifier for an apiKey.
  - `token` string, required: The Token is a confidential piece of information that is used to authorize requests made to v4 endpoints.

## Other responses

- `400`: Returned when we are unable to decode the recevied payload.
- `403`: The client does not have the necessary permissions to access this resource.
- `404`: The requested resource was not found.
- `422`: Request validation error.
- `429`: Returned when the client exceeds the rate limit for the given APIKey.
- `500`: An unexpected error occurred in the server while processing this request.

## Changes

- **2026-10-19** `a5e88bcf71cb`: 3 info
  - added the new `organizationBillingAdmin` enum value to the request property `organizationRoles/items/`
  - added the new `organizationBillingViewer` enum value to the request property `organizationRoles/items/`
  - added the new `organizationReadOnly` enum value to the request property `organizationRoles/items/`

[Operation history](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/changes/v4/organizations/:organizationId/apikeys/post.md)

---

[API](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api.md) - [All operations](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/llms.txt) - [OpenAPI document](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/revisions/a5e88bcf71cb?raw)
