def create(body = nil, timeout: nil, **fields)def create: (
?(project_create | Hash[Symbol | String, untyped])? body,
?timeout: seconds?,
**untyped
) -> project_resourceCreates 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
require "envless/sdk"
project = Envless.projects.create(
name: "API",
slug: "api",
product: "billing"
)
puts "#{project[:id]} #{project.dig(:product, :slug)}"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
body | project_create | No | The fields below as one Hash, with Symbol or String keys, in place of the keywords. |
name: | String | Yes | Human readable project name. |
slug: | String | Yes | Slug for the project, slugified before it is validated for uniqueness. |
product: | String | No | Product slug to create the project in, defaulting to the workspace default product. |
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
project_resource for the newly created project.
Worth knowing
slugis required, and a create without it is refused with 400request.body_invalid.product:resolves product slugs only. Passing a product uniqueId returns 404product.not_found.- 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
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.