policy
auth_error
ai_generated
true
StripeInvalidRequestError: This API call cannot be made with a publishable key
ID: policy/stripe-api-version-pinning
90%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Using publishable key where secret key is required, or API version mismatch.
genericWorkarounds
-
95% success Use secret key (sk_) for server-side API calls
stripe.api_key = os.environ["STRIPE_SECRET_KEY"]
-
88% success Pin API version in Stripe dashboard and SDK init
stripe.api_version = "2023-10-16"
Dead Ends
Common approaches that don't work:
-
Use publishable key for server-side calls
95% fail
Publishable keys are for client-side only. Server operations need secret keys.
-
Hardcode the API version in every request
60% fail
Version should be pinned globally in the SDK initialization.