---
title: "Create an Organization API Key"
method: POST
path: "/organizations/{organizationID}/api-keys"
tags: ["API Keys"]
---

# Create an Organization API Key

`POST /organizations/{organizationID}/api-keys`

Create a new API key for an organization.

## Request body

- CreateAPIKeyRequest
  - `name` string, required
  - `expiry` string, date-time, nullable — Expiration date for the API key, null for no expiry
  - `scopes` string[] — Optional scopes assigned to the API key
  - `projects` string[] — Limit access to these projects
  - `branches` string[] — Limit access to these branches

## Response `201`

API Key created

- object
  - `key` FullAPIKey, required
    - `id` string, required
    - `name` string, required
    - `preview` string, required
    - `scopes` string[], required
    - `projects` string[], required — Projects this API key has access to
    - `branches` string[], required — Branches this API key has access to
    - `created_at` string, date-time, required
    - `expiry` string, date-time, nullable, required — Date when the API key expires (null if no expiry)
    - `last_used` string, date-time, nullable, required — Timestamp of the last time the key was used (null if never)
    - `token` string, required — The actual API key token
    - `created_by` string, nullable — ID of the user that created this API key
    - `created_by_key` string, nullable — ID of the API key that created this API key

## Other responses

- `400` — API key limit reached or invalid request

## Changes

- **2026-07-14** `fcbf82ebfc05` — 1 warning
  - deleted the `path` request parameter `organizationID`
- **2026-04-15** `a2cc5189d200` — 1 breaking
  - added the new path request parameter `organizationID`

[Change history](https://skmtc.dev/xataio/apis/xata-api/changes/organizations/:organizationID/api-keys/post.md)

---

[API](https://skmtc.dev/xataio/apis/xata-api.md) · [All operations](https://skmtc.dev/xataio/apis/xata-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/xataio/xata-api/revisions/16b3a31dfdf8/schema)
