Skip to content

POST /v1/projects/{projectId}/api-keys

Creates a key bound to the selected project using the supplied name, permissions and optional expiry. The secret is returned only in this response and in idempotent replays of it; store it securely because other reads never return it. The key is scoped to this project and does not grant account-level access. Supply the required Idempotency-Key header.

photon.projects.createProjectApiKey(input: CreateProjectApiKeyInput, options?: RequestOptions): Promise<CreateProjectApiKeyOutput>
import { Photon } from "@photon-ai/api";

const photon = new Photon({
  headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.createProjectApiKey({
  path: {
    projectId: "projectId",
  },
  headers: {
    idempotencyKey: "idempotencyKey",
  },
  body: {
    name: "name",
    permissions: [
      "calls:read",
    ],
  },
});
{
  "apiKey": {
    "apiKeyId": "string",
    "createdAt": "2026-01-01T00:00:00.000Z",
    "createdByAccountId": "string",
    "expiresAt": null,
    "name": "string",
    "permissions": [
      "string"
    ],
    "permissionsUpdatedAt": null,
    "projectId": "string",
    "revokedAt": null
  },
  "secret": "string"
}

Parameters

Photon-VersionPhotonVersion

Selects the API contract date. Without it, the request is served as 2026-07-01.

Idempotency-Keystringrequired

Identifies one logical mutation across retries.

projectIdstringrequired

Body

expiresAtstring (date-time)
namestringrequired
permissionsarray of ApiKeyPermissionrequired

Returns

201 The created key, with its secret. The secret is returned only in this response and in idempotent replays of it, and cannot be recovered through any other operation. CreateProjectApiKeyResponse

Headers: Photon-Version. The raw response carries these headers; see Raw responses.

apiKeyApiKeyrequired
secretstringrequired