Overview
This Ruby gem provides a wrapper to Stigg’s GraphQL API based on the operations that are in use by the Stigg’s Node.js SDK. It leverages the graphlient library under the hood and utilizes theGraphlient::Client class to execute the API requests.
Installing the SDK
The first step is to install the Stigg SDK as a dependency in your application using your application’s dependency manager:Retrieving the server API Key
In the Stigg app, go to Settings > Account > Environments. Copy the Server API key of the relevant environment.Initializing the SDK
Import the Stigg client and initialize it with the API key:Provisioning customers
When a new customer is provisioned within your application (for example: as part of your registration or onboarding process), you should also provision them in Stigg. The customer’s billing information can also be passed to Stigg when a customer is created or updated. When Stigg is integrated with additional service, this information will be propagated to the active integrations. The billing information is not persisted on Stigg’s servers. You can optionally passsubscriptionParams to create subscription for that customer using a single operation. Doing so, will allow Stigg admins to override the requested subscription with no-code from the Stigg Console using the product’s Customer Journey configuration.
Updating customers
Customer information can also be updated whenever you like assuming it already exists, for example: In order to update the customer’s email, you only need to send the new email value without the rest of the customer. Due to the fact that the customer’s billing information is not persisted on Stigg’s servers, in order to update it, the entire billing information object must be passed each time.Getting customer data
Listing customers active subscriptions
ThegetActiveSubscriptionsList method returns a list of slim subscription data, for extended data for a specific subscription use getSubscription method.
Getting a subscription
To retrieve extended subscription data:Listing subscriptions
UseGetSubscriptions to retrieve subscriptions with rich filtering, sorting, and cursor-based pagination. This is useful for admin dashboards, audits, reporting, and support tooling.
Filtering
SubscriptionQueryFilter supports logical composition (and, or) plus field comparisons.
Supported operators:
- Strings/enums: eq, neq, in, notIn
- Dates:
eq,neq,gt,gte,lt,lte,in,notIn
Sorting
- Fields:
createdAt,customerId,environmentId,productId,resourceId,status - Direction:
ASC,DESC - Nulls:
FIRST,LAST
Pagination
Cursor-based pagination via CursorPaging.- Forward:
first,after - Backward:
last,before
Returned fields
Common fields on each subscription node:idstatus(e.g., ACTIVE, CANCELED, IN_TRIAL)pricing_type(PAID, FREE, METERED)start_datecurrent_billing_period_endtrial_end_date
customer.customer_idpaying_customer.customer_id(may differ)resource.resource_id(optional)plan.plan_idandplan.display_nameaddons[]withquantityandaddon.addon_idtrial_configuration.trial_end_behavior
has_next_page,has_previous_page,start_cursor,end_cursor
Error handling and tips
- Use only supported operators (eq, neq, in, notIn for strings/enums).
- Use ISO-8601 UTC timestamps (e.g., 2024-01-01T00:00:00Z).
- Reasonable page sizes: 25–100.
- For performance, combine customerId, status, createdAt.
- Split very large OR lists into multiple calls if needed.
End-to-end example
Provisioning subscriptions
When a customer subscribes to a new plan (for example: during an upgrade from a free plan to a paid plan, or downgrade from a higher tier to a lower tier), a subscription needs to be created in Stigg. When provisioning of a paid subscription is attempted, Stigg is integrated with a billing solution and payment details have not been previously provided by the customer, Stigg will auto-magically redirect customers to a the billing solution’s checkout page. After the customer enters the required payment details in the presented checkout page, the relevant subscription will be created in both Stigg and the billing solution. When no payment is required or when Stigg is not integrated with a billing solution, the subscription will be immediately created in Stigg. When a customer subscribes to a new plan (free, paid, trial, etc.), provision a subscription in Stigg. The provision result can be a successfully created subscription, or a redirect link to stripe checkout in case payment is needed.Updating subscriptions
Updating an existing subscription, this can be used to update the feature quantity that the customer is subscribed for or the add-ons.Cancel subscription
Getting the entitlement of a customer for a specific feature
Used to check if the customer has access to a feature, the usage limit, and the current usage.Getting all of the entitlements of a customer
Used to check to what features the customer has access to, the usage limit , and the current usage of each entitlement.Getting paywall data
Useful for rendering the public pricing page or customer paywall.Reporting usage measurements to Stigg
The Stigg SDK allows you to report usage measurements for metered features. The reported usage will be used to track, limit and bill the customer’s usage of metered features. Stigg supports metering of usage from the following data sources:- Calculated usage - usage that has been aggregated and calculated by your application. This type is useful for features, such as: seats.
- Raw events - raw events from your application, which Stigg filters and aggregates aggregate to calculate customer usage. This type is useful for features, such as: monthly active users (MAUs).
Stigg's metering and aggregation capabilities
Validating that a measurement was successfully reported to Stigg is also possible in the customer details section of the relevant customer in the Stigg app.
Calculated usage
Raw events
reportEvent method.
Getting available coupons
Estimating subscription cost
You can estimate the subscription cost using theestimateSubscription method. This can help the customer to understand the costs before paying.
updateSubscription method, which also returns a breakdown of the proration amounts:
