def delete(
project: str,
environment: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> DeletedEnvironmentResourceasync def delete(
project: str,
environment: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> DeletedEnvironmentResourceSoft-deletes an environment along with every variable in it, in one transaction, and takes its published versions out of reach with it. There is no guard on a non-empty environment and no undo over the API, so put your own confirmation in front of it.
The response is a tombstone, not the environment shape: id, name, slug, projectId and a deletedVariables count, with no createdAt, exposed or updatedAt. The slot it frees counts back against the per-project environment allowance right away, so a create that was failing with 402 can succeed immediately after.
Example
from envless import envless
deleted = envless.environments.delete('api', 'staging')
print(
deleted['id'],
deleted['projectId'],
deleted['deletedVariables'],
)import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
deleted = await envless.environments.delete('api', 'staging')
print(
deleted['id'],
deleted['projectId'],
deleted['deletedVariables'],
)
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug or uniqueId that owns the environment. |
environment | str | Yes | Environment slug; ids are not accepted. |
product | str | No | Product slug that disambiguates an ambiguous project slug. |
timeout | float | No | Seconds 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
DeletedEnvironmentResource carrying id, name, slug, projectId and deletedVariables.
Worth knowing
deletedVariablescounts live variables only. Version snapshots are not deleted and are not counted, they simply stop resolving once the environment is gone.- Deleting the last environment in a project is allowed; the project itself stays.
- Capture the
slugyou passed before the call if you need it for an audit trail, since the tombstone is all you get back.
Required scopes
environments:write
Underlying endpoint
DELETE /projects/{slug}/environments/{environmentSlug}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.environments.delete()
The same method in @goenvless/sdk, with the same request, retries and errors.