Stigg GraphQL API
How to use the Stigg API on the server-side
The GraphQL endpoint
#
The GraphQL API has a single endpoint:
The endpoint remains constant no matter what operation you perform.
Retrieving the server API Key
#
In the Stigg Cloud Console, go to Settings > Account > Environments .
Copy the Server API key of the relevant environment.
Discovering the GraphQL API
#
GraphQL explorer
#
You can run queries on real Stigg data using our GraphQL Explorer, an integrated development environment in your browser that includes docs, syntax highlighting, and validation errors.
GraphQL introspection
#
GraphQL is introspective. This means you can query a GraphQL schema for details about itself. You can run an introspection query by passing your Server API key as a query parameter:
For example, running the following curl, will get all the available root types:
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 pass ~~~subscriptionParams~~~ 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.
Query
#
Variables
#
Response:
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.
Query
#
Variables
#
Response:
Getting customer data
#
Query
#
Variables
#
Response:
Getting customer active subscriptions
#
Query
#
Variables
#
Response:
Getting a subscription
#
Query
#
Variables
#
Response:
Provisioning subscriptions
#
When a customer subscribes to a new plan (free, paid, trial, etc.), provision the subscription in Stigg.
Query
#
Variables
#
Response:
Updating subscriptions
#
Updating an existing subscription, this can be used to update the feature quantity that the customer is subscribed for.
Query
#
Variables
#
Response:
Cancel subscription
#
Query
#
Variables
#
Response:
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.
Query
#
Variables
#
Response:
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.
Query
#
Variables
#
Response:
Reporting usage measurements to Stigg
The Stigg API 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).
More details about Stigg's metering and aggregation capabilities can be found here .
Calculated usage
#
Query
#
Variables
#
Response:
Raw events
#
Query
#
Variables
#
It's also possible to send a batch of events in one invocation. To do so, simply pass an array of events to the ~~~reportEvent~~~ method.
Result:
The mutation has no return value.
Getting available coupons
#
Query
#
Variables
#
Response:
Estimate subscription cost
#
You can estimate the subscription cost using the ~~~estimateSubscription~~~ method.
This can help the customer to understand the costs before paying.
Query
#
Variables
#
Result:
You can also estimate the cost of updating an existing subscription using the ~~~updateSubscription~~~ method, which also returns a breakdown of the proration amounts:
Query
#
Variables
#
Result:
Migrating subscriptions to the latest plan and add-on version
#
When changes to plans and add-ons are rolled out only to new subscriptions, grandfathering takes place. In order to prevent a SKU sprawl, Stigg allows you to manually migrate subscriptions to the latest plan and add-on version on a subscription-by-subscription basis.
Query
#
Variables
#
Response:
Archiving/unarchiving customers
#
When a customer is archived:
- Its PII (name and email address) will be nullified.
- It will no longer appear in the Stigg app UI.
- It will no longer be returned by the Stigg API and SDKs.
When Stigg is integrated with a billing solution, customers that are archived in Stigg will still exist in the billing solution to allow upcoming invoices to be finalized. Archiving customers in the billing solution can be done manually in the billing solution.
To archive a customer:
To unarchive a customer:
addonAssociatedEntities