The Stripe API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
You can use the Stripe API in test mode, which doesn’t affect your live data or interact with the banking networks. The API key you use to authenticate the request determines whether the request is live mode or test mode.
The Stripe API doesn’t support bulk updates. You can work on only one object per request.
Test mode secret keys have the prefix
sk_test_ and live mode secret keys have the prefix
sk_live_. Alternatively, you can use restricted API keys for granular permissions.
Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
- Related video: Authentication
To act as connected accounts, clients can issue requests using the
Stripe-Account special header. Make sure that this header contains a Stripe account ID, which usually starts with the
The value is set per-request as shown in the adjacent code sample. Methods on the returned object reuse the same account ID.
- Related guide: Making API calls for connected accounts
Stripe uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the
2xx range indicate success. Codes in the
4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the
5xx range indicate an error with Stripe’s servers (these are rare).
Our Client libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend writing code that gracefully handles all possible API exceptions.
- Related guide: Error Handling