Workflows / Stripe / customer.subscription.created

Stripe New Subscription Notification to Slack & Email

Use the Stripe integration by MagicBell to setup a workflow when customer.subscription.created triggers in Stripe.

Connect Stripe to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.

Add the Stripe integration

Save your Stripe webhook signing secret in MagicBell. See Stripe webhooks.

magicbell integration save_stripe \
  --data '{"webhook_signing_secret":"whsec_xxx"}'

Copy the ID from the response and use it to build your webhook URL:

https://api.magicbell.com/v2/integrations/stripe/webhooks/incoming/{id}

Setup the webhook

Add a workflow

Create a workflow that triggers automatically when Stripe sends this event.

Workflow key

Use this key to trigger the workflow when Stripe sends a customer.subscription.created:

integration.stripe.customer.subscription.created

Example workflow

Welcome new subscribers and notify the sales team about the new signup.

{
  "key": "integration.stripe.customer.subscription.created",
  "steps": [
    {
      "command": "broadcast",
      "input": {
        "content": "Thank you for subscribing! Your subscription is now active and you have full access to all features.",
        "recipients": [
          {
            "external_id": "{{payload.data.object.customer}}"
          }
        ],
        "title": "Welcome to your subscription!"
      }
    },
    {
      "command": "broadcast",
      "input": {
        "content": "Customer {{payload.data.object.customer}} just subscribed. Subscription ID: {{payload.data.object.id}}",
        "overrides": {
          "providers": {
            "slack": {}
          }
        },
        "recipients": [
          {
            "external_id": "sales-team"
          }
        ],
        "title": "New subscription"
      }
    }
  ]
}

Save with the CLI

Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.

magicbell workflow save \
  --data '{"key":"integration.stripe.customer.subscription.created","steps":[{"command":"broadcast","input":{"content":"Thank you for subscribing! Your subscription is now active and you have full access to all features.","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Welcome to your subscription!"}},{"command":"broadcast","input":{"content":"Customer {{payload.data.object.customer}} just subscribed. Subscription ID: {{payload.data.object.id}}","overrides":{"providers":{"slack":{}}},"recipients":[{"external_id":"sales-team"}],"title":"New subscription"}}]}'

Event payload

Sample payload for the customer.subscription.created event. Use liquid templates to access fields in your workflow.

{
  "api_version": "2023-10-16",
  "created": 1694108961,
  "data": {
    "object": {
      "cancel_at": null,
      "canceled_at": null,
      "collection_method": "charge_automatically",
      "created": 1679609767,
      "currency": "usd",
      "current_period_end": 1682288167,
      "current_period_start": 1679609767,
      "customer": "cus_Na6dX7aXxi11N4",
      "id": "sub_1MowQVLkdIwHu7ixeRlqHVzs",
      "items": {
        "data": [
          {
            "id": "si_Na6dzxczY5fwHx",
            "object": "subscription_item",
            "price": {
              "currency": "usd",
              "id": "price_1MowQULkdIwHu7ixraBm864M",
              "object": "price",
              "product": "prod_Na6dGcTsmU0I4R",
              "recurring": {
                "interval": "month",
                "interval_count": 1
              },
              "unit_amount": 1000
            },
            "quantity": 1,
            "subscription": "sub_1MowQVLkdIwHu7ixeRlqHVzs"
          }
        ],
        "object": "list"
      },
      "livemode": false,
      "object": "subscription",
      "start_date": 1679609767,
      "status": "active",
      "trial_end": null,
      "trial_start": null
    }
  },
  "id": "evt_1NqIYSLkdIwHu7ixHkT6Ux9w",
  "livemode": false,
  "object": "event",
  "type": "customer.subscription.created"
}
View all Stripe workflows →