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

# Process Stripe Cancellations

> Create an endpoint to cancel a user's Stripe subscription and send them a confirmation email.

Let's say we're building an internal tool for customer support, and want to create a workflow to cancel a user's Stripe subscription and send them a confirmation email.

**We'll build a workflow that does this in 5 minutes**.

<Info>
  Don't have a Paragon account yet?

  [Sign up for Paragon](https://app.useparagon.com/signup) on our website to get started!
</Info>

## 1. Create an endpoint trigger

In this example, let's assume the frontend of our customer support tool has a button to cancel a user's subscription. We'll start by setting up our Paragon workflow with an [API Endpoint trigger](/automate/building-workflows/triggers#api-endpoint), so that our frontend sends it an HTTP request when the button is pressed.

Under **Endpoint URL**, copy the workflow's trigger URL to use for your frontend's HTTP request. Under **How do you want to define test data for this step?** choose "Enter in request parameters" and add a body parameter called `email`. This will be the customer's email address that should be sent in your frontend's HTTP request.

<Frame caption="">
  <img src="https://mintcdn.com/paragon/EuLlf5VxgsSnEq57/assets/Creating%20an%20endpoint%20trigger%20in%20Paragon.png?fit=max&auto=format&n=EuLlf5VxgsSnEq57&q=85&s=e0bb32cf54a99308aa19e8fe08a9da21" width="1324" height="1126" data-path="assets/Creating an endpoint trigger in Paragon.png" />
</Frame>

If you want to authorize the request, you can optionally add an authorization header and enter a value to use as an "API Key". The workflow will then reject any incoming requests that do not include an Authorization header with the expected value.

<Frame caption="">
  <img src="https://mintcdn.com/paragon/EuLlf5VxgsSnEq57/assets/Defining%20the%20data%20for%20a%20trigger.png?fit=max&auto=format&n=EuLlf5VxgsSnEq57&q=85&s=df883cdb15630a6386055b244a7b053f" width="1042" height="566" data-path="assets/Defining the data for a trigger.png" />
</Frame>

## 2. Lookup customer in Stripe

Next, we'll add a [Request step](/automate/building-workflows/making-api-requests) to lookup the customer in Stripe. Set the Request to perform a `GET` request to the URL `https://api.stripe.com/v1/customers`.

In the request params, use the dropdown variable menu to select `1.request.body.email` from the Trigger step. In the Headers, [add a bearer auth header with your Stripe API Key](https://stripe.com/docs/api/authentication).

Once your Request is configured, click the **Test Step** button to test that your request to Stripe is working.

<Frame caption="">
  <img src="https://mintcdn.com/paragon/7RZyQGncIlY8Xl4A/assets/Looking%20up%20a%20Stripe%20customer.png?fit=max&auto=format&n=7RZyQGncIlY8Xl4A&q=85&s=c17a8a651675b2af15d30c6c5c37c680" width="1946" height="1000" data-path="assets/Looking up a Stripe customer.png" />
</Frame>

## 3. Cancel Stripe subscription

We'll add another [Request step](/automate/building-workflows/making-api-requests) to cancel the user's Stripe subscription. This time, we'll perform a `DELETE` request to the URL `https://api.stripe.com/v1/subscriptions/`.

You'll need to add the customer's subscription ID to the end of the URL – you can do this by typing `{{` to bring up the variable menu and selecting `response.body.data.0.subscriptions.data.0.id` from the previous step. Make sure to also add the same authentication headers as in the previous Request step.

<Frame caption="">
  <img src="https://mintcdn.com/paragon/DkcdqxlytLXlO_-w/assets/Cancelling%20the%20Stripe%20subscription%20in%20Paragon.gif?s=e2c3ce005089133922a4e0fbfc1d99fc" width="1174" height="810" data-path="assets/Cancelling the Stripe subscription in Paragon.gif" />
</Frame>

## 4. Send confirmation email

Paragon supports [several messaging platforms](/automate/resources/integrations-catalog#messaging) – and for this example, we'll use [Sendgrid](/automate/resources/integrations-catalog/sendgrid) to send a confirmation email.

Under **Recipients**, click the dropdown to bring up the variable menu and choose the user's email address from the Fan Out step. In the **Subject** and **Message** fields, you can insert data from previous steps (e.g. your users' subscription info, etc.) by typing \{\{ to bring up the variable menu

<Frame caption="">
  <img src="https://mintcdn.com/paragon/HSp5hB8tE4Z6e44m/assets/Sending%20Sendgrid%20confirmation%20email%20in%20Paragon.png?fit=max&auto=format&n=HSp5hB8tE4Z6e44m&q=85&s=eb35614abf90f3926490157fc783973b" width="1912" height="1716" data-path="assets/Sending Sendgrid confirmation email in Paragon.png" />
</Frame>

## 5. Send a response

Lastly, we'll add a Response step to send a response back to our frontend to confirm that the workflow ran successfully. Your request to include a confirmation message for your frontend to display it's UI, as well as any data from the workflow (e.g. the customer's information from Stripe).

<Frame caption="">
  <img src="https://mintcdn.com/paragon/HSp5hB8tE4Z6e44m/assets/Sending%20a%20Response%20in%20Paragon.png?fit=max&auto=format&n=HSp5hB8tE4Z6e44m&q=85&s=fad9db50875d25ab20f268beb7168fb0" width="1902" height="1292" data-path="assets/Sending a Response in Paragon.png" />
</Frame>

## 6. Deploy your workflow

Now that your workflow is all set up, all you have to do is deploy your workflow by clicking the "Deploy" button in the top-right of your screen. Once you do, your workflow's Trigger URL will go live and you can start making requests to it.

<Frame caption="">
  <img src="https://mintcdn.com/paragon/jCM_Y_j0HttScr1R/assets/Deploying%20a%20workflow%20in%20Paragon.gif?s=6197999a22c03d21f2ec33a73861e0dc" width="517" height="309" data-path="assets/Deploying a workflow in Paragon.gif" />
</Frame>

Great work! We just built a workflow to power the backend of your internal customer support tool in just a few minutes. Of course, this is just a basic example of what you can do with Paragon, and there's much more we could add to this workflow, e.g. issuing a refund, marking the user as canceled in your database, etc. We hope it gives you an idea of how to use Paragon for your own internal workflows!

<Info>
  Want to build your own workflows?

  [Sign up for Paragon](https://app.useparagon.com/signup) on our website to get started!
</Info>
