Environments

envless.environments.create()

Create an environment in a project

ts
create(project: string, body: EnvironmentCreate, options?: ProductScope): Promise<EnvironmentResource>

Creates an environment inside a project. The API requires both name and slug, so always send a slug: it is slugified server-side before validation and has to be free within the project.

The body is parsed and validated before the project is resolved, so a bad name returns 400 even when the project reference is wrong too. The allowance is counted per project, not per workspace the way products and projects are, and it is checked before the slug conflict, so a project that is already at its limit fails with 402 no matter which slug you picked.

Example

ts
const environment = await envless.environments.create('api', { name: 'Production', slug: 'production' })

console.log(environment.id, environment.slug)

Parameters

ParameterTypeRequiredDescription
projectstringYesProject slug or uniqueId that will own the environment.
body.namestringYesDisplay name, 2 to 50 characters.
body.slugstringYesLowercase hyphenated slug, unique inside the project.
options.productstringNoProduct slug that disambiguates an ambiguous project slug.
options.signalAbortSignalNoCancels the request.

Returns

EnvironmentResource, the full shape that carries exposed and updatedAt.

Worth knowing

  • exposed always resolves false here; publishing a feed is a separate expose call.
  • On a 402 the error resource names the allowance that was hit and its message states the limit. The response body also carries limit and current, which EnvlessApiError does not expose.

Required scopes

environments:write

Underlying endpoint

POST /projects/{slug}/environments

Request and response schema, every error code, and a live playground.

In Python

envless.environments.create()

The same method in envless-sdk, the Python SDK, with the same request, retries and errors.

In Ruby

Envless.environments.create

The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.

In PHP

$envless->environments->create()

The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.