Products

Envless.products.create

Create a product in the workspace

def create(body = nil, timeout: nil, **fields)

Creates a product in the workspace the key is bound to. Only name is required: an omitted slug is derived from the name, and a supplied slug is slugified before validation, so My Product and my-product both land on my-product.

The response is built from the freshly inserted row, not from a read back. isPrivate is always false, updatedAt is always nil and there is no locked field even when the new product went in beyond the plan cap. Call get when you need the settled shape, and update when you need the product to be private.

Example

ruby
require "envless/sdk"

product = Envless.products.create(name: "Billing")

puts "#{product[:id]} #{product[:slug]}"

Parameters

ParameterTypeRequiredDescription
bodyproduct_createNoThe fields below as one Hash, with Symbol or String keys, in place of the keywords.
name:StringYesDisplay name for the product.
slug:StringNoPreferred slug, slugified before it is validated for uniqueness.
timeout:Integer | Float | RationalNoSeconds 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

product_resource for the new product, with isPrivate false and no locked field.

Worth knowing

  • The plan allowance is checked before slug uniqueness, so a workspace at its cap reports the upgrade error even when the slug would also have collided.
  • Icons cannot be set here or through update.

Required scopes

products:write

Underlying endpoint

POST /products

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

In TypeScript

envless.products.create()

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