---
title: "Generate API key"
method: POST
path: "/api/v1/api-key"
tags: ["api-key"]
---

# Generate API key

`POST /api/v1/api-key`

Generate an api key for the user

## Request body

- APIKeyCreateRequest — API key POST schema. expires_at: Optional datetime when the API key will expire. workspaces: List of workspace UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign to API key. If not provided, uses default role based on read_only flag: - WORKSPACE_ADMIN if read_only is False - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys If not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace for PATs. If not provided, uses the current logic (first available workspace).
  - `description` string
  - `read_only` boolean
  - `expires_at` string, date-time, nullable
  - `workspaces` string[], nullable
  - `role_id` string, uuid, nullable
  - `org_role_id` string, uuid, nullable
  - `default_workspace_id` string, uuid, nullable

## Response `200`

Successful Response

- APIKeyCreateResponse — API key POST schema.
  - `created_at` string, date-time, nullable
  - `id` string, uuid, required
  - `short_key` string, required
  - `description` string, required
  - `read_only` boolean
  - `last_used_at` string, date-time, nullable
  - `expires_at` string, date-time, nullable
  - `workspace_names` string[], nullable
  - `default_workspace_name` string, nullable
  - `role_id` string, uuid, nullable
  - `org_role_id` string, uuid, nullable
  - `access_scope` 'organization' | 'workspace'
  - `key` string, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/langchain-ai/apis/langsmith-deployment-control-plane-api.md) · [All operations](https://skmtc.net/langchain-ai/apis/langsmith-deployment-control-plane-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/langchain-ai/langsmith-deployment-control-plane-api/versions/a0cd098699b4/schema)
