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

# Stripe

> Start and stop workflows from Stripe trial and subscription events.

Workflows can start and stop on their own from events in your other tools. Stripe is supported today.

* **Triggers** start the workflow for the person the event is about. If they aren't a subscriber yet, they're added using the email on their Stripe customer.
* **Exit conditions** stop the workflow for that person. Their active runs are cancelled and steps that haven't sent never will. Exit conditions are checked before triggers, so an event in both restarts the workflow.

Add them to an automation workflow, or ask [your agent](https://docs.subscriber.dev/mcp.md) to "start the trial workflow when a Stripe trial starts, and stop it when they convert":

> [tab] CLI
>
> Add `triggers` and `exitConditions` to the workflow's JSON file, then run `subscriber workflows update <workflowId> --file trial.json`:
>
> ```json theme={null}
> {
>   "triggers": [{ "source": "stripe", "event": "trial_started" }],
>   "exitConditions": [{ "source": "stripe", "event": "trial_converted" }]
> }
> ```

> [tab] TUI
>
> Open **Workflows**, choose the workflow and press `g`. Choose **+ Add trigger** or **+ Add exit condition**, then pick the events.

> [tab] API
>
> ```bash theme={null}
> curl -X PATCH https://api.subscriber.dev/workflows/$WORKFLOW \
>   -H "x-api-key: $KEY" -H "content-type: application/json" \
>   -d '{"triggers": [{"source": "stripe", "event": "trial_started"}], "exitConditions": [{"source": "stripe", "event": "trial_converted"}]}'
> ```

Connect Stripe first; triggers only run while the integration is connected.

## Events

These are the moments in Stripe you can start or stop a workflow on.

| Event | When it fires |
| - | - |
| `trial_started` | Trial started |
| `trial_ending` | Trial ending (3 days before) |
| `trial_converted` | Trial converted to paid |
| `trial_payment_failed` | Trial ended, payment failed (Stripe retries it) |
| `trial_expired` | Trial expired unpaid |
| `subscription_started` | Subscription started (paid) |
| `subscription_canceled` | Subscription canceled |
| `payment_failed` | Renewal payment failed |

You can also use a raw Stripe event type, such as `checkout.session.completed`. Enable it on the webhook endpoint in Stripe too, since Stripe only sends the events enabled there. subscriber.dev keeps events you add when it updates the endpoint.

## Connect Stripe

Connecting lets subscriber.dev look up who each Stripe event is about, and sets up a webhook so Stripe tells subscriber.dev when something happens.

1. In Stripe, create a [restricted API key](https://dashboard.stripe.com/apikeys) with **Customers: Read** and **Webhook Endpoints: Write**.
2. Connect it to subscriber.dev:

   > [tab] CLI
   >
   > ```bash theme={null}
   > subscriber integrations set stripe --body '{"apiKey": "rk_live_..."}'
   > ```

   > [tab] TUI
   >
   > Open **Integrations**, press `n` and choose **Stripe (trigger workflows)**.

   > [tab] API
   >
   > ```bash theme={null}
   > curl -X PATCH https://api.subscriber.dev/integrations/stripe \
   >   -H "x-api-key: $KEY" -H "content-type: application/json" \
   >   -d '{"apiKey": "rk_live_..."}'
   > ```

That's it. subscriber.dev creates the webhook endpoint in your Stripe account and keeps its signing secret, and the response shows `"webhookStatus": "automatic"`. Saving again updates that endpoint rather than adding another, and disconnecting Stripe deletes it.

### Adding the webhook yourself

If you'd rather not give the key Webhook Endpoints: Write, use a key with just Customers: Read. The response then has a `webhookUrl`, the `eventsToEnable` and a `nextStep`:

1. In Stripe, add a webhook endpoint with that URL and those events.
2. Give subscriber.dev the endpoint's signing secret (`whsec_...`) the same way you saved the key. Your API key is kept, so send only `{"webhookSecret": "whsec_..."}`.

To see the webhook URL again, ask your agent, run `subscriber integrations get stripe`, or open Stripe under **Integrations** in the TUI.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.