Environments
The environments of the calling project key's project.
An environment's own endpoints (/v1/keys, /v1/customers, …) take a project key with x-hixel-environment: env_….
| Operation | Method | SDK |
|---|---|---|
| List environments | GET | hixel.environments.list |
| Create an environment | POST | hixel.environments.create |
| Update an environment | PATCH | hixel.environments.update |
| Archive an environment | POST | hixel.environments.archive |
List environments#
A page of the project's environments: Production first, then the test ones, oldest first; archived ones only with include_archived=true.
Takes a project key with the member role or higher.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
include_archived | query | boolean | true to list archived environments too. |
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: EnvironmentList
| Field | Type | Description |
|---|---|---|
data required | array of Environment | |
data[].id required | string | The id of an environment (env_…). |
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[].slug required | string | The environment's name in URLs; unique in its project. |
data[].kind required | "live" | "test" | live for the project's one Production, test for the others. |
data[].archived_at required | string | null | When the environment was archived; null while it is not. An archived environment serves no traffic. |
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/environments" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY"for await (const item of hixel.environments.list()) {
console.log(item);
}Create an environment#
Adds a test environment; Production is the project's only live one and came with it..
Takes a project key with the admin role. Accepts an Idempotency-Key header: a retry with the same key runs once.
Request body: CreateEnvironmentBody
| Field | Type | Description |
|---|---|---|
name required | string | 1 to 100 characters. |
slug required | string | 2 to 48 lowercase letters, digits and dashes; unique in the project; not settings. |
Response 201: Environment
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment (env_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
slug required | string | The environment's name in URLs; unique in its project. |
kind required | "live" | "test" | live for the project's one Production, test for the others. |
archived_at required | string | null | When the environment was archived; null while it is not. An archived environment serves no traffic. |
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.slug_reservedinvalid_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.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.
- 409
project_archived: This project is archived.slug_taken: Another environment of this project already uses this slug.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/environments" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc.",
"slug": "…"
}'const environment = await hixel.environments.create({
name: "Acme Inc.",
slug: "…",
});Update an environment#
Renames the environment or changes its slug..
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 environment's id (env_…). |
Request body: UpdateEnvironmentBody
| Field | Type | Description |
|---|---|---|
name | string | |
slug | string |
Response 200: Environment
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment (env_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
slug required | string | The environment's name in URLs; unique in its project. |
kind required | "live" | "test" | live for the project's one Production, test for the others. |
archived_at required | string | null | When the environment was archived; null while it is not. An archived environment serves no traffic. |
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.slug_reservedinvalid_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.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
environment_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.environment_archived: This environment is archived.slug_taken: Another environment of this project already uses this slug.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/environments/env_123" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc."
}'const environment = await hixel.environments.update("env_123", {
name: "Acme Inc.",
});Archive an environment#
Archives a test environment: its keys, customers and settings are kept, and it serves no traffic. Production is archived with its project only (live_environment).. Archiving 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 environment's id (env_…). |
Response 200: Environment
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment (env_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
name required | string | |
slug required | string | The environment's name in URLs; unique in its project. |
kind required | "live" | "test" | live for the project's one Production, test for the others. |
archived_at required | string | null | When the environment was archived; null while it is not. An archived environment serves no traffic. |
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
environment_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.environment_archived: This environment is archived.live_environment: Production is archived with its project. Archive the project instead.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/environments/env_123/archive" \
-H "Authorization: Bearer $HIXEL_PROJECT_KEY"const environment = await hixel.environments.archive("env_123");