policy auth_error ai_generated true

StripeInvalidRequestError: This API call cannot be made with a publishable key

ID: policy/stripe-api-version-pinning

Also available as: JSON · Markdown
90%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Using publishable key where secret key is required, or API version mismatch.

generic

Workarounds

  1. 95% success Use secret key (sk_) for server-side API calls
    stripe.api_key = os.environ["STRIPE_SECRET_KEY"]
  2. 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:

  1. Use publishable key for server-side calls 95% fail

    Publishable keys are for client-side only. Server operations need secret keys.

  2. Hardcode the API version in every request 60% fail

    Version should be pinned globally in the SDK initialization.