Skip to main content

When retrieving subscription usage data, using metered billing in Stripe, I have to call an URL containing the Subscription Item ID. How do I set up a webhook where I merge the ID into the URL and make it know that it should start with one ID, get the data, and then continue merging the url with the next ID, get the data and so forth?

Hi @Danny Fabricius Fogel 

Good question.

App APIs can be used in Zaps with the Webhooks app.

What Stripe API endpoint are you trying to use? (Provide the link to the documentation.)

 


Thanks! Heres the link:-)

https://stripe.com/docs/api/usage_records/subscription_item_summary_list

 


@Danny Fabricius Fogel 

Can you provide more examples about the data you are trying to use as part of the Stripe API request so we have more context?


This is the URL:

https://api.stripe.com/v1/subscription_items/si_HxZw9nI5cF9mQu/usage_record_summaries

si_HxZw9nI5cF9mQu” is an example of a Subscription Item ID (SI ID).

This is what I get back:

“{
  "object": "list",
  "url": "/v1/subscription_items/si_HxZw9nI5cF9mQu/usage_record_summaries",
  "has_more": false,
  "data":
    {
      "id": "sis_1DKJ5IBXVOy2SlndSwCc4aBk",
      "object": "usage_record_summary",
      "invoice": "in_1DKIYGBXVOy2SlndfBkBDtwi",
      "livemode": false,
      "period": {
        "end": 1539321672,
        "start": null
      },
      "subscription_item": "si_Dlqmz3K16t9Vdb",
      "total_usage": 123
    },
    {...},
    {...}
  ]
}”

 

The data I need is the “total_usage” and I need that for every single subscription we have on a weekly basis.

I have the SI ID’s in Stripe and Sheets.

I have no idea how to make Zapier find the SI ID and merge it with the URL and make a call per SI ID we have and return the usage data to Sheets.

 


@Danny Fabricius Fogel 

You can combine static values and dynamic variables in Zap fields.

This can be used to create dynamic URLs for the Webhook GET request.

Example:

 


@Danny Fabricius Fogel 

If you are trying to create a looping Zap that goes thru all the rows of a GSheet, then check out this related topic:

 


Thanks, but how do I get the dynamic value before activating the webhook. I need a trigger and I need to get the SI ID in Google Sheets, so I can merge the dynamic values into the static values.


@Danny Fabricius Fogel

If you are trying to create a looping Zap that goes thru all the rows of a GSheet, then check out this related topic:

 

Sounds great but what do I write in the required Lookup value, when it should just go through one row at a time?


@Danny Fabricius Fogel 

In the Guide it indicates you’ll need a dedicated column that is used as part of the Lookup. (e.g. Done = TRUE/FALSE)

See step 2 and Step 5

 


Got it! So now everything seems fine, except I’m not sure how to make it circle back to the trigger. Which data do I use from the final step POST webhook in the CATCH webhook trigger to get it started again? Which fields do i need to update in the POST and CATCH webhooks?


@Danny Fabricius Fogel 

In the last Webhook, you need to POST to the Webhook URL from the Zap trigger step.

Best to include a timestamp as a parameter to make the request unique.
https://zapier.com/help/create/customize/insert-the-time-your-zap-runs-into-a-field


Amazing! And to restart it I then create a Zap that changes the “Done” column in Sheets back to “no” and then activate the trigger e.g. once a week with a scheduled Zap?


@Danny Fabricius Fogel 

Yes once the process is finished you could configure a Zap to change all the DONE=YES to DONE=NO to reset for the following week.

OR you could do this manually (might be a more efficient use of Tasks)


Thanks:-)