Environments

$envless->environments->expose()

Publish an encrypted feed for an environment

php
/** @return EnvironmentResource */
public function expose(
    string $project,
    string $environment,
    ?string $product = null,
    int|float|null $timeout = null,
): array

Turns on public exposure by posting ['exposed' => true] for you. A branded public URL then serves the variables of that environment as ciphertext, so anyone with the link still needs the workspace passphrase or key to read a value. Nothing is decrypted server-side.

Two independent flags have to line up or the call is refused. The workspace needs virtualEnvsEnabled, which you set with $envless->workspace->update(), and the product that owns the project must not be private. A private product fails with environment.expose_private_product and can never be exposed, so move the project or unset privacy first.

Example

php
use Envless\Envless;

$envless = new Envless();

$envless->workspace->update(['virtualEnvsEnabled' => true]);

$environment = $envless->environments->expose('api', 'production');

echo $environment['exposed'] ? 'exposed' : 'not exposed', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug or uniqueId that owns the environment.
$environmentstringYesSlug of the environment to expose; ids are not accepted.
$productstringNoProduct slug that disambiguates an ambiguous project slug.
$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

EnvironmentResource with exposed true, plus updatedAt.

Worth knowing

  • The two-flag opt-in is deliberate, so a single accidental toggle cannot publish a feed.
  • Anything you would not hand out as ciphertext does not belong in an exposed environment.

Required scopes

environments:write

Underlying endpoint

POST /projects/{slug}/environments/{environmentSlug}/expose

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

In TypeScript

envless.environments.expose()

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