Environments

Envless.environments.create

Create an environment in a project

def create(project, body = nil, product: nil, timeout: nil, **fields)

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

ruby
require "envless/sdk"

environment = Envless.environments.create(
  "api",
  name: "Production",
  slug: "production"
)

puts "#{environment[:id]} #{environment[:slug]}"

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug or uniqueId that will own the environment.
bodyenvironment_createNoThe fields below as one Hash, with Symbol or String keys, in place of the keywords.
name:StringYesDisplay name, 2 to 50 characters.
slug:StringYesLowercase hyphenated slug, unique inside the project.
product:String | SymbolNoProduct slug that disambiguates an ambiguous project slug.
timeout:Integer | Float | RationalNoSeconds 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

  • exposed is always 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 Envless::ApiError 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 TypeScript

envless.environments.create()

The same method in @goenvless/sdk, with the same request, retries and errors.