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.Documentation Index
Fetch the complete documentation index at: https://docs.straddle.com/llms.txt
Use this file to discover all available pages before exploring further.
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:| Environment | Base URL | Purpose |
|---|---|---|
| Sandbox | https://sandbox.straddle.com | Testing and development — no real financial transactions are processed |
| Production | https://production.straddle.com | Live transactions with real customer data and banking networks |
Required Headers
In addition to theAuthorization header, Straddle recommends including the following headers with your requests:
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | Set to application/json for request bodies |
Request-Id | No | A unique identifier useful for tracking and debugging individual API requests |
Correlation-Id | No | Used to group related requests within larger operations or transactions for easier debugging |
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.