Projects

envless.projects.create()

Create a project inside a product

def create(
    body: ProjectCreate,
    *,
    timeout: float | None = None,
) -> ProjectResource

Creates a project and returns it. The destination product comes from body['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

from envless import envless

project = envless.projects.create(
    {'name': 'API', 'slug': 'api', 'product': 'billing'}
)

product = project['product']

print(project['id'], product['slug'] if product else None)

Parameters

ParameterTypeRequiredDescription
body['name']strYesHuman readable project name.
body['slug']strYesSlug for the project, slugified before it is validated for uniqueness.
body['product']strNoProduct slug to create the project in, defaulting to the workspace default product.
timeoutfloatNoSeconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

ProjectResource for the newly created project.

Worth knowing

  • slug is required, and a create without it is refused with 400 request.body_invalid.
  • body['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 EnvlessApiError 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.