---
title: "Create API Key"
method: POST
path: "/public/v1/workspaces/{workspace_id}/api-keys"
tags: ["User and Workspace management"]
---

# Create API Key

`POST /public/v1/workspaces/{workspace_id}/api-keys`

## Request

- Base URL: `https://api.pandadoc.com`
- URL: `https://api.pandadoc.com/public/v1/workspaces/{workspace_id}/api-keys`
- Auth: one of:
  - API key in header `Authorization`
  - OAuth 2
    - Authorization code: `https://app.pandadoc.com/oauth2/authorize`
    - Token URL: `https://api.pandadoc.com/oauth2/access_token`
- TypeScript: <https://skmtc.dev/pandadoc/apis/pandadoc-public-api/docs/public/v1/workspaces/:workspace_id/api-keys/post.ts> (a function with typed inputs; its response is checked against the schema)

Generate a new API key for the workspace.
Check out [API Key Authentication article](https://developers.pandadoc.com/reference/api-key-authentication-process) for detailed API Keys description.

> 📘 
> - Only an **Org Admin** can generate an API keys.
> - To make another user a key's owner, pass `user_id` of this user. The user should has an **Admin** role in the workspace.
> - Generating a new key invalidates existing key with the same type. Using this request, you can deactivate the key you're using for the request.

## Path parameters

- `workspace_id` string, required

## Request body

- CreateApiKeyRequest
  - `user_id` string
  - `type` 'production' | 'sandbox', required: A type of API key.

## Response `200`

OK

- CreateApiKeyResponse
  - `user_id` string: A unique identifier of the user.
  - `type` 'production' | 'sandbox': A type of API key.
  - `workspace_id` string: A unique identifier of the workspace.
  - `key` string: A New Public API key.

## Other responses

- `400`: Bad Request
- `401`: Authentication error
- `403`: Permission error
- `429`: Too Many Requests

---

[API](https://skmtc.dev/pandadoc/apis/pandadoc-public-api.md) - [All operations](https://skmtc.dev/pandadoc/apis/pandadoc-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/pandadoc/apis/pandadoc-public-api/revisions/b9a306b1a421?raw)
