Workspaces

$envless->workspaces->create()

Create a workspace owned by the key owner

php
/**
 * @param WorkspaceCreate $body
 * @return WorkspaceResource
 */
public function create(array $body, int|float|null $timeout = null): array

Creates a workspace and makes the API key owner its owner with the full owner role. slug is optional and defaults to a slugified name, but slugs are unique across every Envless workspace rather than only yours, so a common name may already be taken.

The response is the last thing this key will ever see of the new workspace. Keys are bound at creation, so current comes back false and no other method in the SDK can reach it. Mint a key inside the new workspace before you try to add products, projects or variables.

Each owner may hold at most 100 workspaces, and passing the cap fails with workspace.limit_reached.

Example

php
use Envless\Envless;

$envless = new Envless();

$workspace = $envless->workspaces->create([
    'name' => 'Billing',
    'slug' => 'billing',
]);

echo "{$workspace['id']} {$workspace['slug']}", PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$bodyWorkspaceCreateYesThe fields below, as one array.
$body['name']stringYesDisplay name, 3 to 50 characters.
$body['slug']stringNoGlobally unique URL slug of lowercase letters, digits and single hyphens.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

WorkspaceResource for the new workspace, with current always false.

Worth knowing

  • This does not change which workspace the owner has selected in the dashboard.
  • Emits workspace.created to the webhook endpoints of the new workspace, so your existing endpoints never see it.

Required scopes

workspace:write

Underlying endpoint

POST /workspaces

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

In TypeScript

envless.workspaces.create()

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