Overview
Straddle uses Bearer Token authentication via JSON Web Tokens (JWT) for all API requests. Each request must include a valid API key in theAuthorization header as a Bearer token.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail.
Obtaining Your API Key
Before you can authenticate your requests, you’ll need to obtain an API key from the Straddle Dashboard:- Log in to your Straddle Dashboard.
- Click the Developer (
</>) icon in the top-right corner of the navigation bar. - Select API Keys from the dropdown menu.
- Click Generate New API Key.
- Copy your new API key and store it securely.
Using Your API Key
To authenticate an API request, include your API key in theAuthorization header. The value should be formatted as Bearer YOUR_API_KEY.
Here’s an example of how to include the Authorization header in your API requests:
API Environments
Straddle provides two public environments, each with its own base URL and API keys:Required Headers
In addition to theAuthorization header, Straddle recommends including the following headers with your requests:
Best Practices
To ensure the security of your integration, follow these best practices:- Keep your API key secret: Never expose your API key in client-side code or public repositories.
- Use environment variables: Store your API key in environment variables rather than hardcoding it in your application.
- Rotate your API keys: Regularly generate new API keys and update your applications to use them.
- Monitor API key usage: Regularly review your API key usage in the Straddle Dashboard to detect any unauthorized access.
- Match keys to environments: Always confirm your API key matches the environment you’re targeting before processing requests.
Handling Authentication Errors
If your API key is invalid, expired, or has been revoked, you’ll receive a401 Unauthorized response:
- Confirm you’re using the correct API key.
- Check whether your key has been revoked or expired.
- Ensure you’re targeting the correct environment (sandbox or production) for the key you’re using.