def grant(slug, member_id, timeout: nil)def grant: (
String slug,
String member_id,
?timeout: seconds?
) -> granted_product_access_resourceGrants one workspace member access to a product. The two path values are the whole input, there is no request body, and the call is idempotent: re-granting an existing grant succeeds and still returns granted: true.
member_id is a workspace member id, the value on access.list entries and on the members list, not a user id. Passing a user id reports a missing member, which is the most common failure here. Granting on a public product is allowed and only records the row, which starts affecting reads if the product is later made private.
Example
require "envless/sdk"
member_id = "8f1c0e42-9b7a-4d21-9d0e-3a41c7f5b210"
granted = Envless.products.access.grant("billing", member_id)
puts "#{granted[:granted]} #{granted.dig(:user, :email)}"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | String | Yes | Product slug, or the product uniqueId when the value is UUID shaped. |
member_id | String | Yes | Workspace member id, the same id space the members endpoints use. |
timeout: | Integer | Float | Rational | No | Seconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
granted_product_access_resource with the member id, a user summary and granted.
Worth knowing
- The row is upserted, so the API answers 200 rather than 201 even on a first grant.
- A product beyond the plan allowance refuses grants with the same locked error that blocks updates.
Required scopes
product-access:write
Underlying endpoint
PUT /products/{slug}/access/{memberId}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.products.access.grant()
The same method in @goenvless/sdk, with the same request, retries and errors.