Create project API key
Create project API key: createProjectApiKey in the TypeScript, Python, Rust and Go clients.
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>photon.projects.create_project_api_key(input: CreateProjectApiKeyInput, *, options: RequestOptions | None = None) -> models.CreateProjectApiKeyResponseclient.create_project_api_key(idempotency_key: String, project_id: String, body: &types::CreateProjectApiKeyRequest).await -> Result<ResponseValue<types::CreateProjectApiKeyResponse>, Error<CreateProjectApiKeyError>>client.Projects.CreateProjectApiKey(ctx context.Context, params *CreateProjectApiKeyParams, opts ...RequestOption) (*CreateProjectApiKeyResponse, error)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",
],
},
});import os
from photon_api import Photon
from photon_api.rpc_generated import CreateProjectApiKeyInput
photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.projects.create_project_api_key(
CreateProjectApiKeyInput.model_validate({
"path": {
"projectId": "projectId",
},
"headers": {
"Idempotency-Key": "idempotencyKey",
},
"body": {
"name": "name",
"permissions": [
"calls:read",
],
},
})
)use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};
let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
.credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
.build()?;
let result = client
.create_project_api_key(
"idempotencyKey".to_owned(),
"projectId".to_owned(),
&serde_json::from_value(serde_json::json!({
"name": "name",
"permissions": [
"calls:read",
],
}))?,
)
.await
.map_err(|error| format!("{error:?}"))?
.into_inner();import (
"context"
"encoding/json"
"os"
photonapi "github.com/photon-hq/api/packages/go"
)
ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
var body photonapi.CreateProjectApiKeyRequest
if err := json.Unmarshal([]byte(`{
"name": "name",
"permissions": [
"calls:read"
]
}`), &body); err != nil {
return err
}
result, err := client.Projects.CreateProjectApiKey(ctx, &photonapi.CreateProjectApiKeyParams{
IdempotencyKey: "idempotencyKey",
ProjectID: "projectId",
Body: body,
})
if err != nil {
return err
}
_ = result{
"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
Selects the API contract date. Without it, the request is served as 2026-07-01.
Identifies one logical mutation across retries.
Body
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.