> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stigg.io/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET

# Overview

This library provides a .NET client to interact with [Stigg's GraphQL API](./graphql) based on API operations that are in use by the [Stigg's Node.js SDK](/api-and-sdks/integration/backend/nodejs)

Under the hood, it leverages [Strawberry Shake](https://chillicream.com/docs/strawberryshake/v13) to generate C# classes for GraphQL types.

# Installing the SDK

The first step is to add the SDK as a dependency in your .NET application, Stigg package is published as a [Nuget package](https://www.nuget.org/packages/Stigg.Api.Client)

<CodeGroup>
  ```shell shell theme={null}
  dotnet add package Stigg.Api.Client
  ```
</CodeGroup>

<Note>
  It's recommended to hard code the `stigg-api-dot-net` version according to the latest version available [here](https://www.nuget.org/packages/Stigg.Api.Client).
</Note>

# Retrieving the full access key

In the Stigg app, go to **Integrations > API keys**.

Copy the **Full access key** of the relevant environment.

# Initializing the SDK

Import the Stigg client and initialize it with the API key.

Synchronous client:

<CodeGroup>
  ```c# App.cs theme={null}
  using Stigg.Api.Client;

  class App {
      public static void main() {
          var stigg = Stigg.createClient("<FULL-ACCESS-KEY>");
      }
  }
  ```
</CodeGroup>

# 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 app using the [product's Customer Journey configuration](/documentation/modeling-your-pricing-in-stigg/products/defining-customer-journey).

<CodeGroup>
  ```c# ProvisionCustomer.cs theme={null}
  var resp = await stigg.ProvisionCustomer.ExecuteAsync(new ProvisionCustomerInput()
  {
    CustomerId= "customer-81726628184",
    Name = "Acme",
    Email = "john@example.com",
    SubscriptionParams = new ProvisionCustomerSubscriptionInput()
    {
      PlanId = "plan-revvenu-basic"
    }
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "provisionCustomer": {
      "customer": {
        "__typename": "Customer",
        "slimCustomerFragment": {
          "id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
          "name": "Acme",
          "email": "john@example.com",
          "createdAt": "2023-11-20T22:39:19.840Z",
          "updatedAt": "2023-11-20T22:39:19.840Z",
          "refId": "customer-5162641",
          "customerId": "customer-5162641",
          "billingId": null,
          "additionalMetaData": {
            "key": "value"
          }
        }
      },
      "subscriptionDecisionStrategy": {
        "rawValue": "REQUESTED_PLAN"
      },
      "subscription": {
        "__typename": "CustomerSubscription",
        "slimSubscriptionFragment": {
          "id": "e09b03a6-d0ec-4d6b-b184-1b897981283e",
          "refId": "subscription-plan-revvenu-basic-tctmtyrvfv",
          "status": {
            "rawValue": "ACTIVE"
          },
          "additionalMetaData": null,
          "billingId": null,
          "billingLinkUrl": null,
          "effectiveEndDate": null,
          "currentBillingPeriodEnd": "2023-12-20T22:39:19.893Z",
          "pricingType": {
            "rawValue": "FREE"
          },
          "latestInvoice": null,
          "paymentCollection": {
            "rawValue": "NOT_REQUIRED"
          },
          "billingSyncError": null,
          "resource": null,
          "experimentInfo": null,
          "prices": [],
          "totalPrice": null,
          "plan": {
            "id": "bad48997-2aec-4f01-bfa5-534e80826c0e",
            "refId": "plan-revvenu-basic"
          },
          "addons": [],
          "customer": {
            "id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
            "refId": "customer-5162641"
          }
        }
      }
    }
  }
  ```
</Expandable>

# 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.

<CodeGroup>
  ```c# UpdateCustomer.cs theme={null}
  var res = await stigg.UpdateCustomer.ExecuteAsync(new UpdateCustomerInput()
  {
    CustomerId = "customer-demo-01",
    Name = "Acme",
    Email = "john@example.com",
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "updateCustomer": {
      "__typename": "Customer",
      "slimCustomerFragment": {
        "id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
        "name": "Acme",
        "email": "john@example.com",
        "createdAt": "2023-11-21T14:14:50.386Z",
        "updatedAt": "2023-11-21T14:30:07.487Z",
        "refId": "customer-demo-01",
        "customerId": "customer-demo-01",
        "billingId": null,
        "additionalMetaData": {
          "key": "value"
        }
      }
    }
  }
  ```
</Expandable>

# Getting customer data

<CodeGroup>
  ```c# GetCustomerById.cs theme={null}
  var res = await stigg.GetCustomerById.ExecuteAsync(new GetCustomerByRefIdInput()
  {
    CustomerId = "customer-demo-01",
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "getCustomerByRefId": {
      "__typename": "Customer",
      "customerWithSubscriptionsFragment": {
        "__typename": "Customer",
        "subscriptions": [
          {
            "__typename": "CustomerSubscription",
            "subscriptionFragment": {
              "id": "ed2696e4-e840-47b8-af7b-a0babbf1a464",
              "startDate": "2023-10-21T13:14:45.992Z",
              "endDate": null,
              "trialEndDate": null,
              "cancellationDate": null,
              "effectiveEndDate": null,
              "status": {
                "rawValue": "ACTIVE"
              },
              "refId": "subscription-plan-revvenu-basic-g6d4kugtyp",
              "currentBillingPeriodEnd": "2023-12-21T13:14:45.992Z",
              "additionalMetaData": null,
              "billingId": null,
              "billingLinkUrl": null,
              "latestInvoice": null,
              "paymentCollection": {
                "rawValue": "NOT_REQUIRED"
              },
              "billingSyncError": null,
              "resource": null,
              "experimentInfo": null,
              "prices": [],
              "totalPrice": null,
              "pricingType": {
                "rawValue": "FREE"
              },
              "plan": {
                "__typename": "Plan",
                "planFragment": {
                  "id": "05a09259-dcb8-47ca-a447-571a2835e694",
                  "refId": "plan-revvenu-basic",
                  "displayName": "Basic",
                  "description": null,
                  "billingId": "prod_P30kaef2AIphhb",
                  "versionNumber": 1,
                  "additionalMetaData": null,
                  "product": {
                    "__typename": "Product",
                    "productFragment": {
                      "refId": "product-revvenu",
                      "displayName": "Revvenu",
                      "description": null,
                      "additionalMetaData": {
                        "recommendedPlan": "plan-revvenu-essentials"
                      },
                      "productSettings": {
                        "downgradePlan": null
                      }
                    }
                  },
                  "basePlan": null,
                  "entitlements": [
                    {
                      "__typename": "PackageEntitlement",
                      "packageEntitlementFragment": {
                        "usageLimit": 3,
                        "hasUnlimitedUsage": null,
                        "featureId": "109e38e3-fa95-40d2-94a7-730b2bce0e87",
                        "resetPeriod": null,
                        "hiddenFromWidgets": [],
                        "isCustom": null,
                        "displayNameOverride": null,
                        "feature": {
                          "featureType": {
                            "rawValue": "NUMBER"
                          },
                          "meterType": {
                            "rawValue": "Fluctuating"
                          },
                          "featureUnits": "template",
                          "featureUnitsPlural": "templates",
                          "displayName": "Templates",
                          "description": null,
                          "refId": "feature-01-templates",
                          "additionalMetaData": null
                        }
                      }
                    },
                    {
                      "__typename": "PackageEntitlement",
                      "packageEntitlementFragment": {
                        "usageLimit": 4,
                        "hasUnlimitedUsage": null,
                        "featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
                        "resetPeriod": {
                          "rawValue": "MONTH"
                        },
                        "hiddenFromWidgets": [],
                        "isCustom": null,
                        "displayNameOverride": null,
                        "feature": {
                          "featureType": {
                            "rawValue": "NUMBER"
                          },
                          "meterType": {
                            "rawValue": "Incremental"
                          },
                          "featureUnits": "campaign",
                          "featureUnitsPlural": "campaigns",
                          "displayName": "Campaigns",
                          "description": null,
                          "refId": "feature-02-campaigns",
                          "additionalMetaData": null
                        }
                      }
                    },
                    {
                      "__typename": "PackageEntitlement",
                      "packageEntitlementFragment": {
                        "usageLimit": 1000,
                        "hasUnlimitedUsage": null,
                        "featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
                        "resetPeriod": {
                          "rawValue": "MONTH"
                        },
                        "hiddenFromWidgets": [],
                        "isCustom": null,
                        "displayNameOverride": null,
                        "feature": {
                          "featureType": {
                            "rawValue": "NUMBER"
                          },
                          "meterType": {
                            "rawValue": "Incremental"
                          },
                          "featureUnits": "active user",
                          "featureUnitsPlural": "active users",
                          "displayName": "Active users",
                          "description": null,
                          "refId": "feature-07-active-users",
                          "additionalMetaData": null
                        }
                      }
                    },
                    {
                      "__typename": "PackageEntitlement",
                      "packageEntitlementFragment": {
                        "usageLimit": 5,
                        "hasUnlimitedUsage": null,
                        "featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
                        "resetPeriod": null,
                        "hiddenFromWidgets": [],
                        "isCustom": null,
                        "displayNameOverride": "5MB file size limit",
                        "feature": {
                          "featureType": {
                            "rawValue": "NUMBER"
                          },
                          "meterType": {
                            "rawValue": "None"
                          },
                          "featureUnits": "MB",
                          "featureUnitsPlural": "MB",
                          "displayName": "Max file size",
                          "description": null,
                          "refId": "feature-06-max-file-size",
                          "additionalMetaData": null
                        }
                      }
                    }
                  ],
                  "inheritedEntitlements": [],
                  "compatibleAddons": [],
                  "prices": [],
                  "pricingType": {
                    "rawValue": "FREE"
                  },
                  "defaultTrialConfig": null
                }
              },
              "addons": [],
              "scheduledUpdates": [],
              "futureUpdates": []
            }
          }
        ],
        "customerFragment": {
          "__typename": "Customer",
          "hasPaymentMethod": false,
          "hasActiveSubscription": true,
          "defaultPaymentExpirationMonth": null,
          "defaultPaymentExpirationYear": null,
          "defaultPaymentMethodLast4Digits": null,
          "trialedPlans": [],
          "experimentInfo": null,
          "coupon": null,
          "eligibleForTrial": [],
          "promotionalEntitlements": [
            {
              "__typename": "PromotionalEntitlement",
              "promotionalEntitlementFragment": {
                "status": {
                  "rawValue": "Active"
                },
                "usageLimit": null,
                "featureId": "56141e76-9a3f-4d16-b76f-e30228f98a22",
                "hasUnlimitedUsage": null,
                "resetPeriod": null,
                "endDate": null,
                "isVisible": true,
                "feature": {
                  "featureType": {
                    "rawValue": "BOOLEAN"
                  },
                  "meterType": {
                    "rawValue": "None"
                  },
                  "featureUnits": null,
                  "featureUnitsPlural": null,
                  "displayName": "Custom domain",
                  "description": null,
                  "refId": "feature-03-custom-domain",
                  "additionalMetaData": null
                }
              }
            }
          ],
          "slimCustomerFragment": {
            "id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
            "name": "Acme",
            "email": "john@example.com",
            "createdAt": "2023-11-21T14:14:50.386Z",
            "updatedAt": "2023-11-21T16:14:35.415Z",
            "refId": "customer-demo-01",
            "customerId": "customer-demo-01",
            "billingId": null,
            "additionalMetaData": {
              "key": "value"
            }
          }
        }
      }
    }
  }
  ```
</Expandable>

# Getting customer active subscriptions

<CodeGroup>
  ```c# GetActiveSubscriptionsList.cs theme={null}
  var res = await stigg.GetActiveSubscriptionsList.ExecuteAsync(new GetActiveSubscriptionsInput()
  {
    CustomerId = "customer-demo-01",
    ResourceId = "site-1" // optional resource ID
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "getActiveSubscriptions": [
      {
        "__typename": "CustomerSubscription",
        "slimSubscriptionFragmentV2": {
          "subscriptionId": "subscription-plan-revvenu-essentials-cd0ba9",
          "startDate": "2023-11-21T16:26:11.000Z",
          "endDate": null,
          "effectiveEndDate": "2024-11-21T16:26:11.000Z",
          "currentBillingPeriodStart": "2023-11-21T16:26:11.000Z",
          "currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
          "billingPeriod": "MONTHLY",
          "additionalMetaData": {
            "internalTierId": "tier-gold"
          },
          "status": {
            "rawValue": "ACTIVE"
          },
          "resource": null,
          "pricingType": {
            "rawValue": "PAID"
          },
          "customer": {
            "customerId": "customer-demo-01",
            "email": "user@example.com"
          },
          "payingCustomer": {
            "customerId": "customer-demo-01",
            "email": "user@example.com"
          },
          "plan": {
            "planId": "plan-revvenu-essentials",
            "displayName": "Essentials",
            "description": "Full access to all Essentials features",
            "product": {
              "refId": "product-main",
              "displayName": "Main Product",
              "downgradePlan": {
                "refId": "plan-free",
                "displayName": "Free Plan"
              }
            }
          },
          "addons": [
            {
              "quantity": 2,
              "addon": {
                "addonId": "addon-10-campaigns"
              }
            }
          ],
          "prices": [
            {
              "billingModel": "FLAT_FEE",
              "price": {
                "billingPeriod": "MONTHLY",
                "price": {
                  "amount": 99,
                  "currency": "USD"
                }
              }
            }
          ],
          "totalPrice": {
            "subTotal": {
              "amount": 99,
              "currency": "USD"
            },
            "total": {
              "amount": 99,
              "currency": "USD"
            }
          }
        }
      }
    ]
  }
  ```
</Expandable>

# Getting a subscription

To retrieve extended subscription data:

<CodeGroup>
  ```c# GetSubscription.cs theme={null}
  var res = await stigg.GetSubscription.ExecuteAsync(new GetSubscriptionInput()
  {
    SubscriptionId = "subscription-id",
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "getSubscription": {
      "__typename": "CustomerSubscription",
      "subscriptionFragment": {
        "id": "b8b48c70-df8a-460c-b5f9-2276a5854a03",
        "startDate": "2023-11-21T16:26:11.000Z",
        "endDate": null,
        "trialEndDate": null,
        "cancellationDate": null,
        "effectiveEndDate": null,
        "status": {
          "rawValue": "ACTIVE"
        },
        "refId": "subscription-plan-revvenu-essentials-cd0ba9",
        "currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
        "additionalMetaData": null,
        "billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
        "billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
        "latestInvoice": {
          "__typename": "SubscriptionInvoice",
          "subscriptionInvoiceFragment": {
            "billingId": "in_1OEwmQAnAO1PFouU8W9U6ldu",
            "status": {
              "rawValue": "PAID"
            },
            "createdAt": "2023-11-21T16:26:30.000Z",
            "updatedAt": "2023-11-21T16:26:32.842Z",
            "requiresAction": false,
            "paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzJzcDRKTGxJcGNucWhZOEJCd2ZheG9SZk5TOEdJLDkxMTI0Nzkz0200ZnGaOwnQ?s=ap",
            "paymentSecret": "pi_3OEwmRAnAO1PFouU1Zg54ALZ_secret_28nQjBxmQnzVg0ISlvBC2eQJR",
            "errorMessage": null
          }
        },
        "paymentCollection": {
          "rawValue": "NOT_REQUIRED"
        },
        "billingSyncError": null,
        "resource": null,
        "experimentInfo": null,
        "prices": [
          {
            "usageLimit": 7,
            "price": {
              "__typename": "Price",
              "priceFragment": {
                "billingModel": {
                  "rawValue": "PER_UNIT"
                },
                "billingPeriod": {
                  "rawValue": "MONTHLY"
                },
                "billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
                "minUnitQuantity": 5,
                "maxUnitQuantity": null,
                "billingCountryCode": null,
                "price": {
                  "amount": 6,
                  "currency": {
                    "rawValue": "USD"
                  }
                },
                "tiersMode": null,
                "tiers": null,
                "feature": {
                  "refId": "feature-01-templates",
                  "featureUnits": "template",
                  "featureUnitsPlural": "templates",
                  "displayName": "Templates",
                  "description": null
                }
              }
            }
          }
        ],
        "totalPrice": {
          "__typename": "CustomerSubscriptionTotalPrice",
          "totalPriceFragment": {
            "subTotal": {
              "amount": 52,
              "currency": {
                "rawValue": "USD"
              }
            },
            "total": {
              "amount": 52,
              "currency": {
                "rawValue": "USD"
              }
            }
          }
        },
        "pricingType": {
          "rawValue": "PAID"
        },
        "plan": {
          "__typename": "Plan",
          "planFragment": {
            "id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
            "refId": "plan-revvenu-essentials",
            "displayName": "Essentials",
            "description": null,
            "billingId": "prod_P30kP9lB01YaiE",
            "versionNumber": 1,
            "additionalMetaData": null,
            "product": {
              "__typename": "Product",
              "productFragment": {
                "refId": "product-revvenu",
                "displayName": "Revvenu",
                "description": null,
                "additionalMetaData": {
                  "recommendedPlan": "plan-revvenu-essentials"
                },
                "productSettings": {
                  "downgradePlan": null
                }
              }
            },
            "basePlan": {
              "refId": "plan-revvenu-basic",
              "displayName": "Basic"
            },
            "entitlements": [
              {
                "__typename": "PackageEntitlement",
                "packageEntitlementFragment": {
                  "usageLimit": 12,
                  "hasUnlimitedUsage": null,
                  "featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
                  "resetPeriod": {
                    "rawValue": "MONTH"
                  },
                  "hiddenFromWidgets": [],
                  "isCustom": null,
                  "displayNameOverride": null,
                  "feature": {
                    "featureType": {
                      "rawValue": "NUMBER"
                    },
                    "meterType": {
                      "rawValue": "Incremental"
                    },
                    "featureUnits": "campaign",
                    "featureUnitsPlural": "campaigns",
                    "displayName": "Campaigns",
                    "description": null,
                    "refId": "feature-02-campaigns",
                    "additionalMetaData": null
                  }
                }
              },
              {
                "__typename": "PackageEntitlement",
                "packageEntitlementFragment": {
                  "usageLimit": 25000,
                  "hasUnlimitedUsage": null,
                  "featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
                  "resetPeriod": {
                    "rawValue": "MONTH"
                  },
                  "hiddenFromWidgets": [],
                  "isCustom": null,
                  "displayNameOverride": null,
                  "feature": {
                    "featureType": {
                      "rawValue": "NUMBER"
                    },
                    "meterType": {
                      "rawValue": "Incremental"
                    },
                    "featureUnits": "active user",
                    "featureUnitsPlural": "active users",
                    "displayName": "Active users",
                    "description": null,
                    "refId": "feature-07-active-users",
                    "additionalMetaData": null
                  }
                }
              },
              {
                "__typename": "PackageEntitlement",
                "packageEntitlementFragment": {
                  "usageLimit": 100,
                  "hasUnlimitedUsage": null,
                  "featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
                  "resetPeriod": null,
                  "hiddenFromWidgets": [],
                  "isCustom": null,
                  "displayNameOverride": "100MB file size limit",
                  "feature": {
                    "featureType": {
                      "rawValue": "NUMBER"
                    },
                    "meterType": {
                      "rawValue": "None"
                    },
                    "featureUnits": "MB",
                    "featureUnitsPlural": "MB",
                    "displayName": "Max file size",
                    "description": null,
                    "refId": "feature-06-max-file-size",
                    "additionalMetaData": null
                  }
                }
              },
              {
                "__typename": "PackageEntitlement",
                "packageEntitlementFragment": {
                  "usageLimit": null,
                  "hasUnlimitedUsage": null,
                  "featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
                  "resetPeriod": null,
                  "hiddenFromWidgets": [],
                  "isCustom": null,
                  "displayNameOverride": null,
                  "feature": {
                    "featureType": {
                      "rawValue": "BOOLEAN"
                    },
                    "meterType": {
                      "rawValue": "None"
                    },
                    "featureUnits": null,
                    "featureUnitsPlural": null,
                    "displayName": "Analytics",
                    "description": null,
                    "refId": "feature-04-analytics",
                    "additionalMetaData": null
                  }
                }
              }
            ],
            "inheritedEntitlements": [],
            "compatibleAddons": [
              {
                "__typename": "Addon",
                "addonFragment": {
                  "id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
                  "refId": "addon-10-campaigns",
                  "billingId": "prod_P30kizGUa6097e",
                  "displayName": "10 campaigns",
                  "description": "Additional quota of 10 campaigns",
                  "additionalMetaData": null,
                  "entitlements": [
                    {
                      "__typename": "PackageEntitlement",
                      "packageEntitlementFragment": {
                        "usageLimit": 10,
                        "hasUnlimitedUsage": null,
                        "featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
                        "resetPeriod": {
                          "rawValue": "MONTH"
                        },
                        "hiddenFromWidgets": [],
                        "isCustom": null,
                        "displayNameOverride": null,
                        "feature": {
                          "featureType": {
                            "rawValue": "NUMBER"
                          },
                          "meterType": {
                            "rawValue": "Incremental"
                          },
                          "featureUnits": "campaign",
                          "featureUnitsPlural": "campaigns",
                          "displayName": "Campaigns",
                          "description": null,
                          "refId": "feature-02-campaigns",
                          "additionalMetaData": null
                        }
                      }
                    }
                  ],
                  "prices": [
                    {
                      "__typename": "Price",
                      "priceFragment": {
                        "billingModel": {
                          "rawValue": "FLAT_FEE"
                        },
                        "billingPeriod": {
                          "rawValue": "MONTHLY"
                        },
                        "billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
                        "minUnitQuantity": null,
                        "maxUnitQuantity": null,
                        "billingCountryCode": null,
                        "price": {
                          "amount": 5,
                          "currency": {
                            "rawValue": "USD"
                          }
                        },
                        "tiersMode": null,
                        "tiers": null,
                        "feature": null
                      }
                    },
                    {
                      "__typename": "Price",
                      "priceFragment": {
                        "billingModel": {
                          "rawValue": "FLAT_FEE"
                        },
                        "billingPeriod": {
                          "rawValue": "ANNUALLY"
                        },
                        "billingId": "price_1OEuizAnAO1PFouUulgWldtN",
                        "minUnitQuantity": null,
                        "maxUnitQuantity": null,
                        "billingCountryCode": null,
                        "price": {
                          "amount": 54,
                          "currency": {
                            "rawValue": "USD"
                          }
                        },
                        "tiersMode": null,
                        "tiers": null,
                        "feature": null
                      }
                    }
                  ],
                  "pricingType": {
                    "rawValue": "PAID"
                  }
                }
              }
            ],
            "prices": [
              {
                "__typename": "Price",
                "priceFragment": {
                  "billingModel": {
                    "rawValue": "PER_UNIT"
                  },
                  "billingPeriod": {
                    "rawValue": "ANNUALLY"
                  },
                  "billingId": "price_1OEuj0AnAO1PFouUlmmaUgsh",
                  "minUnitQuantity": 5,
                  "maxUnitQuantity": null,
                  "billingCountryCode": null,
                  "price": {
                    "amount": 60,
                    "currency": {
                      "rawValue": "USD"
                    }
                  },
                  "tiersMode": null,
                  "tiers": null,
                  "feature": {
                    "refId": "feature-01-templates",
                    "featureUnits": "template",
                    "featureUnitsPlural": "templates",
                    "displayName": "Templates",
                    "description": null
                  }
                }
              },
              {
                "__typename": "Price",
                "priceFragment": {
                  "billingModel": {
                    "rawValue": "PER_UNIT"
                  },
                  "billingPeriod": {
                    "rawValue": "MONTHLY"
                  },
                  "billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
                  "minUnitQuantity": 5,
                  "maxUnitQuantity": null,
                  "billingCountryCode": null,
                  "price": {
                    "amount": 6,
                    "currency": {
                      "rawValue": "USD"
                    }
                  },
                  "tiersMode": null,
                  "tiers": null,
                  "feature": {
                    "refId": "feature-01-templates",
                    "featureUnits": "template",
                    "featureUnitsPlural": "templates",
                    "displayName": "Templates",
                    "description": null
                  }
                }
              }
            ],
            "pricingType": {
              "rawValue": "PAID"
            },
            "defaultTrialConfig": null
          }
        },
        "addons": [
          {
            "id": "0a86b7b0-b85f-479f-abf9-e7e1167c251d",
            "quantity": 2,
            "addon": {
              "__typename": "Addon",
              "addonFragment": {
                "id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
                "refId": "addon-10-campaigns",
                "billingId": "prod_P30kizGUa6097e",
                "displayName": "10 campaigns",
                "description": "Additional quota of 10 campaigns",
                "additionalMetaData": null,
                "entitlements": [
                  {
                    "__typename": "PackageEntitlement",
                    "packageEntitlementFragment": {
                      "usageLimit": 10,
                      "hasUnlimitedUsage": null,
                      "featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
                      "resetPeriod": {
                        "rawValue": "MONTH"
                      },
                      "hiddenFromWidgets": [],
                      "isCustom": null,
                      "displayNameOverride": null,
                      "feature": {
                        "featureType": {
                          "rawValue": "NUMBER"
                        },
                        "meterType": {
                          "rawValue": "Incremental"
                        },
                        "featureUnits": "campaign",
                        "featureUnitsPlural": "campaigns",
                        "displayName": "Campaigns",
                        "description": null,
                        "refId": "feature-02-campaigns",
                        "additionalMetaData": null
                      }
                    }
                  }
                ],
                "prices": [
                  {
                    "__typename": "Price",
                    "priceFragment": {
                      "billingModel": {
                        "rawValue": "FLAT_FEE"
                      },
                      "billingPeriod": {
                        "rawValue": "MONTHLY"
                      },
                      "billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
                      "minUnitQuantity": null,
                      "maxUnitQuantity": null,
                      "billingCountryCode": null,
                      "price": {
                        "amount": 5,
                        "currency": {
                          "rawValue": "USD"
                        }
                      },
                      "tiersMode": null,
                      "tiers": null,
                      "feature": null
                    }
                  },
                  {
                    "__typename": "Price",
                    "priceFragment": {
                      "billingModel": {
                        "rawValue": "FLAT_FEE"
                      },
                      "billingPeriod": {
                        "rawValue": "ANNUALLY"
                      },
                      "billingId": "price_1OEuizAnAO1PFouUulgWldtN",
                      "minUnitQuantity": null,
                      "maxUnitQuantity": null,
                      "billingCountryCode": null,
                      "price": {
                        "amount": 54,
                        "currency": {
                          "rawValue": "USD"
                        }
                      },
                      "tiersMode": null,
                      "tiers": null,
                      "feature": null
                    }
                  }
                ],
                "pricingType": {
                  "rawValue": "PAID"
                }
              }
            }
          }
        ],
        "scheduledUpdates": [],
        "futureUpdates": []
      }
    }
  }
  ```
</Expandable>

# Provision 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.

<CodeGroup>
  ```c# ProvisionSubscription.cs theme={null}
  var res = await stigg.ProvisionSubscription.ExecuteAsync(new ProvisionSubscriptionInput()
  {
    CustomerId = "customer-demo-01",
    PlanId = "plan-revvenu-essentials",
    BillingPeriod = BillingPeriod.Monthly,
    BillableFeatures = new List<BillableFeatureInput>()
    {
      new()
      {
        FeatureId = "feature-01-templates",
        Quantity = 5
      }
    },
    Addons = new List<SubscriptionAddonInput>()
    {
      new()
      {
        AddonId = "addon-extra-stuff",
        Quantity = 5
      }
    },
    // Optional, entitlements for custom plans (feature + credit)
    Entitlements = new List<SubscriptionEntitlementInputV2>()
    {
      new()
      {
        Feature = new SubscriptionFeatureEntitlementInput()
        {
          FeatureId = "feature-seats",
          UsageLimit = 50
        }
      },
      new()
      {
        Credit = new SubscriptionCreditEntitlementInput()
        {
          CustomCurrencyId = "currency-api-credits",
          Amount = 50000,
          Cadence = CreditCadence.Month
        }
      }
    },
  });
  ```
</CodeGroup>

<Expandable title="Result - Success">
  ```json theme={null}
  {
    "provisionSubscription": {
      "checkoutUrl": null,
      "status": {
        "rawValue": "SUCCESS"
      },
      "subscription": {
        "__typename": "CustomerSubscription",
        "slimSubscriptionFragment": {
          "id": "bad12052-32f1-4590-9230-911298c2d21b",
          "refId": "subscription-plan-revvenu-essentials-bum2flivze",
          "status": {
            "rawValue": "ACTIVE"
          },
          "additionalMetaData": {
            "key": "value"
          },
          "billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
          "billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
          "effectiveEndDate": null,
          "currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
          "pricingType": {
            "rawValue": "PAID"
          },
          "latestInvoice": {
            "__typename": "SubscriptionInvoice",
            "subscriptionInvoiceFragment": {
              "billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
              "status": {
                "rawValue": "PAID"
              },
              "createdAt": "2023-11-21T16:52:09.000Z",
              "updatedAt": "2023-11-21T16:52:58.491Z",
              "requiresAction": false,
              "paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc40200A5QhGfKJ?s=ap",
              "paymentSecret": null,
              "errorMessage": null
            }
          },
          "paymentCollection": {
            "rawValue": "NOT_REQUIRED"
          },
          "billingSyncError": null,
          "resource": null,
          "experimentInfo": null,
          "prices": [
            {
              "usageLimit": 5,
              "price": {
                "__typename": "Price",
                "priceFragment": {
                  "billingModel": {
                    "rawValue": "PER_UNIT"
                  },
                  "billingPeriod": {
                    "rawValue": "MONTHLY"
                  },
                  "billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
                  "minUnitQuantity": 5,
                  "maxUnitQuantity": null,
                  "billingCountryCode": null,
                  "price": {
                    "amount": 6,
                    "currency": {
                      "rawValue": "USD"
                    }
                  },
                  "tiersMode": null,
                  "tiers": null,
                  "feature": {
                    "refId": "feature-01-templates",
                    "featureUnits": "template",
                    "featureUnitsPlural": "templates",
                    "displayName": "Templates",
                    "description": null
                  }
                }
              }
            }
          ],
          "totalPrice": {
            "__typename": "CustomerSubscriptionTotalPrice",
            "totalPriceFragment": {
              "subTotal": {
                "amount": 30,
                "currency": {
                  "rawValue": "USD"
                }
              },
              "total": {
                "amount": 30,
                "currency": {
                  "rawValue": "USD"
                }
              }
            }
          },
          "plan": {
            "id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
            "refId": "plan-revvenu-essentials"
          },
          "addons": [],
          "customer": {
            "id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
            "refId": "customer-demo-01"
          }
        }
      }
    }
  }
  ```
</Expandable>

<Expandable title="Result - Action required (3DS)">
  ```json theme={null}
  {
    "provision_subscription": {
      "subscription": {
        "paymentCollection": { 
          "rawValue": "ACTION_REQUIRED" 
        },
        "latestInvoice": {
          "paymentUrl": "https...",
          "paymentSecret": "secret",
        }
      }
    }
  }
  ```
</Expandable>

<Expandable title="Result - Payment failed">
  ```json theme={null}
  {
    "provisionSubscription": {
      "subscription": {
        "paymentCollection": {
          "rawValue": "FAILED"
        },      
        "latestInvoice": {
          "paymentUrl": "https...",
          "errorMessage": "no sufficient funds"
        }
      }
    }
  }
  ```
</Expandable>

<Expandable title="Result - Checkout">
  ```json theme={null}
  {
    "provisionSubscription": {
      "checkoutUrl": "https://checkout.stripe.com/c/pay/cs_test_b1PKYNIzXFR3uejdj59M0BghDF4mNtL2MoHf6vipEpREAJPQ7zhR6rlJQG#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3Zxd2x1YERmZmpwa3EnPydkZmZxWjROfUFIcURrREo0VUNqcFAnKSdkdWxOYHwnPyd1blpxYHZxWjA0TnZpVjZCX11oMk9QUzxWcEpPRzN8cTZQXDZSSDRwcGRpQ3BiZ0w8NDY9PFZiX2REa0tHZzJDdXBHTD1caEN%2FQ3doS21Abn00REhDUH12cW50fW9rcHJ0NTVwVTxpdEFsMicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl",
      "status": {
        "rawValue": "PAYMENT_REQUIRED"
      },
      "subscription": null
    }
  }
  ```
</Expandable>

<Warning>
  1. A customer can have both a non-trial (free or paid) subscription and trial subscription to different plans of the same product in parallel - this logic allows customers to trial a higher tier plan, while still paying for an existing plan.
  2. When the customer has a trial subscription for plan X of product A and a new subscription is created for the same plan, the new subscription will be created as as non-trial (paid) subscription - this logic follows an upgrade flow of a trial subscription to a paid subscription of a specific plan.
  3. Except in the above mentioned cases, when a customer has an active subscription for product X, and another subscription for the same product is created with start date S, the existing subscription will automatically be cancelled and the new subscription will start on start date S.
  4. It's also possible to explicitly skip the trial period of the selected plan by providing the `skipTrial: true` parameter to the `provisionSubscription()` method.
</Warning>

# 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.

<CodeGroup>
  ```c# UpdateSubscription.cs theme={null}
  var res = await stigg.UpdateSubscription.ExecuteAsync(new UpdateSubscriptionInput()
  {
    SubscriptionId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
    BillableFeatures = new List<BillableFeatureInput>()
    {
      new()
      {
        FeatureId = "feature-01-templates",
        Quantity = 7
      }
    },
    Addons = new List<SubscriptionAddonInput>()
    {
      new()
      {
        AddonId = "addon-extra-stuff",
        Quantity = 5
      }
    },
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "updateSubscription": {
      "__typename": "CustomerSubscription",
      "slimSubscriptionFragment": {
        "id": "bad12052-32f1-4590-9230-911298c2d21b",
        "refId": "subscription-plan-revvenu-essentials-bum2flivze",
        "status": {
          "rawValue": "ACTIVE"
        },
        "additionalMetaData": {
          "key": "value"
        },
        "billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
        "billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
        "effectiveEndDate": null,
        "currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
        "pricingType": {
          "rawValue": "PAID"
        },
        "latestInvoice": {
          "__typename": "SubscriptionInvoice",
          "subscriptionInvoiceFragment": {
            "billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
            "status": {
              "rawValue": "PAID"
            },
            "createdAt": "2023-11-21T16:52:09.000Z",
            "updatedAt": "2023-11-21T16:52:59.336Z",
            "requiresAction": false,
            "paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc50200GdQT8sqx?s=ap",
            "paymentSecret": null,
            "errorMessage": null
          }
        },
        "paymentCollection": {
          "rawValue": "NOT_REQUIRED"
        },
        "billingSyncError": null,
        "resource": null,
        "experimentInfo": null,
        "prices": [
          {
            "usageLimit": 5,
            "price": {
              "__typename": "Price",
              "priceFragment": {
                "billingModel": {
                  "rawValue": "PER_UNIT"
                },
                "billingPeriod": {
                  "rawValue": "MONTHLY"
                },
                "billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
                "minUnitQuantity": 5,
                "maxUnitQuantity": null,
                "billingCountryCode": null,
                "price": {
                  "amount": 6,
                  "currency": {
                    "rawValue": "USD"
                  }
                },
                "tiersMode": null,
                "tiers": null,
                "feature": {
                  "refId": "feature-01-templates",
                  "featureUnits": "template",
                  "featureUnitsPlural": "templates",
                  "displayName": "Templates",
                  "description": null
                }
              }
            }
          }
        ],
        "totalPrice": {
          "__typename": "CustomerSubscriptionTotalPrice",
          "totalPriceFragment": {
            "subTotal": {
              "amount": 30,
              "currency": {
                "rawValue": "USD"
              }
            },
            "total": {
              "amount": 30,
              "currency": {
                "rawValue": "USD"
              }
            }
          }
        },
        "plan": {
          "id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
          "refId": "plan-revvenu-essentials"
        },
        "addons": [],
        "customer": {
          "id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
          "refId": "customer-demo-01"
        }
      }
    }
  }
  ```
</Expandable>

# Cancel subscription

<CodeGroup>
  ```c# CancelSubscription.cs theme={null}
  var res = await stigg.CancelSubscription.ExecuteAsync(new SubscriptionCancellationInput()
  {
    SubscriptionRefId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
    SubscriptionCancellationTime = SubscriptionCancellationTime.END_OF_BILLING_PERIOD, // optional
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
      "cancel_subscription": {
          "id": "subscription-plan-revvenu-growth-589879",
          "status": "CANCELED",
          "metadata": null,
          "billing_id": "sub_1LxD4TE1gVT2zwZVSav7tZvC",
          "billing_link_url": "https:\/\/dashboard.stripe.com\/test\/subscriptions\/sub_1LxD4TE1gVT2zwZVSav7tZvC",
          "effective_end_date": "2022-10-30T23:54:38.582Z",
          "current_billing_period_end": "2022-11-26T17:07:17.000Z",
          "pricing_type": "PAID",
          "prices": [
              {
                  "usage_limit": 2,
                  "price": {
                      "__typename": "Price",
                      "billing_model": "PER_UNIT",
                      "billing_period": "MONTHLY",
                      "price": {
                          "amount": 1,
                          "currency": "USD"
                      },
                      "feature": {
                          "__typename": "Feature",
                          "id": "feature-01-templates",
                          "feature_type": "NUMBER",
                          "meter_type": "Fluctuating",
                          "feature_units": "template",
                          "feature_units_plural": "templates",
                          "display_name": "Templates",
                          "description": null
                      }
                  }
              }
          ],
          "total_price": {
              "sub_total": {
                  "amount": 17,
                  "currency": "USD"
              },
              "total": {
                  "amount": 17,
                  "currency": "USD"
              }
          },
          "plan": {
              "id": "plan-revvenu-growth"
          },
          "addons": [
              {
                  "quantity": 3,
                  "addon": {
                      "id": "addon-10-campaigns"
                  }
              }
          ],
          "customer": {
              "id": "customer-demo-01"
          }
      }
  }
  ```
</Expandable>

<Warning>
  Subscription cancellation will take place according to the defined product behavior.
</Warning>

# 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.

<CodeGroup>
  ```c# GetEntitlement.cs theme={null}
  var resp = await stigg.GetEntitlement.ExecuteAsync(new FetchEntitlementQuery()
  {
    CustomerId = "customer-demo-01",
    FeatureId = "feature-02-templates",
    ResourceId = "site-1" // optional
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "entitlement": {
      "__typename": "Entitlement",
      "entitlementFragment": {
        "isGranted": false,
        "accessDeniedReason": {
          "rawValue": "RequestedUsageExceedingLimit"
        },
        "customerId": null,
        "resourceId": null,
        "usageLimit": 5,
        "hasUnlimitedUsage": false,
        "currentUsage": 3,
        "requestedUsage": 10,
        "entitlementUpdatedAt": null,
        "usageUpdatedAt": null,
        "usagePeriodAnchor": null,
        "usagePeriodStart": null,
        "usagePeriodEnd": null,
        "resetPeriod": null,
        "resetPeriodConfiguration": null,
        "feature": {
          "__typename": "EntitlementFeature",
          "featureFragment": {
            "featureType": {
              "rawValue": "NUMBER"
            },
            "meterType": {
              "rawValue": "Fluctuating"
            },
            "featureUnits": "template",
            "featureUnitsPlural": "templates",
            "description": null,
            "displayName": "Templates",
            "refId": "feature-01-templates"
          }
        }
      }
    }
  }
  ```
</Expandable>

# 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.

<CodeGroup>
  ```c# GetEntitlements.cs theme={null}
  var resp = await stigg.GetEntitlementsState.ExecuteAsync(new FetchEntitlementsQuery()
  {
    CustomerId = "customer-demo-01",
    ResourceId = "site-1" // optional resource ID
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "entitlementsState": {
      "entitlements": [
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": null,
            "hasUnlimitedUsage": false,
            "currentUsage": null,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": null,
            "usagePeriodAnchor": null,
            "usagePeriodStart": null,
            "usagePeriodEnd": null,
            "resetPeriod": null,
            "resetPeriodConfiguration": null,
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "BOOLEAN"
                },
                "meterType": {
                  "rawValue": "None"
                },
                "featureUnits": null,
                "featureUnitsPlural": null,
                "description": null,
                "displayName": "Analytics",
                "refId": "feature-04-analytics"
              }
            }
          }
        },
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": 100,
            "hasUnlimitedUsage": false,
            "currentUsage": null,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": null,
            "usagePeriodAnchor": null,
            "usagePeriodStart": null,
            "usagePeriodEnd": null,
            "resetPeriod": null,
            "resetPeriodConfiguration": null,
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "NUMBER"
                },
                "meterType": {
                  "rawValue": "None"
                },
                "featureUnits": "MB",
                "featureUnitsPlural": "MB",
                "description": null,
                "displayName": "Max file size",
                "refId": "feature-06-max-file-size"
              }
            }
          }
        },
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": 25000,
            "hasUnlimitedUsage": false,
            "currentUsage": 0,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": 1700595037.13,
            "usagePeriodAnchor": 1703116800,
            "usagePeriodStart": 1703116800,
            "usagePeriodEnd": 1700568000,
            "resetPeriod": {
              "rawValue": "MONTH"
            },
            "resetPeriodConfiguration": {
              "__typename": "MonthlyResetPeriodConfig",
              "resetPeriodConfigurationFragment": {
                "__typename": "MonthlyResetPeriodConfig",
                "onMonthlyResetPeriodConfig": {
                  "monthlyAccordingTo": {
                    "rawValue": "SubscriptionStart"
                  }
                },
                "onWeeklyResetPeriodConfig": null
              }
            },
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "NUMBER"
                },
                "meterType": {
                  "rawValue": "Incremental"
                },
                "featureUnits": "active user",
                "featureUnitsPlural": "active users",
                "description": null,
                "displayName": "Active users",
                "refId": "feature-07-active-users"
              }
            }
          }
        },
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": 12,
            "hasUnlimitedUsage": false,
            "currentUsage": 0,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": 1700595037.13,
            "usagePeriodAnchor": 1703116800,
            "usagePeriodStart": 1703116800,
            "usagePeriodEnd": 1700568000,
            "resetPeriod": {
              "rawValue": "MONTH"
            },
            "resetPeriodConfiguration": {
              "__typename": "MonthlyResetPeriodConfig",
              "resetPeriodConfigurationFragment": {
                "__typename": "MonthlyResetPeriodConfig",
                "onMonthlyResetPeriodConfig": {
                  "monthlyAccordingTo": {
                    "rawValue": "SubscriptionStart"
                  }
                },
                "onWeeklyResetPeriodConfig": null
              }
            },
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "NUMBER"
                },
                "meterType": {
                  "rawValue": "Incremental"
                },
                "featureUnits": "campaign",
                "featureUnitsPlural": "campaigns",
                "description": null,
                "displayName": "Campaigns",
                "refId": "feature-02-campaigns"
              }
            }
          }
        },
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": 5,
            "hasUnlimitedUsage": false,
            "currentUsage": 3,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": 1700594586.26,
            "usagePeriodAnchor": null,
            "usagePeriodStart": null,
            "usagePeriodEnd": null,
            "resetPeriod": null,
            "resetPeriodConfiguration": null,
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "NUMBER"
                },
                "meterType": {
                  "rawValue": "Fluctuating"
                },
                "featureUnits": "template",
                "featureUnitsPlural": "templates",
                "description": null,
                "displayName": "Templates",
                "refId": "feature-01-templates"
              }
            }
          }
        },
        {
          "__typename": "Entitlement",
          "entitlementFragment": {
            "isGranted": true,
            "accessDeniedReason": null,
            "customerId": null,
            "resourceId": null,
            "usageLimit": null,
            "hasUnlimitedUsage": false,
            "currentUsage": null,
            "requestedUsage": null,
            "entitlementUpdatedAt": null,
            "usageUpdatedAt": null,
            "usagePeriodAnchor": null,
            "usagePeriodStart": null,
            "usagePeriodEnd": null,
            "resetPeriod": null,
            "resetPeriodConfiguration": null,
            "feature": {
              "__typename": "EntitlementFeature",
              "featureFragment": {
                "featureType": {
                  "rawValue": "BOOLEAN"
                },
                "meterType": {
                  "rawValue": "None"
                },
                "featureUnits": null,
                "featureUnitsPlural": null,
                "description": null,
                "displayName": "Custom domain",
                "refId": "feature-03-custom-domain"
              }
            }
          }
        }
      ]
    },
    "accessDeniedReason": null
  }
  ```
</Expandable>

# Getting paywall data

Useful for rendering the public pricing page or customer paywall.

```c# GetPaywall.cs theme={null}
var resp = await stigg.GetPaywall.ExecuteAsync(new GetPaywallInput()
        {
			// optional, filters by product
            ProductId = "product-revvenu",
 			// optional, omit if customer doesn't exist yet
            CustomerId = "customer-demo-01",
			// optional
            ResourceId = "resource-01",
            // optional, for localized prices
            BillingCountryCode = "US",
            // optional, fetches all countries prices
            FetchAllCountriesPrices = false
        });
```

<Expandable title="Result">
  ```json theme={null}
  {
  "Paywall": {
    "Plans": [
      {
        "Id": "33964e83-8dab-4931-86ad-1e77fde63497",
        "RefId": "plan-revvenu-basic",
        "DisplayName": "Basic",
        "Description": null,
        "BillingId": "prod_SZLLC24CGnWh2x",
        "VersionNumber": 1,
        "AdditionalMetaData": null,
        "HiddenFromWidgets": [],
        "Product": {
          "RefId": "product-revvenu",
          "DisplayName": "Revvenu",
          "Description": null,
          "AdditionalMetaData": {
            "ValueKind": 1
          },
          "ProductSettings": {
            "DowngradePlan": null
          }
        },
        "BasePlan": null,
        "Entitlements": [
          {
            "UsageLimit": 3.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "3cec589c-3125-4fd6-ae0d-180ad15e9c3c",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 0,
              "FeatureUnits": "template",
              "FeatureUnitsPlural": "templates",
              "DisplayName": "Templates",
              "Description": null,
              "RefId": "feature-01-templates",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": 4.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "8fa3c1cd-a508-4f90-9d33-b365a65bede3",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "campaign",
              "FeatureUnitsPlural": "campaigns",
              "DisplayName": "Campaigns",
              "Description": null,
              "RefId": "feature-02-campaigns",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": 1000.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "cd79fb17-71ea-4a06-8cb7-de22e47d7eca",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "active user",
              "FeatureUnitsPlural": "active users",
              "DisplayName": "Active users",
              "Description": null,
              "RefId": "feature-07-active-users",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": 5.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "309e12c4-5c6c-4309-a5b6-d812ba42f3a4",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": "5MB file size limit",
            "Feature": {
              "FeatureType": 2,
              "MeterType": 2,
              "FeatureUnits": "MB",
              "FeatureUnitsPlural": "MB",
              "DisplayName": "Max file size",
              "Description": null,
              "RefId": "feature-06-max-file-size",
              "AdditionalMetaData": null
            }
          }
        ],
        "InheritedEntitlements": [],
        "CompatibleAddons": [],
        "CompatiblePackageGroups": [],
        "Prices": [],
        "OveragePrices": [],
        "PricingType": 1,
        "DefaultTrialConfig": null
      },
      {
        "Id": "9f8295c7-c4d9-4afb-aa94-79ecda2eca7e",
        "RefId": "plan-revvenu-essentials",
        "DisplayName": "Essentials",
        "Description": null,
        "BillingId": "prod_SZLLJUmFx9Uzy9",
        "VersionNumber": 1,
        "AdditionalMetaData": null,
        "HiddenFromWidgets": [],
        "Product": {
          "RefId": "product-revvenu",
          "DisplayName": "Revvenu",
          "Description": null,
          "AdditionalMetaData": {
            "ValueKind": 1
          },
          "ProductSettings": {
            "DowngradePlan": null
          }
        },
        "BasePlan": {
          "RefId": "plan-revvenu-basic",
          "DisplayName": "Basic"
        },
        "Entitlements": [
          {
            "UsageLimit": 12.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "8fa3c1cd-a508-4f90-9d33-b365a65bede3",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "campaign",
              "FeatureUnitsPlural": "campaigns",
              "DisplayName": "Campaigns",
              "Description": null,
              "RefId": "feature-02-campaigns",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": 25000.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "cd79fb17-71ea-4a06-8cb7-de22e47d7eca",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "active user",
              "FeatureUnitsPlural": "active users",
              "DisplayName": "Active users",
              "Description": null,
              "RefId": "feature-07-active-users",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": 100.0,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "309e12c4-5c6c-4309-a5b6-d812ba42f3a4",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": "100MB file size limit",
            "Feature": {
              "FeatureType": 2,
              "MeterType": 2,
              "FeatureUnits": "MB",
              "FeatureUnitsPlural": "MB",
              "DisplayName": "Max file size",
              "Description": null,
              "RefId": "feature-06-max-file-size",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "6eeb634b-6034-4d1a-a941-bc12f1740d61",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 0,
              "MeterType": 2,
              "FeatureUnits": null,
              "FeatureUnitsPlural": null,
              "DisplayName": "Analytics",
              "Description": null,
              "RefId": "feature-04-analytics",
              "AdditionalMetaData": null
            }
          }
        ],
        "InheritedEntitlements": [],
        "CompatibleAddons": [
          {
            "Id": "91bf33e5-3bb1-404a-9c47-bab0b108f836",
            "RefId": "addon-10-campaigns",
            "BillingId": "prod_SZLLOxIizytcBM",
            "DisplayName": "10 campaigns",
            "Description": "Additional quota of 10 campaigns",
            "AdditionalMetaData": null,
            "HiddenFromWidgets": [],
            "Entitlements": [
              {
                "UsageLimit": 10.0,
                "HasUnlimitedUsage": null,
                "HasSoftLimit": false,
                "FeatureId": "8fa3c1cd-a508-4f90-9d33-b365a65bede3",
                "ResetPeriod": 2,
                "HiddenFromWidgets": [],
                "IsCustom": null,
                "DisplayNameOverride": null,
                "Feature": {
                  "FeatureType": 2,
                  "MeterType": 1,
                  "FeatureUnits": "campaign",
                  "FeatureUnitsPlural": "campaigns",
                  "DisplayName": "Campaigns",
                  "Description": null,
                  "RefId": "feature-02-campaigns",
                  "AdditionalMetaData": null
                }
              }
            ],
            "Prices": [
              {
                "BillingModel": 0,
                "BillingPeriod": 1,
                "BillingCadence": 1,
                "BillingId": "price_1ReCerAnAO1PFouU8KR8DUCP",
                "MinUnitQuantity": null,
                "MaxUnitQuantity": null,
                "BillingCountryCode": null,
                "Price": {
                  "Amount": 5.0,
                  "Currency": 104
                },
                "TiersMode": null,
                "Tiers": null,
                "Feature": null,
                "BlockSize": null
              },
              {
                "BillingModel": 0,
                "BillingPeriod": 0,
                "BillingCadence": 1,
                "BillingId": "price_1ReCerAnAO1PFouUHwJ9wrDz",
                "MinUnitQuantity": null,
                "MaxUnitQuantity": null,
                "BillingCountryCode": null,
                "Price": {
                  "Amount": 54.0,
                  "Currency": 104
                },
                "TiersMode": null,
                "Tiers": null,
                "Feature": null,
                "BlockSize": null
              }
            ],
            "OveragePrices": [],
            "PricingType": 2,
            "MaxQuantity": null,
            "Dependencies": []
          }
        ],
        "CompatiblePackageGroups": [],
        "Prices": [
          {
            "BillingModel": 2,
            "BillingPeriod": 1,
            "BillingCadence": 1,
            "BillingId": "price_1ReCetAnAO1PFouUX6fhG6BT",
            "MinUnitQuantity": 5.0,
            "MaxUnitQuantity": null,
            "BillingCountryCode": null,
            "Price": {
              "Amount": 6.0,
              "Currency": 104
            },
            "TiersMode": null,
            "Tiers": null,
            "Feature": {
              "RefId": "feature-01-templates",
              "FeatureUnits": "template",
              "FeatureUnitsPlural": "templates",
              "DisplayName": "Templates",
              "Description": null
            },
            "BlockSize": null
          },
          {
            "BillingModel": 2,
            "BillingPeriod": 0,
            "BillingCadence": 1,
            "BillingId": "price_1ReCetAnAO1PFouUVmwSjaeg",
            "MinUnitQuantity": 5.0,
            "MaxUnitQuantity": null,
            "BillingCountryCode": null,
            "Price": {
              "Amount": 60.0,
              "Currency": 104
            },
            "TiersMode": null,
            "Tiers": null,
            "Feature": {
              "RefId": "feature-01-templates",
              "FeatureUnits": "template",
              "FeatureUnitsPlural": "templates",
              "DisplayName": "Templates",
              "Description": null
            },
            "BlockSize": null
          }
        ],
        "OveragePrices": [],
        "PricingType": 2,
        "DefaultTrialConfig": null
      },
      {
        "Id": "dd4d4296-bf87-4be4-a57b-0b7f1570ba67",
        "RefId": "plan-revvenu-pro",
        "DisplayName": "Professional",
        "Description": null,
        "BillingId": "prod_SZLLOz925T2MM9",
        "VersionNumber": 1,
        "AdditionalMetaData": null,
        "HiddenFromWidgets": [],
        "Product": {
          "RefId": "product-revvenu",
          "DisplayName": "Revvenu",
          "Description": null,
          "AdditionalMetaData": {
            "ValueKind": 1
          },
          "ProductSettings": {
            "DowngradePlan": null
          }
        },
        "BasePlan": {
          "RefId": "plan-revvenu-essentials",
          "DisplayName": "Essentials"
        },
        "Entitlements": [
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "3cec589c-3125-4fd6-ae0d-180ad15e9c3c",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": true,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 0,
              "FeatureUnits": "template",
              "FeatureUnitsPlural": "templates",
              "DisplayName": "Templates",
              "Description": null,
              "RefId": "feature-01-templates",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "8fa3c1cd-a508-4f90-9d33-b365a65bede3",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": true,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "campaign",
              "FeatureUnitsPlural": "campaigns",
              "DisplayName": "Campaigns",
              "Description": null,
              "RefId": "feature-02-campaigns",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "cd79fb17-71ea-4a06-8cb7-de22e47d7eca",
            "ResetPeriod": 2,
            "HiddenFromWidgets": [],
            "IsCustom": true,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 2,
              "MeterType": 1,
              "FeatureUnits": "active user",
              "FeatureUnitsPlural": "active users",
              "DisplayName": "Active users",
              "Description": null,
              "RefId": "feature-07-active-users",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": true,
            "HasSoftLimit": false,
            "FeatureId": "309e12c4-5c6c-4309-a5b6-d812ba42f3a4",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": "No file size limit",
            "Feature": {
              "FeatureType": 2,
              "MeterType": 2,
              "FeatureUnits": "MB",
              "FeatureUnitsPlural": "MB",
              "DisplayName": "Max file size",
              "Description": null,
              "RefId": "feature-06-max-file-size",
              "AdditionalMetaData": null
            }
          },
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "db8a4fc5-045a-4767-800f-a5b389acc1ac",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 0,
              "MeterType": 2,
              "FeatureUnits": null,
              "FeatureUnitsPlural": null,
              "DisplayName": "Integrations",
              "Description": null,
              "RefId": "feature-05-integrations",
              "AdditionalMetaData": null
            }
          }
        ],
        "InheritedEntitlements": [
          {
            "UsageLimit": null,
            "HasUnlimitedUsage": null,
            "HasSoftLimit": false,
            "FeatureId": "6eeb634b-6034-4d1a-a941-bc12f1740d61",
            "ResetPeriod": null,
            "HiddenFromWidgets": [],
            "IsCustom": null,
            "DisplayNameOverride": null,
            "Feature": {
              "FeatureType": 0,
              "MeterType": 2,
              "FeatureUnits": null,
              "FeatureUnitsPlural": null,
              "DisplayName": "Analytics",
              "Description": null,
              "RefId": "feature-04-analytics",
              "AdditionalMetaData": null
            }
          }
        ],
        "CompatibleAddons": [],
        "CompatiblePackageGroups": [],
        "Prices": [],
        "OveragePrices": [],
        "PricingType": 0,
        "DefaultTrialConfig": null
      }
    ],
    "Currency": {
      "Code": 104,
      "Symbol": "$"
    },
    "Configuration": {
      "Palette": {
        "Primary": "#2e7d32",
        "TextColor": "#000000",
        "BackgroundColor": null,
        "BorderColor": null,
        "CurrentPlanBackground": "#f5fbf7"
      },
      "Typography": {
        "FontFamily": null,
        "H1": {
          "FontSize": 28.0,
          "FontWeight": null
        },
        "H2": {
          "FontSize": 20.0,
          "FontWeight": null
        },
        "H3": {
          "FontSize": 14.0,
          "FontWeight": null
        },
        "Body": null
      },
      "Layout": {
        "Alignment": null,
        "PlanWidth": 320.0,
        "PlanMargin": 20.0,
        "PlanPadding": 32.0
      },
      "CustomCss": null
    },
    "Customer": null,
    "ActiveSubscriptions": null,
    "Resource": null,
    "PaywallCalculatedPricePoints": [
      {
        "PlanId": "plan-revvenu-essentials",
        "AdditionalChargesMayApply": true,
        "BillingPeriod": 1,
        "Amount": 6.0,
        "Currency": 104,
        "BillingCountryCode": null,
        "Feature": null
      },
      {
        "PlanId": "plan-revvenu-essentials",
        "AdditionalChargesMayApply": true,
        "BillingPeriod": 0,
        "Amount": 60.0,
        "Currency": 104,
        "BillingCountryCode": null,
        "Feature": null
      }
    ]
  }
  }

  ```
</Expandable>

# Get products

<CodeGroup>
  ```c# GetProducts.cs theme={null}
  var resp = await stigg.GetProducts.ExecuteAsync();
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
  "Products": {
    "Edges": [
      {
        "Node": {
          "RefId": "product-revvenu",
          "DisplayName": "Revvenu",
          "Description": null,
          "AdditionalMetaData": {
            "ValueKind": 1
          },
          "ProductSettings": {
            "DowngradePlan": null
          }
        }
      }
    ]
  }
  }
  ```
</Expandable>

# Reporting usage measurements to Stigg

The Stigg SDK allows you to report usage measurements for [metered features](/documentation/modeling-your-pricing-in-stigg/features/overview). 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:

1. [Calculated usage](#calculated-usage) - usage that has been aggregated and calculated by **your application**. This type is useful for features, such as: seats.
2. [Raw events](#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:

<Card title="Stigg's metering and aggregation capabilities" icon="gauge" href="/documentation/getting-usage-data-into-stigg/overview" />

<Warning>
  1. Reporting of measurements to Stigg should be done only after the relevant resources have been provisioned in your application.
  2. To ensure that the provisioned resources are aligned with the measurements that are reported to Stigg, ensure that customers are not allowed to allocate new resources until an acknowledgement about the processed measurement is received from the Stigg backend.
</Warning>

<Note>
  Validating that a measurement was successfully reported to Stigg is also possible in the [customer details section](/documentation/managing-customers-and-subscriptions/customers/viewing-customers-entitlement-usage) of the relevant customer in the Stigg app.
</Note>

### Calculated usage

<CodeGroup>
  ```c# ReportUsage.cs theme={null}
  var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
  {
    CustomerId = "customer-demo-01",
    FeatureId = "feature-02-campaigns",
    ResourceId = "site-1" // optional resource ID
    Value = 1
  });
  ```
</CodeGroup>

By default, the value reported should represent the **change** in usage of the feature, for example user added 2 more seats then the report usage call should have the value of 2.

In some cases, it's more useful to set the usage to some value instead of reporting the change value, it's possible by passing the `updateBehavior` parameter:

<CodeGroup>
  ```c# ReportUsage.cs theme={null}
  var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
  {
    CustomerId = "customer-demo-01",
    FeatureId = "feature-02-campaigns",
    ResourceId = "site-1" // optional resource ID
    Value = 3
    UpdateBehavior = UsageUpdateBehavior.Set
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "reportUsage": {
      "id": "5fc41989-e624-4240-a482-c588b4255791",
      "currentUsage": 3,
      "usagePeriodEnd": 1700568000,
      "usagePeriodEnd": 1703116800,
      "timestamp": 1700595372.708
    }
  }
  ```
</Expandable>

### Raw events

<CodeGroup>
  ```c# ReportEvent.cs theme={null}
  var resp = await stigg.ReportEvent.ExecuteAsync(new UsageEventsReportInput()
  {
    UsageEvents = new List<UsageEventReportInput>()
    {
      new()
      {
        CustomerId = "customer-demo-01",
        EventName = "user_login",
        Dimensions = JsonSerializer.SerializeToElement(new { user_id = "1" }),
        IdempotencyKey = Guid.NewGuid().ToString(),
      }
    }
  });
  ```
</CodeGroup>

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.

# Getting available coupons

<CodeGroup>
  ```c# GetCoupons.cs theme={null}
  var resp = await stigg.GetCoupons.ExecuteAsync();
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "coupons": {
      "edges": [
        {
          "node": {
            "__typename": "Coupon",
            "couponFragment": {
              "id": "8fe11e1f-7dc2-4a82-b357-c1c3dc738660",
              "discountValue": 20,
              "type": {
                "rawValue": "PERCENTAGE"
              },
              "additionalMetaData": null,
              "refId": "coupon-vip",
              "name": "VIP",
              "description": null,
              "createdAt": 1700576088.148,
              "updatedAt": 1700576091.342,
              "billingId": "9zQ41isX",
              "billingLinkUrl": "https://dashboard.stripe.com/test/coupons/9zQ41isX",
              "status": {
                "rawValue": "ACTIVE"
              },
              "syncStates": [
                {
                  "vendorIdentifier": {
                    "rawValue": "STRIPE"
                  },
                  "status": {
                    "rawValue": "SUCCESS"
                  }
                }
              ],
              "customers": []
            }
          }
        }
      ]
    }
  }
  ```
</Expandable>

# Granting promotional entitlements

You can grant [promotional entitlements](/documentation/managing-customers-and-subscriptions/customers/managing-customers-promotional-entitlements) for customers using the `GrantPromotionalEntitlements` method.

<CodeGroup>
  ```c# GrantPromotionalEntitlements.cs theme={null}
  var resp = await stigg.GrantPromotionalEntitlements.ExecuteAsync(new GrantPromotionalEntitlementsInput()
  {
    CustomerId = "customer-demo-01",
    PromotionalEntitlements = new List<GrantPromotionalEntitlementInput>()
    {
      new()
      {
        FeatureId = "feature-04-analytics",
        Period = PromotionalEntitlementPeriod.Lifetime
      },
      new() 
      {
        FeatureId = "feature-02-campaigns",
        Period = PromotionalEntitlementPeriod.Custom,
        CustomEndDate = DateTime.Now.AddDays(15),
        UsageLimit = 100
      }
    }
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "grantPromotionalEntitlements": [
      {
        "__typename": "PromotionalEntitlement",
        "promotionalEntitlementFragment": {
          "status": {
            "rawValue": "Active"
          },
          "usageLimit": null,
          "featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
          "hasUnlimitedUsage": null,
          "resetPeriod": null,
          "endDate": 1703188217.659,
          "isVisible": true,
          "feature": {
            "featureType": {
              "rawValue": "BOOLEAN"
            },
            "meterType": {
              "rawValue": "None"
            },
            "featureUnits": null,
            "featureUnitsPlural": null,
            "displayName": "Analytics",
            "description": null,
            "refId": "feature-04-analytics",
            "additionalMetaData": null
          }
        }
      },
      {
        "__typename": "PromotionalEntitlement",
        "promotionalEntitlementFragment": {
          "status": {
            "rawValue": "Active"
          },
          "usageLimit": 100,
          "featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
          "hasUnlimitedUsage": null,
          "resetPeriod": null,
          "endDate": 1703188216.028,
          "isVisible": true,
          "feature": {
            "featureType": {
              "rawValue": "NUMBER"
            },
            "meterType": {
              "rawValue": "Incremental"
            },
            "featureUnits": "campaign",
            "featureUnitsPlural": "campaigns",
            "displayName": "Campaigns",
            "description": null,
            "refId": "feature-02-campaigns",
            "additionalMetaData": null
          }
        }
      }
    ]
  }
  ```
</Expandable>

# Revoking promotional entitlements

You can revoke [promotional entitlements](/documentation/managing-customers-and-subscriptions/customers/managing-customers-promotional-entitlements) from customer using the `RevokePromotionalEntitlement` method.

<CodeGroup>
  ```c# RevokePromotionalEntitlement.cs theme={null}
  await stigg.RevokePromotionalEntitlement.ExecuteAsync(new RevokePromotionalEntitlementInput()
  {
    CustomerId = "customer-demo-01",
    FeatureId = "feature-04-analytics"
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "revokePromotionalEntitlement": {
      "id": "f77c7c8c-098b-42f2-a82b-134f69241e2d"
    }
  }
  ```
</Expandable>

# Estimate subscription cost

You can estimate the subscription cost using the `EstimateSubscription` method. This can help the customer to understand the costs before paying.

<CodeGroup>
  ```c# EstimateSubscription.cs theme={null}
  var resp = await stigg.EstimateSubscription.ExecuteAsync(new EstimateSubscriptionInput()
  {
    CustomerId = "customer-demo-01",
    PlanId = "plan-revvenu-essentials",
    BillableFeatures = new List<BillableFeatureInput>()
    {
      new()
      {
        FeatureId = "feature-01-templates",
        Quantity = 5
       }
    },
    Addons = new List<SubscriptionAddonInput>()
    {
      new()
      {
        AddonId = "addon-10-campaigns",
        Quantity = 5
      }
    },
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "estimateSubscription": {
      "__typename": "SubscriptionPreview",
      "subscriptionPreviewFragment": {
        "subTotal": {
          "amount": 24.88,
          "currency": {
            "rawValue": "USD"
          }
        },
        "totalExcludingTax": {
          "amount": 24.88,
          "currency": {
            "rawValue": "USD"
          }
        },
        "total": {
          "amount": 2.89,
          "currency": {
            "rawValue": "USD"
          }
        },
        "discountAmount": null,
        "taxDetails": null,
        "tax": {
          "amount": 0,
          "currency": {
            "rawValue": "USD"
          }
        },
        "billingPeriodRange": {
          "start": 1700596892.977,
          "end": 1703188892.977
        },
        "discount": null,
        "subscription": {
          "subTotal": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "totalExcludingTax": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "total": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "tax": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          },
          "discountAmount": null,
          "taxDetails": null,
          "discount": null
        },
        "proration": {
          "prorationDate": 1700596893,
          "credit": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          },
          "debit": {
            "amount": 24.88,
            "currency": {
              "rawValue": "USD"
            }
          },
          "netAmount": {
            "amount": 24.88,
            "currency": {
              "rawValue": "USD"
            }
          }
        },
        "isPlanDowngrade": null,
        "hasScheduledUpdates": null,
        "credits": {
          "initial": {
            "amount": 21.99,
            "currency": {
              "rawValue": "USD"
            }
          },
          "used": {
            "amount": 21.99,
            "currency": {
              "rawValue": "USD"
            }
          },
          "remaining": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          }
        }
      }
    }
  }
  ```
</Expandable>

You can also estimate the cost of updating an existing subscription using the `EstimateSubscriptionUpdate` method, which also returns a breakdown of the proration amounts:

<CodeGroup>
  ```c# EstimateSubscriptionUpdate.cs theme={null}
  var resp = await stigg.EstimateSubscriptionUpdate.ExecuteAsync(new EstimateSubscriptionUpdateInput()
  {
    SubscriptionId = "subscription-plan-revvenu-essentials-bum2flivze",
    BillableFeatures = new List<BillableFeatureInput>()
    {
      new()
      {
        FeatureId = "feature-01-templates",
        Quantity = 5
      }
    },
    Addons = new List<SubscriptionAddonInput>()
    {
      new()
      {
        AddonId = "addon-10-campaigns",
        Quantity = 5
      }
    },
  });
  ```
</CodeGroup>

<Expandable title="Result">
  ```json theme={null}
  {
    "estimateSubscriptionUpdate": {
      "__typename": "SubscriptionPreview",
      "subscriptionPreviewFragment": {
        "subTotal": {
          "amount": 24.87,
          "currency": {
            "rawValue": "USD"
          }
        },
        "totalExcludingTax": {
          "amount": 24.87,
          "currency": {
            "rawValue": "USD"
          }
        },
        "total": {
          "amount": 2.8800000000000026,
          "currency": {
            "rawValue": "USD"
          }
        },
        "discountAmount": null,
        "taxDetails": null,
        "tax": {
          "amount": 0,
          "currency": {
            "rawValue": "USD"
          }
        },
        "billingPeriodRange": {
          "start": 1700583990,
          "end": 1703175990
        },
        "discount": null,
        "subscription": {
          "subTotal": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "totalExcludingTax": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "total": {
            "amount": 55,
            "currency": {
              "rawValue": "USD"
            }
          },
          "tax": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          },
          "discountAmount": null,
          "taxDetails": null,
          "discount": null
        },
        "proration": {
          "prorationDate": 1700597071,
          "credit": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          },
          "debit": {
            "amount": 24.87,
            "currency": {
              "rawValue": "USD"
            }
          },
          "netAmount": {
            "amount": 24.87,
            "currency": {
              "rawValue": "USD"
            }
          }
        },
        "isPlanDowngrade": null,
        "hasScheduledUpdates": null,
        "credits": {
          "initial": {
            "amount": 21.99,
            "currency": {
              "rawValue": "USD"
            }
          },
          "used": {
            "amount": 21.99,
            "currency": {
              "rawValue": "USD"
            }
          },
          "remaining": {
            "amount": 0,
            "currency": {
              "rawValue": "USD"
            }
          }
        }
      }
    }
  }
  ```
</Expandable>

# Governance

Stigg Governance lets your enterprise customers control AI usage and credit spend across their organizations. The governance API is a REST API — use `System.Net.Http.HttpClient`.

## Check

Call `check` before allowing consumption. Returns `hasAccess: true` when every budget in the hierarchy allows the request.

<CodeGroup>
  ```c# Check.cs theme={null}
  using System.Net.Http;
  using System.Net.Http.Json;
  using System.Text.Json;

  var baseUrl   = Environment.GetEnvironmentVariable("GOVERNANCE_API_URL");
  var authToken = Environment.GetEnvironmentVariable("GOVERNANCE_ACCESS_TOKEN");
  var accountId = Environment.GetEnvironmentVariable("STIGG_ACCOUNT_ID");
  var envId     = Environment.GetEnvironmentVariable("STIGG_ENVIRONMENT_ID");

  using var http = new HttpClient();
  http.DefaultRequestHeaders.Add("Authorization", $"Bearer {authToken}");
  http.DefaultRequestHeaders.Add("x-stigg-account-id", accountId);
  http.DefaultRequestHeaders.Add("x-stigg-environment-id", envId);

  var checkResp = await http.PostAsJsonAsync($"{baseUrl}/owners/cus-acme/check", new {
    entityIds       = new[] { "team-eng" },
    capabilityId    = "ai-tokens",
    requestedAmount = 1000,
  });
  var report = await checkResp.Content.ReadFromJsonAsync<JsonElement>();
  if (!report.GetProperty("hasAccess").GetBoolean())
    throw new Exception("Usage limit reached");
  ```
</CodeGroup>

## Ingest

Call `ingest` after consuming to increment the usage counter.

<CodeGroup>
  ```c# Ingest.cs theme={null}
  await http.PostAsJsonAsync($"{baseUrl}/owners/cus-acme/ingest", new {
    events = new[] {
      new { entityIds = new[] { "team-eng" }, capabilityId = "ai-tokens", amount = 1250 },
    },
  });
  ```
</CodeGroup>

For the full check-then-ingest pattern, provisioning entities, setting budgets, and querying the governance tree, see [Governance](/documentation/governance/overview).

## SDK changelog

<Card title=".NET SDK changelog" icon="list-timeline" horizontal href="/api-and-sdks/changelog/backend-graphql/dotnet" />
