Get subscription features

As an alternate to using the tenant provisioning webhooks you can query for the features that should be enabled on a tenant.

To find out which features and quantities a tenant is entitled to, query the tenant’s active and trial subscriptions together with their plan features and current charges. This is the same information Bunny uses to build the tenant provisioning change webhook.

QueryLink to Query section

Look the tenant up by the unique code you assigned to it. The code is typically the tenant’s identifier in your SaaS application.

query tenantEntitlements ($code: String!) {
  tenant (code: $code) {
    id
    code
    name
    account {
      subscriptions (filter: "state in ['active', 'trial']") {
        id
        state
        tenant {
          code
        }
        plan {
          code
          name
          planFeatures {
            value
            feature {
              code
              name
              kind
              isUnit
              isProvisioned
            }
          }
        }
        priceList {
          code
          name
        }
        currentCharges {
          quantity
          feature {
            code
          }
        }
      }
    }
  }
}

Variables

{
  "code": "tenant-553"
}

ResponseLink to Response section

An account can have several tenants, so account.subscriptions returns the subscriptions of every tenant on the account. Keep the ones whose tenant.code matches the tenant you asked for.

{
  "data": {
    "tenant": {
      "id": "418",
      "code": "tenant-553",
      "name": "Superdesk",
      "account": {
        "subscriptions": [
          {
            "id": "31782",
            "state": "ACTIVE",
            "tenant": { "code": "tenant-553" },
            "plan": {
              "code": "business",
              "name": "Business",
              "planFeatures": [
                {
                  "value": null,
                  "feature": { "code": "users", "name": "Users", "kind": "QUANTITY", "isUnit": true, "isProvisioned": true }
                },
                {
                  "value": "custom",
                  "feature": { "code": "workflows", "name": "Workflows", "kind": "VALUE", "isUnit": false, "isProvisioned": true }
                },
                {
                  "value": null,
                  "feature": { "code": "sso", "name": "SSO", "kind": "BOOLEAN", "isUnit": false, "isProvisioned": true }
                }
              ]
            },
            "priceList": { "code": "business_monthly", "name": "Monthly" },
            "currentCharges": [
              { "quantity": 50, "feature": { "code": "users" } }
            ]
          }
        ]
      }
    }
  }
}

Work out the entitlementsLink to Work out the entitlements section

For each subscription, go through plan.planFeatures and skip any feature where isProvisioned is false. Bunny leaves those out of provisioning too.

  • Quantity units (kind is QUANTITY and isUnit is true): the quantity is the sum of quantity over the currentCharges whose feature.code matches. In the example, the tenant has 50 users.
  • Every other feature: the feature is enabled, and its setting is the plan feature’s value. In the example, the tenant has SSO and has workflows set to custom.

If the tenant has several subscriptions, for example a plan and an add-on, combine the features across all of them.

To receive exactly what the provisioning webhook contains instead, call the tenantProvisioningSend mutation. Bunny sends a fresh provisioning webhook for the tenant to your platform’s webhook URL.