Project keys
The keys of the calling project key's project.
A project key manages the project, its environments and everything in them, with its role's permissions; an environment's endpoint called with it names the environment in x-hixel-environment. A key's secret is shown once, when it is created, and stored only as a hash.
| Operation | Method | SDK |
|---|---|---|
| List project keys | GET | hixel.projectKeys.list |
| Create a project key | POST | hixel.projectKeys.create |
| Get a project key | GET | hixel.projectKeys.get |
| Update a project key | PATCH | hixel.projectKeys.update |
| Rotate a project key | POST | hixel.projectKeys.rotate |
| Revoke a project key | POST | hixel.projectKeys.revoke |
List project keys#
A page of the project's keys, newest first, revoked and expired ones included.
Takes a project key with the member role or higher.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: ProjectKeyList
| Field | Type | Description |
|---|---|---|
data required | array of ProjectKey | |
data[].id required | string | The id of a project key (pkey_…); never the key itself. |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].name required | string | |
data[].role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
data[].last_four required | string | The key's last four characters, to tell keys apart. |
data[].status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
data[].expires_at required | string | null | When the key stops working; null for never. |
data[].revoked_at required | string | null | When the key was revoked; null while it is not. |
data[].created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
data[].created_at required | string (date-time) | |
data[].updated_at required | string (date-time) | |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.project_key_required: an environment's key was sent; the project's endpoints take a project key.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/project/keys" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY"for await (const item of hixel.projectKeys.list()) {
console.log(item);
}Create a project key#
Creates a key of the project and answers its secret, which is never shown again.. A project key cannot give a key more reach than its own (key_reach_exceeded): the admin role when it is a member, a later expiry than its own, or none when it has one.
Takes a project key with the admin role. Accepts an Idempotency-Key header: a retry with the same key runs once.
Request body: CreateProjectKeyBody
| Field | Type | Description |
|---|---|---|
name required | string | A name to tell the key apart. |
role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
expires_at | string (date-time) | When the key stops working; never when left out. |
Response 200: CreatedProjectKey
| Field | Type | Description |
|---|---|---|
key required | ProjectKey | A key of the project, as every read shows it: never the key itself. |
key.id required | string | The id of a project key (pkey_…); never the key itself. |
key.organization_id required | string | The id of your organization (org_…). |
key.project_id required | string | The id of a project (proj_…). |
key.name required | string | |
key.role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
key.last_four required | string | The key's last four characters, to tell keys apart. |
key.status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
key.expires_at required | string | null | When the key stops working; null for never. |
key.revoked_at required | string | null | When the key was revoked; null while it is not. |
key.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
key.created_at required | string (date-time) | |
key.updated_at required | string (date-time) | |
secret required | string | null | The key itself, hx_proj_…: store it now, it is never shown again. null in a response replayed for an Idempotency-Key. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.key_reach_exceededproject_key_required: an environment's key was sent; the project's endpoints take a project key.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 409
project_archived: This project is archived.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X POST "https://api.hixel.dev/v1/project/keys" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc.",
"role": "admin"
}'const createdProjectKey = await hixel.projectKeys.create({
name: "Acme Inc.",
role: "admin",
});Get a project key#
The project key, never its secret; project_key_not_found when the project has none by this id.
Takes a project key with the member role or higher.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The project key's id (pkey_…). |
Response 200: ProjectKey
| Field | Type | Description |
|---|---|---|
id required | string | The id of a project key (pkey_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.project_key_required: an environment's key was sent; the project's endpoints take a project key.
- 404
project_key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/project/keys/pkey_123" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY"const projectKey = await hixel.projectKeys.get("pkey_123");Update a project key#
Renames the key or changes its expiry. A revoked or expired key cannot be changed. A project key cannot give a later expiry than its own, or none when it has one (key_reach_exceeded). Its role cannot change: create a key with the role instead.
Takes a project key with the admin role. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The project key's id (pkey_…). |
Request body: UpdateProjectKeyBody
| Field | Type | Description |
|---|---|---|
name | string | A name to tell the key apart. |
expires_at | string | null | When the key stops working; null for never. |
Response 200: ProjectKey
| Field | Type | Description |
|---|---|---|
id required | string | The id of a project key (pkey_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.key_reach_exceededproject_key_required: an environment's key was sent; the project's endpoints take a project key.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
project_key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same. - 409
project_archived: This project is archived.key_revoked: This key is revoked.key_expired: This key has expired.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PATCH "https://api.hixel.dev/v1/project/keys/pkey_123" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc."
}'const projectKey = await hixel.projectKeys.update("pkey_123", {
name: "Acme Inc.",
});Rotate a project key#
Creates the key's successor, with its name, role and expiry, and answers its secret, which is never shown again. The old key keeps working for grace_period_seconds (none by default, at most 30 days); without one it is revoked at once, the calling key too when it rotates itself. The body may be empty.
Takes a project key with the admin role. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The project key's id (pkey_…). |
Request body: RotateProjectKeyBody
| Field | Type | Description |
|---|---|---|
grace_period_seconds | integer | How long the old key keeps working, in seconds: 0 (the default) to 30 days. |
Response 200: RotatedProjectKey
| Field | Type | Description |
|---|---|---|
previous required | ProjectKey | A key of the project, as every read shows it: never the key itself. |
previous.id required | string | The id of a project key (pkey_…); never the key itself. |
previous.organization_id required | string | The id of your organization (org_…). |
previous.project_id required | string | The id of a project (proj_…). |
previous.name required | string | |
previous.role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
previous.last_four required | string | The key's last four characters, to tell keys apart. |
previous.status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
previous.expires_at required | string | null | When the key stops working; null for never. |
previous.revoked_at required | string | null | When the key was revoked; null while it is not. |
previous.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
previous.created_at required | string (date-time) | |
previous.updated_at required | string (date-time) | |
key required | ProjectKey | A key of the project, as every read shows it: never the key itself. |
key.id required | string | The id of a project key (pkey_…); never the key itself. |
key.organization_id required | string | The id of your organization (org_…). |
key.project_id required | string | The id of a project (proj_…). |
key.name required | string | |
key.role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
key.last_four required | string | The key's last four characters, to tell keys apart. |
key.status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
key.expires_at required | string | null | When the key stops working; null for never. |
key.revoked_at required | string | null | When the key was revoked; null while it is not. |
key.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
key.created_at required | string (date-time) | |
key.updated_at required | string (date-time) | |
secret required | string | null | The successor itself, hx_proj_…: store it now, it is never shown again. null in a response replayed for an Idempotency-Key. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.key_reach_exceededproject_key_required: an environment's key was sent; the project's endpoints take a project key.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
project_key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same. - 409
project_archived: This project is archived.key_revoked: This key is revoked.key_expired: This key has expired.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X POST "https://api.hixel.dev/v1/project/keys/pkey_123/rotate" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"grace_period_seconds": 3600
}'const rotatedProjectKey = await hixel.projectKeys.rotate("pkey_123", {
grace_period_seconds: 3600,
});Revoke a project key#
The key stops working, the calling key too when it revokes itself.. Revoking cannot be undone.
Takes a project key with the admin role. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The project key's id (pkey_…). |
Response 200: ProjectKey
| Field | Type | Description |
|---|---|---|
id required | string | The id of a project key (pkey_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
role required | "admin" | "member" | admin manages the project, its environments and everything in them; member reads them. Never anything of the organization's own. |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where a key stands; expired is an unrevoked key past its expiry. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a project key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the project key was revoked or expired while the request ran.project_key_required: an environment's key was sent; the project's endpoints take a project key.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
project_key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same. - 409
project_archived: This project is archived.key_revoked: This key is revoked.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X POST "https://api.hixel.dev/v1/project/keys/pkey_123/revoke" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY"const projectKey = await hixel.projectKeys.revoke("pkey_123");