# `create()`

1. [`CreateAPIKeyParams`](/content/docs/reference/backend/api-keys/create#create-api-key-params/index.html)
2. [Usage](/content/docs/reference/backend/api-keys/create#usage/index.html)
   1. [Create a basic API key](/content/docs/reference/backend/api-keys/create#create-a-basic-api-key/index.html)
   2. [Create an API key with optional parameters](/content/docs/reference/backend/api-keys/create#create-an-api-key-with-optional-parameters/index.html)
   3. [Backend API (BAPI) endpoint](/content/docs/reference/backend/api-keys/create#backend-api-bapi-endpoint/index.html)

Creates a new API key for the given user or Organization.

Returns the created [`APIKey`](/content/docs/reference/backend/types/backend-api-key/index.html) object.

```
function create(params: CreateAPIKeyParams): Promise<APIKey>
```

## [`CreateAPIKeyParams`](/content/docs/reference/backend/api-keys/create#create-api-key-params/index.html)

- **Name** `claims?`  
  **Type** `Record<string, any> | null`  
  **Description**  
  Custom claims to store additional information about the API key.

- **Name** `createdBy?`  
  **Type** `string | null`  
  **Description**  
  The user ID of the user who created the API key.

- **Name** `description?`  
  **Type** `string | null`  
  **Description**  
  The description of the API key.

- **Name** `name`  
  **Type** `string`  
  **Description**  
  A descriptive name for the API key (e.g., "Production API Key", "Development Key").

- **Name** `scopes?`  
  **Type** `string[]`  
  **Description**  
  Scopes to limit the API key's access to specific resources.

- **Name** `secondsUntilExpiration?`  
  **Type** `number | null`  
  **Description**  
  The number of seconds until the API key expires. Defaults to `null` (never expires).

- **Name** `subject`  
  **Type** `string`  
  **Description**  
  The user or Organization ID to associate the API key with.

## [Usage](/content/docs/reference/backend/api-keys/create#usage/index.html)

### [Create a basic API key](/content/docs/reference/backend/api-keys/create#create-a-basic-api-key/index.html)

```
const userId = 'user_123'

const apiKey = await clerkClient.apiKeys.create({
  name: 'My API Key',
  subject: userId,
})
```

### [Create an API key with optional parameters](/content/docs/reference/backend/api-keys/create#create-an-api-key-with-optional-parameters/index.html)

```
const userId = 'user_123'

const apiKey = await clerkClient.apiKeys.create({
  name: 'Production API Key',
  subject: userId,
  description: 'API key for accessing my application',
  scopes: ['read:users', 'write:users'],
  secondsUntilExpiration: 86400, // expires in 24 hours
})
```

## [Backend API (BAPI) endpoint](/content/docs/reference/backend/api-keys/create#backend-api-bapi-endpoint/index.html)

This method in the SDK is a wrapper around the BAPI endpoint `POST/api_keys`. See the [BAPI reference](/content/docs/reference/backend-api/tag/api-keys/POST/api_keys/index.html) for more information.
