---
title: "Create Namespace Api Key"
method: POST
path: "/v1/namespace/{namespace_id}/api-keys"
tags: ["v1", "Namespace"]
---

# Create Namespace Api Key

`POST /v1/namespace/{namespace_id}/api-keys`

Mint a new API key bound to the given namespace. Caller must authenticate with any API key belonging to the same organization (typically the org-wide / default-namespace key).

**Security:** The full key is returned exactly once in this response. Store it immediately — it cannot be retrieved later. Subsequent reads expose only the masked `key_prefix`.

## Path parameters

- `namespace_id` string, required

## Headers

- `X-API-Key` string, required

## Request body

- CreateNamespaceApiKeyRequest — Request body for ``POST /v1/namespace/{namespace_id}/api-keys``.
  - `name` string, required — Human-readable name for the API key (shown in admin UIs).
  - `environment` 'development' | 'staging' | 'production' — Environment label: development, staging, or production.
  - `permissions` string[] — Permissions granted by this key. Must be a subset of ['read', 'write', 'delete'].

## Response `200`

API key created

- CreateNamespaceApiKeyResponse — Response for ``POST /v1/namespace/{namespace_id}/api-keys``.
  - `code` integer — HTTP status code
  - `status` string — 'success' or 'error'
  - `data` NamespaceApiKeyItem — Public-facing API key data. The ``key`` field is populated **only** in the response of ``POST /v1/namespace/{namespace_id}/api-keys`` (the moment of creation). It is never returned by any read/list endpoint and is never logged. Use ``key_prefix`` (first 24 chars) to identify the key in audit trails and admin dashboards.
    - `objectId` string, nullable — Parse APIKey objectId
    - `key` string, nullable — The full API key string. Returned ONLY on creation; store it securely — you cannot retrieve it later.
    - `key_prefix` string, nullable — First 24 characters of the key, safe for audit/UI display.
    - `name` string, nullable — Human-readable name
    - `namespace_id` string, nullable — Bound namespace objectId
    - `organization_id` string, nullable — Bound organization objectId
    - `environment` string, nullable — Environment label
    - `permissions` string[], nullable — Granted permissions
    - `is_active` boolean, nullable — Whether this key is active
    - `createdAt` string, nullable — Creation timestamp (ISO 8601)
  - `error` string, nullable — Error message if failed
  - `details` unknown

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Namespace not found
- `422` — Validation Error
- `500` — Internal server error

---

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