def create(project, body = nil, product: nil, timeout: nil, **fields)def create: (
String project,
?(environment_create | Hash[Symbol | String, untyped])? body,
?product: (String | Symbol)?,
?timeout: seconds?,
**untyped
) -> environment_resourceCreates 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
require "envless/sdk"
environment = Envless.environments.create(
"api",
name: "Production",
slug: "production"
)
puts "#{environment[:id]} #{environment[:slug]}"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | String | Yes | Project slug or uniqueId that will own the environment. |
body | environment_create | No | The fields below as one Hash, with Symbol or String keys, in place of the keywords. |
name: | String | Yes | Display name, 2 to 50 characters. |
slug: | String | Yes | Lowercase hyphenated slug, unique inside the project. |
product: | String | Symbol | No | Product slug that disambiguates an ambiguous project slug. |
timeout: | Integer | Float | Rational | No | Seconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
environment_resource, the full shape that carries exposed and updatedAt.
Worth knowing
exposedis always 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, whichEnvless::ApiErrordoes not expose.
Required scopes
environments:write
Underlying endpoint
POST /projects/{slug}/environments
Request and response schema, every error code, and a live playground.
In TypeScript
envless.environments.create()
The same method in @goenvless/sdk, with the same request, retries and errors.