stripe-cli: `--api-version` not working

stripe listen --api-version 2019-09-09 results in:

unknown flag: --api-version

The same goes for stripe trigger checkout.session.completed --api-version 2019-09-09

Second issue:
It looks like Stripe CLI is defaulting to the 2019-03-14 API version, not to my currently used API version.

I have:

stripe version 0.6.12 (beta)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (2 by maintainers)

Most upvoted comments

this is an issue for us too. After a stripe account migration, our account default version is after the version we are using. So I can’t test webhooks locally…

FWIW, this is an issue for us, as well. Our use case was we were prepared to update to a more recent version of the Stripe API (but not latest).

Same problem here. I have a project running on API version of 2020, I try to test it with sandbox, but I’m on a new account with latest version and of course it doesn’t work. I don’t want to use the sandbox from production account because it’s a security risk and I don’t want to upgrade my API version, because it might introduce bugs.

Is there any hope you might reconsider changing this behaviour?

No. When using API requests commands (e.g. stripe charges create, stripe customers update, etc.), you can specify any API version. This controls which parameters are accepted in the request, and how the API response is formatted.

However, it doesn’t control which API version will be used to format the resulting event (if any). This is briefly mentioned here: https://stripe.com/docs/api/versioning

Note that events generated by API requests will always be structured according to your account API version.

(Though this isn’t 100% correct – when setting up a webhook endpoint, or when using stripe listen with the --latest flag, you can request that events be formatted with the latest API version instead of your account’s default version.)

This is how events work in Stripe’s API and is not specific to the CLI.

Can you clarify your usecase? In nearly all cases, you want events to be formatted with your account’s default API version (or the latest, when you’re preparing to upgrade your account’s default API version to the latest).

Unfortunately, due to technical constraints on the backend, the listen command can only support two different API versions:

  • by default, events will be formatted according to your account’s default API version (which you can view at https://dashboard.stripe.com/developers)
  • alternatively, you can request that events be formatted with the latest API version by using the --latest (or -l) flag

Relatedly, the trigger command also doesn’t support specific API versions. The events are formatted by Stripe’s backend servers:

  • if you’re receiving events via the stripe listen command, then events will be formatted as explained above
  • if you’re receiving events via a regular webhook endpoint, then events will be formatted according to the endpoint’s API version

Second issue: It looks like Stripe CLI is defaulting to the 2019-03-14 API version, not to my currently used API version.

For the trigger command, yes, API requests that are sent by the CLI in order to trigger the requested event do use that API version. But that doesn’t control the API version that will be used to format the event object you receive on your endpoint.