Learn how to authenticate your requests to the Straddle API
Securing your API requests is crucial when integrating with Straddle. This guide will walk you through the authentication process, ensuring your API calls are properly authenticated and your data remains secure.
Straddle uses Bearer Token authentication for API requests. This method involves including a unique API key in the Authorization
header of each HTTP request you make to our API.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail.
Before you can authenticate your requests, you’ll need to obtain an API key:
Your API key carries many privileges, so be sure to keep it secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, or in your application logs.
To authenticate an API request, you should include your API key in the Authorization
header. The value of this header should be formatted as Bearer YOUR_API_KEY
.
Here’s an example of how to include the Authorization
header in your API requests:
Straddle provides separate API keys for test and production environments:
sk_test_
and are used for testing your integration without affecting live data.sk_live_
and are used for live transactions in your production environment.Always use test API keys when developing and testing your integration. Only switch to production keys when you’re ready to go live.
To ensure the security of your integration, follow these best practices:
If your API key is invalid or has been revoked, you’ll receive a 401 Unauthorized
response. Here’s an example of an authentication error response:
If you encounter this error, double-check that you’re using the correct API key and that it hasn’t been revoked or expired.
Now that you understand how to authenticate your API requests, you’re ready to start integrating with Straddle. Check out our API Reference for detailed information on available endpoints and how to use them.