Skip to content
Sad Subscription Analytics
Menu

Create a restricted key

A restricted key can only do what you allow it to do. This walks through creating a read-only one in the Stripe Dashboard, then connecting it to SadAnalytics.

Create the key in Stripe

  1. In the Stripe Dashboard, go to Developers > API keys and click Create restricted key.

    The API keys tab under Developers in the Stripe Dashboard, with the Restricted keys list and its Create restricted key button.
  2. Stripe asks How will you be using this key? Choose Powering an integration you built, even though SadAnalytics is a plugin, then click Continue. That is the choice that leads to the read-only template in the next step.

    Stripe asking how the key will be used, with Powering an integration you built selected above the third-party and AI agent choices.
  3. Under Choose a permission template, select Reporting, analytics, and accounting, then click Continue. It gives the key read-only access, which covers everything SadAnalytics reads.

    Stripe's permission templates, with Reporting, analytics, and accounting selected: read-only access for finance teams and accounting integrations.
  4. Give the key a name you will recognize, such as "Sad Subscription Analytics". The template has already set the permissions, so leave them as they are. Scroll to the bottom, click Create key, and enter the verification code if Stripe asks for one.

    The Create restricted API key form, with Sad Subscription Analytics entered as the key name above the list of permissions.
  5. Copy the key. In a sandbox it stays in the Restricted keys list, so you can come back to it at any time. In live mode Stripe shows a key you created only once, in the window that opens after you create it, so copy it there before you close that window.

    The Restricted keys list with the new Sad Subscription Analytics key added. The key tokens are blurred.
The Billing group in the new key's permission list in Stripe, set to Read. Most rows under it are grayed out because they inherit that Read.
The template sets the whole Billing group to Read, which covers Invoices, Prices and Subscriptions further down the list.

Paste it into SadAnalytics

Open the setup wizard (it opens on its own after you activate SadAnalytics and answer the opt-in screen) or go to Settings > Payment Providers. Paste the key into Secret key (wizard) or Secret API Key (Settings). In the wizard, SadAnalytics reads the rk_test_ / rk_live_ prefix and picks Test or Live for you. In Settings, pick the matching Environment first; a key that does not match it is refused.

The setup wizard step that asks for the Stripe key.
Paste a restricted key. SadAnalytics detects Test or Live mode from its prefix.

Before saving anything, SadAnalytics checks the key by listing one record from each of Customers, Subscriptions, Charges, Invoices and Prices. If a permission is missing, the error names exactly which one, so you can go back to Stripe and grant it rather than guessing. A missing Prices permission is named "Products and prices (read)" in that message.