---
title: "Create a workspace API key"
description: "Create a secret key for your backend\u2019s workspace operations."
api: POST https://api.nuxie.ai/v1/workspaces/{workspaceId}/api-keys
authMethod: bearer
playground: simple
search:
  tags: ["api", "workspace", "reference"]
  keywords: ["sk_", "workspace key", "expiresInDays", "owner", "admin", "X-Nuxie-Env"]
---

Create a secret `sk_` key for server-side workspace requests, such as [starting an Experience](/docs/api-reference/workspace/start-experience). You must be a workspace owner or admin with a verified email address.

## Authentication

Authenticate with the **user session bearer token** returned by [Create a user session](/docs/api-reference/workspace/create-session). A workspace `sk_` key cannot authenticate this operation.

## Request

- **`workspaceId`** · path · `string` · required

  Workspace ID from [List your workspaces](/docs/api-reference/workspace/list-workspaces).

- **`name`** · body · `string` · required

  A name describing where you will use the key, from 1 to 100 characters.

- **`expiresInDays`** · body · `integer`

  Days until expiry: `1`–`365`. Defaults to `90`. Send `null` for no expiry.

## Response

Save the `key` when it is created. Later key listings return metadata without the secret. Keep it on your server, separate from the publishable app keys used by the SDKs.

- **`object`** · `string` · required

  `api_key`.

- **`id`** · `string` · required

  Key ID, used to revoke it later.

- **`name`** · `string` · required

  Key name, or `null`.

- **`prefix`** · `string` · required

  `sk_` for workspace keys.

- **`created_by_user_id`** · `string` · required

  Creating user ID, or `null`.

- **`created_at`** · `string` · required

  ISO 8601 creation time.

- **`expires_at`** · `string` · required

  ISO 8601 expiry time, or `null` for no expiry.

- **`last_used_at`** · `string` · required

  ISO 8601 last-use time, or `null`.

- **`enabled`** · `boolean` · required

  Whether the key is enabled.

- **`key`** · `string` · required

  Complete secret key. Returned only when the key is created.

## Use and manage the key

Send the returned key as `Authorization: Bearer <key>` on Workspace API requests. Set `X-Nuxie-Env: test` for test data or `X-Nuxie-Env: live` for live data; requests default to `live` if you omit the header. The key's name or prefix does not select the environment.

To list keys, send `GET /v1/workspaces/{workspaceId}/api-keys`. To revoke a key, send `DELETE /v1/workspaces/{workspaceId}/api-keys/{keyId}`. Both management requests use your **user session token**.

## Errors

A `403` can return `workspace_access_denied` when you are not a member, `workspace_admin_required` when you are not an owner or admin, or `email_verification_required` when your email is unverified. Invalid body fields return `400`.

Workspace API requests also depend on your plan and billing status. See [Workspace authentication](/docs/api-reference/rest-api#workspace-authentication).

```sh title="cURL"
curl https://api.nuxie.ai/v1/workspaces/workspace-id/api-keys \
  --header "Authorization: Bearer $NUXIE_USER_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Experience backend",
  "expiresInDays": 90
}'
```

```json title="201"
{
  "object": "api_key",
  "id": "key-id",
  "name": "Experience backend",
  "prefix": "sk_",
  "created_by_user_id": "user-id",
  "created_at": "2026-08-21T12:00:00.000Z",
  "expires_at": "2026-11-19T12:00:00.000Z",
  "last_used_at": null,
  "enabled": true,
  "key": "sk_example"
}
```
