API Keys
Personal Access Tokens (PATs) are long-lived API keys for programmatic access. You can create them via the GEN dashboard or through these endpoints.
Token schema
Section titled “Token schema”{ "id": 5, "name": "CI Pipeline", "token_type": "personal_access_token", "created_at": "2026-03-01T12:00:00.000Z", "expires_at": "2026-06-01T12:00:00.000Z", "last_used_at": "2026-03-09T08:15:00.000Z", "revoked_at": null, "status": "active"}The status field is one of: active, expired, revoked.
List API keys
Section titled “List API keys”Returns all PATs for the authenticated user.
GET /v1/persisted_tokensParameters
Section titled “Parameters”None.
Response
Section titled “Response”[ { "id": 5, "name": "CI Pipeline", "token_type": "personal_access_token", "created_at": "2026-03-01T12:00:00.000Z", "expires_at": "2026-06-01T12:00:00.000Z", "last_used_at": "2026-03-09T08:15:00.000Z", "revoked_at": null, "status": "active" }]Example
Section titled “Example”curl https://api.gen.pro/v1/persisted_tokens \ -H "X-API-Key: your-api-key"Create API key
Section titled “Create API key”Creates a new PAT. The response includes a token field with the plain-text key.
POST /v1/persisted_tokensRequest body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | A label for the key (e.g., "n8n production"). |
expires_in | string | No | Duration until expiry (e.g., "30d", "90d"). Omit for no expiration. |
Response (201)
Section titled “Response (201)”{ "id": 6, "name": "n8n production", "token": "gen_pat_abc123def456...", "token_type": "personal_access_token", "created_at": "2026-03-09T10:00:00.000Z", "expires_at": "2026-06-07T10:00:00.000Z", "last_used_at": null, "revoked_at": null, "status": "active"}Example
Section titled “Example”curl -X POST https://api.gen.pro/v1/persisted_tokens \ -H "X-API-Key: your-api-key" \ -H "Content-Type: application/json" \ -d '{"name": "n8n production", "expires_in": "90d"}'Rename API key
Section titled “Rename API key”Updates the name of an existing PAT.
PATCH /v1/persisted_tokens/{id}Path parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
id | integer | The token ID. |
Request body
Section titled “Request body”{ "persisted_token": { "name": "Updated name" }}Response
Section titled “Response”Returns the updated token object (without the plain-text token field).
Example
Section titled “Example”curl -X PATCH https://api.gen.pro/v1/persisted_tokens/6 \ -H "X-API-Key: your-api-key" \ -H "Content-Type: application/json" \ -d '{"persisted_token": {"name": "Updated name"}}'Errors
Section titled “Errors”| Status | Error code | Description |
|---|---|---|
404 | not_found | Token not found or not owned by you. |
Revoke API key
Section titled “Revoke API key”Immediately invalidates a single PAT.
DELETE /v1/persisted_tokens/{id}/revokePath parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
id | integer | The token ID to revoke. |
Response (204)
Section titled “Response (204)”No content.
Example
Section titled “Example”curl -X DELETE https://api.gen.pro/v1/persisted_tokens/6/revoke \ -H "X-API-Key: your-api-key"Errors
Section titled “Errors”| Status | Error code | Description |
|---|---|---|
404 | not_found | Token not found or not owned by you. |
Revoke all API keys
Section titled “Revoke all API keys”Immediately invalidates all PATs for the authenticated user.
DELETE /v1/persisted_tokens/revoke_allResponse (204)
Section titled “Response (204)”No content.
Example
Section titled “Example”curl -X DELETE https://api.gen.pro/v1/persisted_tokens/revoke_all \ -H "X-API-Key: your-api-key"