Projects

Envless.projects.create

Create a project inside a product

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

Creates a project and returns it. The destination product comes from product:, which is a field in the body rather than a query option, and it accepts a product slug only. Omit it and the workspace default product is used, being created on the fly if it does not exist yet.

The API wants both name and slug here, unlike product creation which derives the slug for you. Slug uniqueness is scoped to the chosen product, so the same project slug can exist in several products. The plan allowance is counted across the whole workspace and checked before the slug conflict, so a workspace at its limit fails with 402 even when the slug was also taken.

Example

ruby
require "envless/sdk"

project = Envless.projects.create(
  name: "API",
  slug: "api",
  product: "billing"
)

puts "#{project[:id]} #{project.dig(:product, :slug)}"

Parameters

ParameterTypeRequiredDescription
bodyproject_createNoThe fields below as one Hash, with Symbol or String keys, in place of the keywords.
name:StringYesHuman readable project name.
slug:StringYesSlug for the project, slugified before it is validated for uniqueness.
product:StringNoProduct slug to create the project in, defaulting to the workspace default product.
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

project_resource for the newly created project.

Worth knowing

  • slug is required, and a create without it is refused with 400 request.body_invalid.
  • product: resolves product slugs only. Passing a product uniqueId returns 404 product.not_found.
  • 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

projects:write

Underlying endpoint

POST /projects

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

In TypeScript

envless.projects.create()

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