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
const environment = await envless.environments.create('api', { name: 'Production', slug: 'production' })
console.log(environment.id, environment.slug)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | string | Yes | Project slug or uniqueId that will own the environment. |
body.name | string | Yes | Display name, 2 to 50 characters. |
body.slug | string | Yes | Lowercase hyphenated slug, unique inside the project. |
options.product | string | No | Product slug that disambiguates an ambiguous project slug. |
options.signal | AbortSignal | No | Cancels the request. |
Returns
EnvironmentResource, the full shape that carries exposed and updatedAt.
Worth knowing
exposedalways resolves false here; publishing a feed is a separateexposecall.- On a 402 the error
resourcenames the allowance that was hit and itsmessagestates the limit. The response body also carrieslimitandcurrent, whichEnvlessApiErrordoes 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.