Products

$envless->products->update()

Update a product name, slug or privacy

php
/**
 * @param ProductPatch $patch
 * @return ProductResource
 */
public function update(
    string $slug,
    array $patch,
    int|float|null $timeout = null,
): array

Partial update: only the keys present in the patch are touched. A new slug is validated against the whole workspace rather than against the product being renamed, so any collision is reported as a conflict.

Flipping isPrivate to true also records a grant for the key owner, so an integration cannot lock itself out in one call. Flipping it back to false leaves every stored grant in place, and those grants start applying again the moment the product is made private.

A product beyond the plan allowance refuses every patch, including a rename. Delete something or upgrade the plan to get back under the cap.

Example

php
use Envless\Envless;

$envless = new Envless();

$product = $envless->products->update('billing', ['isPrivate' => true]);

echo $product['isPrivate'] ? 'private' : 'public', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$slugstringYesProduct slug, or the product uniqueId when the value is UUID shaped.
$patchProductPatchYesThe fields below, as one array.
$patch['name']stringNoNew display name.
$patch['slug']stringNoNew slug, unique across the workspace.
$patch['isPrivate']boolNoSwitches grant enforcement on or off for the product.
$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

ProductResource reflecting the patched product.

Worth knowing

  • An icon key of any value, including null, is rejected before the product is resolved, so an unknown slug plus icon reports the body error and not a missing product.

Required scopes

products:write

Underlying endpoint

PATCH /products/{slug}

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

In TypeScript

envless.products.update()

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