---
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

---

[API](https://skmtc.net/xata/apis/xata-api.md) · [All operations](https://skmtc.net/xata/apis/xata-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/xata/xata-api/versions/33621695d346/schema)
