# Get account settings
Source: https://docs.straddle.com/api-reference/accounts/account-settings
get /v1/account_settings/{account_id}
Get all resolved settings for the specified account, including inherited values from organization, platform, and system defaults.
# Create an account
Source: https://docs.straddle.com/api-reference/accounts/create
post /v1/accounts
Creates a new account associated with your Straddle platform integration. This endpoint allows you to set up an account with specified details, including business information and access levels.
# List accounts
Source: https://docs.straddle.com/api-reference/accounts/list
get /v1/accounts
Returns a list of accounts associated with your Straddle platform integration. The accounts are returned sorted by creation date, with the most recently created accounts appearing first. This endpoint supports advanced sorting and filtering options.
# Lookup an account
Source: https://docs.straddle.com/api-reference/accounts/lookup
get /v1/accounts/{account_id}
Retrieves the details of an account that has previously been created. Supply the unique account ID that was returned from your previous request, and Straddle will return the corresponding account information.
# Onboard an account
Source: https://docs.straddle.com/api-reference/accounts/onboard
post /v1/accounts/{account_id}/onboard
Initiates the onboarding process for a new account. This endpoint can only be used for accounts where at least one representative and one bank account have already been created.
Prior to onboarding via this endpoint you must capture consent to the Straddle Payment Services Agreement ([legal.straddle.com](https://legal.straddle.com)).
# Simulate account onboarding in sandbox
Source: https://docs.straddle.com/api-reference/accounts/simulate
post /v1/accounts/{account_id}/simulate
Simulate the status transitions for sandbox accounts. This endpoint can only be used for sandbox accounts.
# Update an account
Source: https://docs.straddle.com/api-reference/accounts/update
put /v1/accounts/{account_id}
Updates an existing account's information. This endpoint allows you to update various account details during onboarding or after the account has been created.
# API authentication with bearer tokens
Source: https://docs.straddle.com/api-reference/authentication
Authenticate Straddle API requests using JWT bearer tokens. Generate API keys, manage sandbox and production credentials, and follow security best practices.
Securing your API requests is crucial when integrating with Straddle. This guide walks you through the authentication process, ensuring your API calls are properly authenticated and your data remains secure.
## Overview
Straddle uses Bearer Token authentication via JSON Web Tokens (JWT) for all API requests. Each request must include a valid API key in the `Authorization` 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:
1. Log in to your [Straddle Dashboard](https://dashboard.straddle.com).
2. Select the **Developer** (`>`) icon in the top-right corner of the navigation bar.
3. Select **API Keys** from the dropdown menu.
4. Select **Generate New API Key**.
5. Copy your new API key and store it securely.
Your API key carries many privileges, so be sure to keep it secure! Do not share your API keys in publicly accessible areas such as GitHub, client-side code, or in your application logs.
## Using your API key
To authenticate an API request, include your API key in the `Authorization` 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:
```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/accounts \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJvcmdfMmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6Iiwib3JnIjoiYWNtZS1jb3JwIiwiZW52Ijoic2FuZGJveCIsImlhdCI6MTcxMTU1OTAwMCwiZXhwIjoxNzExNjQ1NDAwfQ.VGhpcyBpcyBhIHNpbXVsYXRlZCBSUzI1NiBzaWduYXR1cmUgZm9yIGRlbW9uc3RyYXRpb24gcHVycG9zZXMgb25seQ" \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
const apiKey = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJvcmdfMmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6Iiwib3JnIjoiYWNtZS1jb3JwIiwiZW52Ijoic2FuZGJveCIsImlhdCI6MTcxMTU1OTAwMCwiZXhwIjoxNzExNjQ1NDAwfQ.VGhpcyBpcyBhIHNpbXVsYXRlZCBSUzI1NiBzaWduYXR1cmUgZm9yIGRlbW9uc3RyYXRpb24gcHVycG9zZXMgb25seQ'
async function listAccounts() {
const res = await fetch('https://sandbox.straddle.com/v1/accounts', {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
})
const json = await res.json()
console.log(json)
}
listAccounts().catch(err => console.error('Error:', err))
```
```python Python theme={null}
import requests
api_key = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJvcmdfMmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6Iiwib3JnIjoiYWNtZS1jb3JwIiwiZW52Ijoic2FuZGJveCIsImlhdCI6MTcxMTU1OTAwMCwiZXhwIjoxNzExNjQ1NDAwfQ.VGhpcyBpcyBhIHNpbXVsYXRlZCBSUzI1NiBzaWduYXR1cmUgZm9yIGRlbW9uc3RyYXRpb24gcHVycG9zZXMgb25seQ'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
response = requests.get('https://sandbox.straddle.com/v1/accounts', headers=headers)
print(response.json())
```
## 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 |
API keys are environment-specific. A sandbox API key doesn't authenticate against the production environment, and vice versa. Always verify you are using the correct key for your target environment.
Always use sandbox API keys when developing and testing your integration. Only switch to production keys when you're ready to go live.
## Required headers
In addition to the `Authorization` 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 |
While `Request-Id` and `Correlation-Id` are optional, we strongly recommend including them. They make it much easier to trace and debug API requests when troubleshooting issues.
## Best practices
To ensure the security of your integration, follow these best practices:
1. **Keep your API key secret**: Never expose your API key in client-side code or public repositories.
2. **Use environment variables**: Store your API key in environment variables rather than hardcoding it in your application.
3. **Rotate your API keys**: Regularly generate new API keys and update your applications to use them.
4. **Monitor API key usage**: Regularly review your API key usage in the Straddle Dashboard to detect any unauthorized access.
5. **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 a `401 Unauthorized` response:
```json theme={null}
{
"error": {
"code": "invalid_api_key",
"message": "The provided API key is invalid or has been revoked.",
"type": "authentication_error"
}
}
```
If you encounter this error, verify the following:
1. Confirm you're using the correct API key.
2. Check whether your key has been revoked or expired.
3. Ensure you're targeting the correct environment (sandbox or production) for the key you're using.
## Next steps
Now that you understand how to authenticate your API requests, you're ready to start integrating with Straddle. Check out our [API Reference](/api-reference) for detailed information on available endpoints and how to use them.
# Bridge a bank account
Source: https://docs.straddle.com/api-reference/bridge/bank-account
post /v1/bridge/bank_account
Use Bridge to create a new paykey using a bank routing and account number as the source. This endpoint allows you to create a secure payment token linked to a specific bank account.
# Bridge a Mastercard consent receipt
Source: https://docs.straddle.com/api-reference/bridge/mastercard
post /v1/bridge/mastercard
Creates a new paykey from a Mastercard Open Finance connection your application already owns. Supply the consent receipt granting Straddle third-party access along with the pseudonymous Mastercard customer and account identifiers, and Straddle retrieves the bank details, account holder names, and live balance on your behalf.
# Bridge a Plaid token
Source: https://docs.straddle.com/api-reference/bridge/plaid-token
post /v1/bridge/plaid
Use Bridge to create a new paykey using a Plaid token as the source. This endpoint allows you to create a secure payment token linked to a bank account authenticated through Plaid.
# Bridge a Quiltt token
Source: https://docs.straddle.com/api-reference/bridge/quiltt-token
post /v1/bridge/quiltt
Creates a new paykey using a Quiltt token as the source. This endpoint allows you to create a secure payment token linked to a bank account authenticated through Quiltt.
# Initiate a widget session
Source: https://docs.straddle.com/api-reference/bridge/session
post /v1/bridge/initialize
Use this endpoint to generate a session token for use in the Bridge widget.
# Request a capability
Source: https://docs.straddle.com/api-reference/capabilityrequests/create
post /v1/accounts/{account_id}/capability_requests
Submits a request to enable a specific capability for an account. Use this endpoint to request additional features or services for an account.
# List capability requests
Source: https://docs.straddle.com/api-reference/capabilityrequests/list
get /v1/accounts/{account_id}/capability_requests
Retrieves a list of capability requests associated with an account. The requests are returned sorted by creation date, with the most recent requests appearing first. This endpoint supports advanced sorting and filtering options.
# Upload proof of authorization for a charge
Source: https://docs.straddle.com/api-reference/charges/authorize
post /v1/charges/{id}/authorization
Uploads a document as proof of authorization for a charge. Uploading again adds another entry to documents rather than replacing the previous one.
# Cancel a charge
Source: https://docs.straddle.com/api-reference/charges/cancel
put /v1/charges/{id}/cancel
Cancel a charge to prevent it from being originated for processing. The status of the charge must be `created`, `scheduled`, or `on_hold`.
# Create a charge
Source: https://docs.straddle.com/api-reference/charges/create
post /v1/charges
Use charges to collect money from a customer for the sale of goods or services.
In ACH terminology, Straddle charges are **ACH debit transactions** that pull money from customer bank accounts. Learn more about [ACH debits](/help/ACH101/ach-debit) and [authorization requirements](/help/Payment-Compliance/ach-auth) to ensure compliant payment collection.
# Hold a charge
Source: https://docs.straddle.com/api-reference/charges/hold
put /v1/charges/{id}/hold
Place a charge on hold to prevent it from being originated for processing. The status of the charge must be `created` or `scheduled`.
# Refund a charge
Source: https://docs.straddle.com/api-reference/charges/refund
post /v1/charges/{id}/refund
Issue a refund for a successfully paid charge. The refund is created as a new payout linked to the original charge through `related_payments`. The customer receives the funds back at the bank account they paid from. Each charge can be refunded once; partial and full refunds are both supported.
# Release a charge
Source: https://docs.straddle.com/api-reference/charges/release
put /v1/charges/{id}/release
Release a charge from an `on_hold` status to allow it to be rescheduled for processing.
# Resubmit a charge
Source: https://docs.straddle.com/api-reference/charges/resubmit
post /v1/charges/{id}/resubmit
Recover a failed, reversed, or cancelled ACH debit by creating a new charge linked to the original transaction and retaining payment history.
# Lookup a charge
Source: https://docs.straddle.com/api-reference/charges/retrieve
get /v1/charges/{id}
Retrieves the details of an existing charge. Supply the unique charge `id`, and Straddle will return the corresponding charge information.
# Update a charge
Source: https://docs.straddle.com/api-reference/charges/update
put /v1/charges/{id}
Change the values of parameters associated with a charge prior to processing. The status of the charge must be `created`, `scheduled`, or `on_hold`.
# Create a customer
Source: https://docs.straddle.com/api-reference/customers/create
post /v1/customers
Creates a new customer record and automatically initiates identity, fraud, and risk assessment scores. This endpoint allows you to create a customer profile and associate it with paykeys and payments.
# Decision a customer
Source: https://docs.straddle.com/api-reference/customers/decision
patch /v1/customers/{id}/review
Updates the status of a customer's identity decision. This endpoint allows you to modify the outcome of a customer risk screening and is useful for correcting or updating the status of a customer's verification. Note that this endpoint is only available for customers with a current status of `review`.
# Delete a customer
Source: https://docs.straddle.com/api-reference/customers/delete
delete /v1/customers/{id}
Permanently removes a customer record from Straddle. This action cannot be undone and should only be used to satisfy regulatory requirements or for privacy compliance.
# Lookup a customer
Source: https://docs.straddle.com/api-reference/customers/retrieve
get /v1/customers/{id}
Retrieves the details of an existing customer. Supply the unique customer ID that was returned from your 'create customer' request, and Straddle will return the corresponding customer information.
# Review a customer
Source: https://docs.straddle.com/api-reference/customers/review
get /v1/customers/{id}/review
Retrieves and analyzes the results of a customer's identity validation and fraud score. This endpoint provides a comprehensive breakdown of the validation outcome, including:
- Risk and correlation scores
- Reason codes for the decision
- Results of watchlist screening
- Any network alerts detected
Use this endpoint to gain insights into the verification process and make informed decisions about customer onboarding.
# List customers
Source: https://docs.straddle.com/api-reference/customers/search
get /v1/customers
Lists or searches customers connected to your account. All supported query parameters are optional. If none are provided, the response will include all customers connected to your account. This endpoint supports advanced sorting and filtering options.
# Unmask customer data
Source: https://docs.straddle.com/api-reference/customers/unmask
get /v1/customers/{id}/unmasked
Retrieves the unmasked details, including PII, of an existing customer. Supply the unique customer ID that was returned from your 'create customer' request, and Straddle will return the corresponding customer information. This endpoint needs to be enabled by Straddle and should only be used when absolutely necessary.
This endpoint is not enabled by default.
Please contact [compliance@straddle.com](mailto:compliance@straddle.com) to request access.
# Update a customer
Source: https://docs.straddle.com/api-reference/customers/update
put /v1/customers/{id}
Updates an existing customer's information. This endpoint allows you to modify the customer's contact details, PII, and metadata.
Updating more than two fields (not including `metadata`) within a 24 hour period will trigger a new [identity](/guides/identity/overview) score.
# Make API calls for embedded accounts
Source: https://docs.straddle.com/api-reference/embedded-accounts
Use the Straddle-Account-Id header to make API requests on behalf of your embedded accounts, including charges, payouts, and customer operations.
For platforms building on Embed, you can make API calls on behalf of your embedded accounts. This guide walks you through the process of adding the necessary information to your API calls to act on behalf of your connected accounts.
## Overview
You can make API calls for your embedded accounts in two ways:
1. Server-side using the `Straddle-Account-Id` header and the embedded account ID, per request
2. Client-side by passing the embedded account ID as an argument to the client library
To ensure optimal performance and reliability, Straddle has established rate limits and allocations for API endpoints. These limits apply collectively to all requests made on behalf of embedded accounts.
## Server-side requests: Using the Straddle-Account-Id header
For server-side API calls, you can make requests as embedded accounts using the special header `Straddle-Account-Id` with the Straddle account identifier (prefixed with `acct_`) of your platform user.
### Example: Creating a charge
Here's an example that shows how to create a Charge with your platform's API secret key and your user's Account identifier:
```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/charges \
-H "Authorization: Bearer 51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1" \
-H "Straddle-Account-Id: 1234567890" \
-d amount=1000 \
-d currency=usd \
-d paykey="pk_test_TYooMQauvdEDq54NiTphI7jx"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.charges.create({
amount: 1000,
currency: 'usd',
paykey: 'pk_test_TYooMQauvdEDq54NiTphI7jx'
}, {
straddleAccountId: 'acct_1234567890'
}).then(charge => {
console.log(charge);
}).catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
charge = straddle.Charge.create(
amount=1000,
currency="usd",
paykey="pk_test_TYooMQauvdEDq54NiTphI7jx",
straddle_account_id="acct_1234567890"
)
print(charge)
```
## Client-side requests
For client-side API calls, you can pass the embedded account ID as an argument when initializing the Straddle client. Here's an example:
*COMING SOON*
Be cautious when using client-side requests for embedded accounts. Ensure that you're not exposing sensitive information or granting unnecessary permissions to the client.
## Best practices
When making API requests for embedded accounts, keep these best practices in mind:
1. **Use server-side requests when possible**: This gives you more control over the API calls and keeps sensitive information secure.
2. **Validate the embedded account ID**: Before making a request on behalf of an embedded account, ensure that the account ID is valid and belongs to your platform.
3. **Handle errors gracefully**: Be prepared to handle errors that may occur when making requests for embedded accounts, such as account not found or insufficient permissions.
4. **Monitor API usage**: Keep track of the API calls made on behalf of your embedded accounts to ensure you're within rate limits and to detect any unusual activity.
5. **Use webhooks**: Set up webhooks to receive real-time notifications about events related to your embedded accounts.
## Rate limits
Straddle applies rate limits to API requests to ensure fair usage and system stability. These limits apply collectively to all requests made by your platform, including those made on behalf of embedded accounts.
If you need higher rate limits for your platform, contact Straddle support to discuss your requirements.
## Conclusion
Making API requests on behalf of embedded accounts is a powerful feature that allows you to build sophisticated platforms on top of Straddle. Follow the guidelines in this document to make these requests correctly and securely.
For more information on specific API endpoints and how they behave when used with embedded accounts, refer to our [API Reference](/api-reference) documentation.
# Sandbox and production environments
Source: https://docs.straddle.com/api-reference/environments
Compare Straddle's sandbox and production API environments, including base URLs, credentials, testing workflows, and how to safely promote integrations to live.
Straddle provides two distinct environments for developers: a sandbox environment for testing and a production environment for live transactions. This guide helps you understand the differences between these environments and how to use them effectively in your development process.
## Overview
Straddle offers two environments:
1. **Sandbox Environment**: `https://sandbox.straddle.com`
2. **Production Environment**: `https://production.straddle.com`
Each environment serves a specific purpose in your development lifecycle.
## Sandbox environment
The sandbox environment (`https://sandbox.straddle.com`) is designed for testing and development purposes. It allows you to integrate and experiment with Straddle's API without affecting real data or triggering actual financial transactions.
### Key features of the sandbox environment
* Simulates the behavior of the production environment
* Uses sandbox API keys
* Does not process real financial transactions
* Provides pre-defined test data and scenarios
* No rate limits or usage restrictions
### When to use the sandbox environment
Use the sandbox environment when:
* Developing and testing your integration
* Experimenting with new features
* Running automated tests
* Demonstrating your application without using real data
### Accessing the sandbox environment
To use the sandbox environment, make API requests to `https://sandbox.straddle.com` and use your test API key for authentication.
Example API request to the sandbox environment:
```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/accounts \
-H "Authorization: Bearer 71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi"
```
```javascript Node.js theme={null}
const apiKey = '71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi'
async function listAccounts() {
const res = await fetch('https://sandbox.straddle.com/v1/accounts', {
headers: { 'Authorization': `Bearer ${apiKey}` }
})
const json = await res.json()
console.log(json)
}
listAccounts().catch(err => console.error('Error:', err))
```
```python Python theme={null}
import requests
api_key = '71aVYucgQ8o0ymsuaT0ymEEQUR03NrYAqoy58Z53n9LHgRmJlMp8HSbOOBl6TWi'
headers = {
'Authorization': f'Bearer {api_key}'
}
response = requests.get('https://sandbox.straddle.com/v1/accounts', headers=headers)
print(response.json())
```
## Production environment
The production environment (`https://production.straddle.com`) is used for live, real-world transactions. This is where your application interacts with actual customer data and process real financial transactions.
### Key features of the production environment
* Processes real financial transactions
* Uses live API keys
* Interacts with real customer data
* Subject to rate limits and usage restrictions
* Monitored for performance and reliability
### When to use the production environment
Use the production environment when:
* Your application is ready for real-world use
* Processing actual financial transactions
* Working with real customer data
### Accessing the production environment
To use the production environment, make API requests to `https://production.straddle.com` and use your live API key for authentication.
Example API request to the production environment:
```bash cURL theme={null}
curl https://production.straddle.com/v1/accounts \
-H "Authorization: Bearer 51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
```
```javascript Node.js theme={null}
const apiKey = '51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1'
async function listAccountsProd() {
const res = await fetch('https://production.straddle.com/v1/accounts', {
headers: { 'Authorization': `Bearer ${apiKey}` }
})
const json = await res.json()
console.log(json)
}
listAccountsProd()
```
```python Python theme={null}
import requests
api_key = '51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1'
headers = {
'Authorization': f'Bearer {api_key}'
}
response = requests.get('https://production.straddle.com/v1/accounts', headers=headers)
print(response.json())
```
## Best practices
To ensure a smooth transition from development to production, follow these best practices:
1. **Use environment variables**: Store your API keys and environment URLs as environment variables to easily switch between sandbox and production.
2. **Thoroughly test in sandbox**: Extensively test your integration in the sandbox environment before moving to production.
3. **Gradual rollout**: When moving to production, consider a phased rollout to minimize potential issues.
4. **Monitor closely**: Keep a close eye on your production transactions and be prepared to switch back to sandbox if issues arise.
5. **Keep environments separate**: Never mix sandbox and production data or API keys.
## Transitioning from sandbox to production
When you're ready to go live with your Straddle integration, follow these steps:
1. Review and test all features in the sandbox environment.
2. Update your API key to the live production key.
3. Change your API endpoint from `https://sandbox.straddle.com` to `https://production.straddle.com`.
4. Update any environment-specific configurations or settings.
5. Perform final testing in production with real data (start with small, controlled transactions).
6. Monitor your production transactions closely for any issues.
Always double-check that you're using the correct environment and API key before processing real transactions. Using sandbox credentials in production can lead to failed transactions and poor user experience.
## Conclusion
Understanding and properly utilizing Straddle's sandbox and production environments is crucial for successful integration and deployment. Follow the guidelines and best practices in this guide to ensure a smooth development process and transition to production.
For more detailed information on specific API endpoints and how they behave in different environments, refer to our [API Reference](/api-reference) documentation.
# API errors and HTTP status codes
Source: https://docs.straddle.com/api-reference/errors
Learn how to interpret HTTP status codes and error responses from the Straddle API, including validation, authentication, and rate limit errors.
When working with the Straddle API, it's crucial to properly handle HTTP errors to ensure your application can gracefully manage unexpected situations. This guide walks you through the different types of errors you might encounter, how to interpret them, and best practices for error handling.
## Common HTTP errors
Here's a quick reference table of common HTTP errors you might encounter when using the Straddle API:
Status Code
Error Type
Description
Common Causes
400
Bad Request
The request was unacceptable, often due to missing a required parameter.
Missing required fields
Invalid field values
Malformed JSON
401
Unauthorized
No valid API key provided.
Invalid API key
Expired API key
403
Forbidden
The API key doesn't have permissions to perform the request.
Insufficient permissions
Incorrect account access
404
Not Found
The requested resource doesn't exist.
Incorrect resource ID
Deleted resource
422
Unprocessable Entity
The request was well-formed but was unable to be followed due to semantic errors.
Invalid parameter values
Logical errors in request
429
Too Many Requests
Too many requests hit the API too quickly.
Exceeding rate limits
500
Internal Server Error
Something went wrong on Straddle's end.
Unexpected server issues
## Understanding HTTP status codes
Straddle uses standard HTTP status codes to indicate the success or failure of an API request. Here are the main categories:
* 2xx: Success
* 4xx: Client errors
* 5xx: Server errors
## Common error responses
When an error occurs, Straddle returns a JSON object with details about the error. The structure of this object is consistent across all error types:
```json theme={null}
{
"error": {
"code": "error_code",
"message": "A human-readable message providing more details about the error.",
"type": "error_type"
}
}
```
## Types of errors
### 400 Bad Request
This error occurs when the request is malformed or contains invalid parameters.
Example response:
```json theme={null}
{
"error": {
"code": "invalid_request_error",
"message": "The 'amount' parameter is required and must be a positive integer.",
"type": "invalid_request_error"
}
}
```
How to handle:
* Check your request parameters for any missing or invalid values.
* Ensure all required fields are included and formatted correctly.
### 401 Unauthorized
This error occurs when authentication fails, typically due to an invalid API key.
Example response:
```json theme={null}
{
"error": {
"code": "invalid_api_key",
"message": "The provided API key is invalid or has been revoked.",
"type": "authentication_error"
}
}
```
How to handle:
* Verify that you're using the correct API key.
* Check if your API key has been revoked or expired.
* Ensure you're using the correct environment (test vs. production).
### 403 Forbidden
This error occurs when the authenticated user doesn't have permission to perform the requested action.
Example response:
```json theme={null}
{
"error": {
"code": "permission_denied",
"message": "You don't have permission to access this resource.",
"type": "authentication_error"
}
}
```
How to handle:
* Check if the authenticated account has the necessary permissions.
* If you're using a platform account, ensure you've correctly specified the `Straddle-Account-Id` header.
### 404 Not Found
This error occurs when the requested resource doesn't exist.
Example response:
```json theme={null}
{
"error": {
"code": "resource_missing",
"message": "The requested resource does not exist.",
"type": "invalid_request_error"
}
}
```
How to handle:
* Verify that you're using the correct resource ID.
* Check if the resource has been deleted or hasn't been created yet.
### 422 Unprocessable Entity
This error occurs when the request is well-formed, but contains invalid data.
Example response:
```json theme={null}
{
"error": {
"code": "invalid_parameter",
"message": "The 'amount' parameter must be greater than 0.",
"type": "invalid_request_error"
}
}
```
How to handle:
* Review the error message for specific details about which parameter is invalid.
* Adjust your request data accordingly.
### 429 Too Many Requests
This error occurs when you've exceeded the rate limit for API requests.
Example response:
```json theme={null}
{
"error": {
"code": "rate_limit_exceeded",
"message": "You have exceeded the rate limit. Please try again later.",
"type": "rate_limit_error"
}
}
```
How to handle:
* Implement exponential backoff and retry logic in your application.
* Consider optimizing your code to make fewer API requests.
### 500 Internal Server Error
This error indicates an unexpected condition on the server side.
Example response:
```json theme={null}
{
"error": {
"code": "internal_server_error",
"message": "An unexpected error occurred. Please try again later.",
"type": "api_error"
}
}
```
How to handle:
* Implement a retry mechanism with exponential backoff.
* If the error persists, contact Straddle support and provide the Request-Id and Correlation-Id.
## Best practices for error handling
1. **Always check the HTTP status code**: Don't assume a request was successful. Always check the HTTP status code before processing the response.
2. **Parse the error response**: Extract the error details from the JSON response to get more information about what went wrong.
3. **Log errors with context**: When logging errors, include relevant context such as the Request-Id, Correlation-Id, and any pertinent request details.
4. **Implement retry logic**: For transient errors (like rate limiting or temporary server issues), implement a retry mechanism with exponential backoff.
5. **Provide meaningful error messages to users**: Translate API errors into user-friendly messages in your application's UI.
6. **Monitor error rates**: Keep track of the frequency and types of errors you're encountering to identify and address recurring issues.
## Example: Error handling in Node.js
Here's an example of how you might handle errors when making a request to the Straddle API:
```javascript theme={null}
const Straddle = require('straddle')
const straddle = new Straddle('sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1')
async function createCharge(amount, currency, paykey) {
try {
const charge = await straddle.charges.create({
amount,
currency,
paykey,
payment_date: new Date().toISOString().split('T')[0],
consent_type: 'internet'
})
return charge
} catch (error) {
if (error.statusCode === 400) {
console.error('Invalid request:', error.message)
} else if (error.statusCode === 401) {
console.error('Authentication failed:', error.message)
} else if (error.statusCode === 429) {
console.error('Rate limit exceeded. Retrying in 5 seconds...')
await new Promise(resolve => setTimeout(resolve, 5000))
return createCharge(amount, currency, paykey)
} else {
console.error('An unexpected error occurred:', error.message)
}
throw error
}
}
createCharge(1000, 'usd', 'pk_test_TYooMQauvdEDq54NiTphI7jx')
.then(charge => console.log('Charge created:', charge.id))
.catch(error => console.error('Failed to create charge:', error))
```
This example demonstrates how to catch and handle different types of errors, including implementing a simple retry mechanism for rate limiting errors.
## Conclusion
Proper error handling is crucial for building robust applications that integrate with the Straddle API. Understand the different types of errors, implement appropriate error handling strategies, and follow best practices. This helps you create a smoother experience for your users and more easily diagnose and resolve issues when they arise.
Remember to always refer to the [API Reference](/api-reference) documentation for the most up-to-date information on error codes and handling for specific endpoints.
# Lookup funding details
Source: https://docs.straddle.com/api-reference/funding/details
get /v1/funding_events/{id}
Retrieves the details of an existing funding event. Supply the unique funding event `id`, and Straddle will return the individual transaction items that make up the funding event.
# List funding events
Source: https://docs.straddle.com/api-reference/funding/search
get /v1/funding_events
Retrieves a list of funding events for your account. This endpoint supports advanced sorting and filtering options.
# Simulate a funding event in sandbox
Source: https://docs.straddle.com/api-reference/funding/simulate
POST /v1/funding_events/simulate
Simulate a funding event for testing. This endpoint can only be used in the sandbox environment.
# Idempotency keys for safe API retries
Source: https://docs.straddle.com/api-reference/idempotency
Use the Idempotency-Key header to safely retry Straddle API requests without duplicating operations like charges or payouts. Includes best practices.
Straddle supports idempotent API requests, which means you can safely retry requests without fear of performing the same operation multiple times. This is especially important for operations that change state, like creating a payment, where duplicate requests could lead to financial discrepancies.
## Overview
Idempotency is achieved by including a unique `Idempotency-Key` header in your HTTP requests. Straddle then uses this key to detect and prevent duplicate operations. If a request with a given key has already been processed, Straddle returns the original response without re-executing the operation.
Idempotency is currently supported for **POST** and **PATCH** requests only and requires API key authentication.
## How it works
When you send a request with an `Idempotency-Key` header:
1. Straddle checks if a request with that key has been seen before.
2. If it's a new key, the request is processed normally. The key and the request's details (path, method, body hash) are stored.
3. If the key has been seen before:
* If the previous request with that key is still in progress, a `409 Conflict` error is returned, indicating a concurrent request.
* If the previous request completed and the requests are identical, the original response is replayed with an `Idempotent-Replayed: true` header.
* If the idempotency key is reused for a non-identical request, a `409 Conflict` error is returned, indicating that the key has been reused for a different request.
4. Idempotency keys are only stored for a limited period of time (\~24 hours).
## Using your idempotency key
To make an idempotent API request, include a unique string in the `Idempotency-Key` header. We require a key length of 10-40 characters.
Here's an example of how to include the `Idempotency-Key` header in your API requests:
```bash cURL theme={null}
curl -X POST https://sandbox.straddle.com/v1/charges \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-client-key-7890" \
-d '{
"amount": 100.00,
"currency": "USD",
}'
```
```javascript Node.js theme={null}
const apiKey = 'YOUR_API_KEY'
const idempotencyKey = 'unique-client-key-7890'
async function createCharge() {
const res = await fetch('https://sandbox.straddle.com/v1/charges', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey
},
body: JSON.stringify({
amount: 100.00,
currency: 'USD'
})
})
const json = await res.json()
console.log(json)
}
createCharge().catch(err => console.error('Error:', err))
```
```python Python theme={null}
import requests
api_key = 'YOUR_API_KEY'
idempotency_key = 'unique-client-key-7890'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
'Idempotency-Key': idempotency_key
}
payload = {
"amount": 100.00,
"currency": "USD"
}
response = requests.post('https://sandbox.straddle.com/v1/charges', headers=headers, json=payload)
print(response.json())
```
### Response headers (replayed)
When an identical request is successfully replayed, the response includes the original HTTP status code, original response headers, and the original response body, with an additional header:
```
HTTP/1.1 201 Created
Idempotent-Replayed: true
Content-Type: application/json
```
## Handling idempotency errors
Straddle returns specific `409 Conflict` errors in idempotency-related scenarios:
### Idempotency key reused for a different request
If you send a request with an `Idempotency-Key` that was previously used for a different request (e.g., different path, method, or request body), you receive a `409 Conflict` error.
```json theme={null}
{
"status": 409,
"type": "/conflict",
"title": "Conflict",
"detail": "Idempotency key already used for a different request."
}
```
**Recommended Action**: Generate a new, unique `Idempotency-Key` for each distinct logical operation.
### Concurrent request in progress
If you send a request with an `Idempotency-Key` that is currently being processed by another request, you receive a `409 Conflict` error.
```json theme={null}
{
"status": 409,
"type": "/conflict",
"title": "Conflict",
"detail": "Previous identical request currently in progress."
}
```
**Recommended Action**: Back off and retry the transaction with the same idempotency key. If the retry returns an unsuccessful status, you can safely retry the transaction with a new idempotency key.
### Invalid idempotency key
If the `Idempotency-Key` header is supplied and does not meet the length requirements (10-40 characters), Straddle returns a `400 Bad Request` error.
```json theme={null}
{
"status": 400,
"type": "/bad_request",
"title": "Bad Request",
"detail": "Validation failed",
"items": [
{
"detail": "The Idempotency-Key header value is not valid."
}
]
}
```
**Recommended Action**: Ensure your `Idempotency-Key` is present and meets the specified length requirements.
## Best practices
1. **Generate Unique Keys per Business Operation**: For each distinct business operation you initiate, generate a new and unique `Idempotency-Key`. Do not reuse keys across different logical actions.
2. **Use UUIDs**: Universally Unique Identifiers (UUIDs) are an excellent choice for generating idempotency keys due to their high probability of uniqueness.
3. **Handle 409 Conflicts**: Implement logic in your client to properly handle `409 Conflict` responses. For "key already used for a different request," generate a new key. For "previous identical request currently in progress," consider retrying.
4. **Key Length**: Ensure your `Idempotency-Key` is between 10 and 40 characters long.
5. **Avoid Sending Same Key with Different Data**: Never send the same `Idempotency-Key` with a different request body, path, or HTTP method. This results in a `409 Conflict` error.
## Next steps
Now that you are familiar with idempotent requests, it's time to start using them. Check out our [API Reference](/api-reference) for detailed information on available endpoints and how to use them.
# Straddle API introduction
Source: https://docs.straddle.com/api-reference/introduction
Get started with the Straddle REST API for ACH and bank payments. Learn the resource model, request and response conventions, and authentication basics.
The Straddle API is designed around REST principles. Our API features intuitive, resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and utilizes standard HTTP response codes, authentication, and verbs.
## API environments
You can use the Straddle API in sandbox mode, which doesn't affect your live data or interact with real banking networks. It's crucial to use the correct combination of API key and environment URL:
* Sandbox API keys must be used with the sandbox environment URL
* Production API keys must be used with the production environment URL
`https://sandbox.straddle.com`
Use this environment for testing and development. It doesn't affect live data or interact with real banking networks.
`https://production.straddle.com`
Use this environment for live transactions. Be cautious, as this interacts with real banking networks and affects live data.
Using mismatched keys and URLs results in authentication errors.
## Authentication
Authentication to the API is performed via HTTP Bearer Auth. Your API key should be included in the `Authorization` header of each request:
```
Authorization: Bearer YOUR_API_KEY
```
## Request format
The Straddle API accepts JSON-encoded request bodies. Make sure to set the `Content-Type` header to `application/json` when sending request data.
## Response format
Responses from the Straddle API are always JSON-encoded. Successful responses include a `data` object containing the requested information, while error responses include an `error` object with details about what went wrong.
## API limitations
The Straddle API is designed for individual object operations. Bulk updates are not supported, meaning you can work on only one object per request.
## Best practices
1. Always use HTTPS for API requests to ensure data security.
2. Include a unique `Request-Id` header with each request to help with debugging and tracking.
3. Use the `Correlation-Id` header for requests that are part of a larger operation or transaction.
4. Implement proper error handling to gracefully manage API responses.
By following these guidelines and understanding the structure of the Straddle API, you'll be well-equipped to build robust integrations with our platform.
For detailed information on specific endpoints and request/response structures, refer to the relevant sections of this API reference documentation.
## Download API specification
You can also download the raw OpenAPI specification file:
[Download OpenAPI Specification](https://straddlepublic.blob.core.windows.net/openapi-specs/openapi.json)
# Cancel a linked bank account
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/cancel
patch /v1/linked_bank_accounts/{linked_bank_account_id}/cancel
Cancels an existing linked bank account. This can be used to cancel a linked bank account before it has been reviewed. The linked bank account must be in 'created' status.
# Create a linked bank account
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/create
post /v1/linked_bank_accounts
Creates a new linked bank account associated with a Straddle account. This endpoint allows you to associate external bank accounts with a Straddle account for various payment operations such as payment deposits, payout withdrawals, and more.
# List linked bank accounts
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/list
get /v1/linked_bank_accounts
Returns a list of bank accounts associated with a specific Straddle account. The linked bank accounts are returned sorted by creation date, with the most recently created appearing first. This endpoint supports pagination to handle accounts with multiple linked bank accounts.
# Lookup a linked bank account
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/lookup
get /v1/linked_bank_accounts/{linked_bank_account_id}
Retrieves the details of a linked bank account that has previously been created. Supply the unique linked bank account `id`, and Straddle will return the corresponding information. The response includes masked account details for security purposes.
# Unmask a linked bank account
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/unmask
get /v1/linked_bank_accounts/{linked_bank_account_id}/unmask
Retrieves the unmasked details of a linked bank account that has previously been created. Supply the unique linked bank account `id`, and Straddle will return the corresponding information, including sensitive details. This endpoint needs to be enabled by Straddle for your account and should only be used when absolutely necessary.
# Update a linked bank account
Source: https://docs.straddle.com/api-reference/linkedbankaccounts/update
put /v1/linked_bank_accounts/{linked_bank_account_id}
Updates an existing linked bank account's information. This can be used to update account details during onboarding or to update metadata associated with the linked account. The linked bank account must be in 'created' or 'onboarding' status.
# Attaching metadata to Straddle objects
Source: https://docs.straddle.com/api-reference/metadata
Attach custom key-value pairs to Straddle customers, charges, and payouts using the metadata field. Learn formatting rules, limits, and use cases.
Metadata is a powerful feature in Straddle that allows you to attach custom key-value pairs to various objects. This guide explains how to use metadata effectively, its benefits, and best practices.
## What is metadata?
Metadata in Straddle is a set of key-value pairs that you can attach to objects such as customers, charges, payouts, and more. It allows you to store additional, structured information that is important for your business but isn't covered by Straddle's standard fields.
Metadata is not used by Straddle for any purpose other than storing on the object for your use in the future. It's purely for your own record-keeping.
## Benefits of using metadata
1. **Custom Data Storage**: Store information specific to your business needs.
2. **Improved Searchability**: Use metadata to filter objects in API requests.
3. **Enhanced Reporting**: Include metadata in exported reports for better analysis.
4. **Integration Flexibility**: Facilitate integrations with other systems by storing external IDs or references.
## How to use metadata
You can add metadata when creating or updating objects via the Straddle API. Here are some examples:
### Adding metadata when creating a customer
```bash cURL theme={null}
curl https://api.straddle.com/v1/customers \
-H "Authorization: Bearer sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1" \
-d email="john@example.com" \
-d metadata[order_id]="6735" \
-d metadata[customer_group]="premium"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.customers.create({
email: 'john@example.com',
metadata: {
order_id: '6735',
customer_group: 'premium'
}
}).then(customer => {
console.log(customer);
}).catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
customer = straddle.Customer.create(
email="john@example.com",
metadata={
"order_id": "6735",
"customer_group": "premium"
}
)
print(customer)
```
### Updating metadata on an existing charge
```bash cURL theme={null}
curl https://api.straddle.com/v1/charges/ch_1234567890 \
-H "Authorization: Bearer sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1" \
-d metadata[sales_rep]="Jane Doe" \
-d metadata[promotion_code]="SUMMER2023"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.charges.update('ch_1234567890', {
metadata: {
sales_rep: 'Jane Doe',
promotion_code: 'SUMMER2023'
}
}).then(charge => {
console.log(charge);
}).catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
charge = straddle.Charge.modify(
"ch_1234567890",
metadata={
"sales_rep": "Jane Doe",
"promotion_code": "SUMMER2023"
}
)
print(charge)
```
## Retrieving metadata
When you retrieve an object via the API, its metadata is included in the response. Here's an example of retrieving a customer:
```bash cURL theme={null}
curl https://api.straddle.com/v1/customers/cus_1234567890 \
-H "Authorization: Bearer sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.customers.retrieve('cus_1234567890')
.then(customer => {
console.log(customer.metadata);
})
.catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "sk_test_51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
customer = straddle.Customer.retrieve("cus_1234567890")
print(customer.metadata)
```
## Best practices
1. **Use Consistent Keys**: Establish a naming convention for your metadata keys and stick to it.
2. **Keep It Simple**: Metadata is best suited for simple key-value pairs. For complex data structures, consider storing a reference ID in metadata and keep the full data in your own database.
3. **Avoid Sensitive Data**: Don't store sensitive information (like credit card numbers or social security numbers) in metadata.
4. **Update Carefully**: When updating metadata, be aware that you're replacing the entire metadata object. To add or modify a single field without affecting others, first retrieve the current metadata, modify it, then update the object with the new metadata.
5. **Use for Searchability**: Leverage metadata for fields you'll want to search or filter by later.
## Limitations
* Metadata keys and values must be 80 characters or less.
* You can have up to 20 keys in the metadata dictionary.
* Metadata is not indexed, so searching large volumes of objects by metadata can be slow.
Changes to metadata are not versioned. Once you change a metadata value, you cannot retrieve its previous value.
## Conclusion
Metadata is a flexible and powerful feature in Straddle that allows you to customize and extend the platform to fit your specific business needs. Follow these guidelines and best practices to use metadata effectively and enhance your integration with Straddle.
For more information on how metadata behaves with specific API endpoints, refer to our [API Reference](/api-reference) documentation.
# Create an organization
Source: https://docs.straddle.com/api-reference/organizations/create
post /v1/organizations
Creates a new organization related to your Straddle integration. Organizations can be used to group related accounts and manage permissions across multiple users.
# List organizations
Source: https://docs.straddle.com/api-reference/organizations/list
get /v1/organizations
Retrieves a list of organizations associated with your Straddle integration. The organizations are returned sorted by creation date, with the most recently created organizations appearing first. This endpoint supports advanced sorting and filtering options to help you find specific organizations.
# Cancel a paykey
Source: https://docs.straddle.com/api-reference/paykeys/cancel
put /v1/paykeys/{id}/cancel
Change a paykey's status to inactive to prevent any new charges or payouts from being created using it. The action cannot be undone.
# Accept/Reject a paykey
Source: https://docs.straddle.com/api-reference/paykeys/patch_review
patch /v1/paykeys/{id}/review
Update the status of a paykey when in review status
# Lookup a paykey
Source: https://docs.straddle.com/api-reference/paykeys/retrieve
get /v1/paykeys/{id}
Retrieves the details of an existing paykey. Supply the unique paykey `id` and Straddle will return the corresponding paykey record , including the `paykey` token value and masked bank account details.
# Reveal a paykey
Source: https://docs.straddle.com/api-reference/paykeys/reveal
get /v1/paykeys/{id}/reveal
Retrieves the details of a paykey that has previously been created. Supply the unique paykey ID that was returned from your previous request, and Straddle will return the corresponding paykey information including the unmasked token.
# Review a paykey
Source: https://docs.straddle.com/api-reference/paykeys/review
get /v1/paykeys/{id}/review
Get additional details about a paykey.
# Search paykeys
Source: https://docs.straddle.com/api-reference/paykeys/search
get /v1/paykeys
Returns a list of paykeys associated with a Straddle account. This endpoint supports advanced sorting and filtering options.
# Unblock a paykey
Source: https://docs.straddle.com/api-reference/paykeys/unblock
patch /v1/paykeys/{id}/unblock
Unblocks a paykey that was previously blocked due to an R29 return code. Only paykeys blocked with R29 returns that have not been previously unblocked are eligible.
# Unmask paykey data
Source: https://docs.straddle.com/api-reference/paykeys/unmask
get /v1/paykeys/{id}/unmasked
Retrieves the unmasked details of an existing paykey. Supply the unique paykey `id` and Straddle will return the corresponding paykey record, including the unmasked bank account details. This endpoint needs to be enabled by Straddle for your account and should only be used when absolutely necessary.
This endpoint is not enabled by default.
Please contact [compliance@straddle.com](mailto:compliance@straddle.com) to request access.
# Search for all payments
Source: https://docs.straddle.com/api-reference/payments/search
get /v1/payments
Search for payments, including `charges` and `payouts`, using a variety of criteria. This endpoint supports advanced sorting and filtering options.
# Upload proof of authorization for a payout
Source: https://docs.straddle.com/api-reference/payouts/authorize
post /v1/payouts/{id}/authorization
Uploads a document as proof of authorization for a payout. Uploading again adds another entry to documents rather than replacing the previous one.
# Cancel a payout
Source: https://docs.straddle.com/api-reference/payouts/cancel
put /v1/payouts/{id}/cancel
Cancel a payout to prevent it from being processed. The status of the payout must be `created`, `scheduled`, or `on_hold`.
# Create a payout
Source: https://docs.straddle.com/api-reference/payouts/create
post /v1/payouts
Use payouts to send money to your customers.
# Hold a payout
Source: https://docs.straddle.com/api-reference/payouts/hold
put /v1/payouts/{id}/hold
Hold a payout to prevent it from being processed. The status of the payout must be `created`, `scheduled`, or `on_hold`.
# Release a payout
Source: https://docs.straddle.com/api-reference/payouts/release
put /v1/payouts/{id}/release
Release a payout from a `hold` status to allow it to be rescheduled for processing.
# Resubmit a payout
Source: https://docs.straddle.com/api-reference/payouts/resubmit
post /v1/payouts/{id}/resubmit
Retry a failed, reversed, or cancelled ACH credit by creating a new payout linked to the original transaction and retaining payment history.
# Lookup a payout
Source: https://docs.straddle.com/api-reference/payouts/retrieve
get /v1/payouts/{id}
Retrieves the details of an existing payout. Supply the unique payout `id` to retrieve the corresponding payout information.
# Update a payout
Source: https://docs.straddle.com/api-reference/payouts/update
put /v1/payouts/{id}
Update the details of a payout prior to processing. The status of the payout must be `created`, `scheduled`, or `on_hold`.
# Create a representative
Source: https://docs.straddle.com/api-reference/representatives/create
post /v1/representatives
Creates a new representative associated with an account. Representatives are individuals who have legal authority or significant responsibility within the business.
# List representatives
Source: https://docs.straddle.com/api-reference/representatives/list
get /v1/representatives
Returns a list of representatives associated with a specific account or organization. The representatives are returned sorted by creation date, with the most recently created representatives appearing first. This endpoint supports advanced sorting and filtering options.
# Lookup a representative
Source: https://docs.straddle.com/api-reference/representatives/lookup
get /v1/representatives/{representative_id}
Retrieves the details of an existing representative. Supply the unique representative ID, and Straddle will return the corresponding representative information.
# Unmask representative data
Source: https://docs.straddle.com/api-reference/representatives/unmask
get /v1/representatives/{representative_id}/unmask
Retrieves the unmasked details of a representative that has previously been created. Supply the unique representative ID, and Straddle will return the corresponding representative information, including sensitive details. This endpoint requires additional authentication and should be used with caution.
# Update a representative
Source: https://docs.straddle.com/api-reference/representatives/update
put /v1/representatives/{representative_id}
Updates an existing representative's information. This can be used to update personal details, contact information, or the relationship to the account or organization.
# Tracing API requests with Request-Id
Source: https://docs.straddle.com/api-reference/request-id
Use Request-Id and Correlation-Id headers to trace, debug, and correlate Straddle API requests across services for faster troubleshooting and support.
Request ID and Correlation ID are powerful header tools for debugging and tracing API requests in Straddle. This guide explains what they are, how to use them, and best practices for implementation.
## What are Request ID and Correlation ID?
### Request ID
A Request ID is a user-defined identifier in the header of each API request. It helps in tracking and debugging individual API calls.
### Correlation ID
A Correlation ID is a user-defined identifier in the header of each API request. It helps in tracing a sequence of operations across multiple systems or services.
## How to use Request ID and Correlation ID
You can include Request ID and Correlation ID in your API requests to Straddle by adding specific headers to your HTTP requests.
### Using Request ID and Correlation ID
Here's an example of creating a charge using the correct fields as specified in the OpenAPI schema, along with Request ID and Correlation ID:
```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/charges \
-H "Authorization: Bearer 51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1" \
-H "Request-Id: req_1234567890" \
-H "Correlation-Id: corr_abcdefghij" \
-d paykey="pk_test_TYooMQauvdEDq54NiTphI7jx" \
-d description="Example charge" \
-d amount=1000 \
-d currency="usd" \
-d payment_date="2023-09-15" \
-d consent_type="internet" \
-d "device[ip_address]=192.168.1.1" \
-d external_id="order_12345" \
-d "config[balance_check]=required"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.charges.create({
paykey: 'pk_test_TYooMQauvdEDq54NiTphI7jx',
description: 'Example charge',
amount: 1000,
currency: 'usd',
payment_date: '2023-09-15',
consent_type: 'internet',
device: {
ip_address: '192.168.1.1'
},
external_id: 'order_12345',
config: {
balance_check: 'required'
}
}, {
headers: {
'Request-Id': 'req_1234567890',
'Correlation-Id': 'corr_abcdefghij'
}
}).then(charge => {
console.log(charge);
}).catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
charge = straddle.Charge.create(
paykey="pk_test_TYooMQauvdEDq54NiTphI7jx",
description="Example charge",
amount=1000,
currency="usd",
payment_date="2023-09-15",
consent_type="internet",
device={
"ip_address": "192.168.1.1"
},
external_id="order_12345",
config={
"balance_check": "required"
},
headers={
'Request-Id': 'req_1234567890',
'Correlation-Id': 'corr_abcdefghij'
}
)
print(charge)
```
Here's an example of creating a customer:
```bash cURL theme={null}
curl https://sandbox.straddle.com/v1/customers \
-H "Authorization: Bearer 51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1" \
-H "Request-Id: req_0987654321" \
-H "Correlation-Id: corr_klmnopqrst" \
-d name="John Doe" \
-d type="individual" \
-d email="john@example.com" \
-d "address[address1]=123 Main St" \
-d "address[city]=Anytown" \
-d "address[state]=CA" \
-d "address[zip]=12345" \
-d phone="+11234567890" \
-d external_id="cust_12345" \
-d "device[ip_address]=192.168.1.1" \
-d "metadata[customer_group]=premium"
```
```javascript Node.js theme={null}
const Straddle = require('straddle');
const straddle = new Straddle('51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
straddle.customers.create({
name: 'John Doe',
type: 'individual',
email: 'john@example.com',
address: {
address1: '123 Main St',
city: 'Anytown',
state: 'CA',
zip: '12345'
},
phone: '+11234567890',
external_id: 'cust_12345',
device: {
ip_address: '192.168.1.1'
},
metadata: {
customer_group: 'premium'
}
}, {
headers: {
'Request-Id': 'req_0987654321',
'Correlation-Id': 'corr_klmnopqrst'
}
}).then(customer => {
console.log(customer);
}).catch(error => {
console.error(error);
});
```
```python Python theme={null}
import straddle
straddle.api_key = "51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1"
customer = straddle.Customer.create(
name="John Doe",
type="individual",
email="john@example.com",
address={
"address1": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
phone="+11234567890",
external_id="cust_12345",
device={
"ip_address": "192.168.1.1"
},
metadata={
"customer_group": "premium"
},
headers={
'Request-Id': 'req_0987654321',
'Correlation-Id': 'corr_klmnopqrst'
}
)
print(customer)
```
## Retrieving Request ID and Correlation ID
Straddle includes the Request ID and Correlation ID (if provided) in the response headers of every API request.
* Request ID: `Request-Id`
* Correlation ID: `Correlation-Id`
You can retrieve these headers from the API response to log them or use them for debugging purposes.
## Best practices
1. **Generate Unique IDs**: Ensure that your Request IDs and Correlation IDs are unique. UUIDs are a good choice for this.
2. **Consistent Usage**: Use Request IDs for every API call, and use Correlation IDs for all requests related to a single operation or transaction.
3. **Logging**: Log both Request IDs and Correlation IDs in your application logs. This makes it easier to trace requests across your systems and Straddle.
4. **Error Handling**: Include the Request ID and Correlation ID when logging errors or exceptions. This helps in debugging issues more effectively.
5. **Support Communication**: When contacting Straddle support about a specific API request, always include the Request ID and Correlation ID (if applicable).
## Implementation example
Here's an example of how you might implement Request ID and Correlation ID in a real-world scenario:
```javascript Node.js theme={null}
const Straddle = require('straddle');
const { v4: uuidv4 } = require('uuid');
const straddle = new Straddle('51NBBbbDBkrcnHrnR0nBGsOvFHQrM0n8T1FKZmAUWbJqq8oRsAM3dEZzBIbHwzKrVUUFOyRvX1Ib8Sn3VWWQMW00r300IIrGBWb1');
async function processOrder(orderDetails) {
const correlationId = uuidv4();
try {
// Create customer
const customer = await straddle.customers.create({
name: orderDetails.name,
type: 'individual',
email: orderDetails.email,
phone: orderDetails.phone,
external_id: orderDetails.customerId,
device: {
ip_address: orderDetails.ipAddress
}
}, {
headers: {
'Correlation-Id': correlationId,
'Request-Id': uuidv4()
}
});
// Create charge
const charge = await straddle.charges.create({
paykey: orderDetails.paykey,
amount: orderDetails.amount,
currency: orderDetails.currency,
payment_date: new Date().toISOString().split('T')[0], // Today's date
consent_type: 'internet',
device: {
ip_address: orderDetails.ipAddress
},
external_id: orderDetails.orderId
}, {
headers: {
'Correlation-Id': correlationId,
'Request-Id': uuidv4()
}
});
console.log(`Order processed successfully. Charge ID: ${charge.id}`);
} catch (error) {
console.error(`Error processing order. Correlation ID: ${correlationId}`, error);
}
}
processOrder({
name: 'Jane Smith',
email: 'jane@example.com',
phone: '+11234567890',
customerId: 'cust_67890',
ipAddress: '192.168.1.1',
amount: 2000,
currency: 'usd',
paykey: 'TYooMQauvdEDq54NiTphI7jx',
orderId: 'order_54321'
});
```
In this example, you generate a unique Correlation ID for the entire order processing operation, and unique Request IDs for each API call. This allows you to trace the entire order process across multiple API calls.
## Conclusion
Using Request ID and Correlation ID effectively can significantly improve your ability to debug and trace API requests when integrating with Straddle. These best practices help you monitor your integration, troubleshoot issues, and communicate effectively with Straddle support when needed.
For more information on how Request ID and Correlation ID behave with specific API endpoints, refer to our [API Reference](/api-reference) documentation.
# Straddle API response format
Source: https://docs.straddle.com/api-reference/response-structure
Understand the JSON envelope for Straddle API responses, including the data, meta, and error fields, plus pagination metadata for list endpoints.
Understanding the structure of API responses is crucial for effectively integrating with the Straddle API. This guide outlines the standard format for successful requests, paginated responses, and error responses.
## Successful requests
For successful requests, the Straddle API returns a JSON object with the following structure:
* `meta`: Contains metadata about the request.
* `response_type`: Indicates the type of data returned (e.g., "object" or "array").
* `data`: Contains the actual payload of the response.
### Example: Single object response
```json JSON theme={null}
{
"meta": {
"api_request_id": "f1b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b"
},
"response_type": "object",
"data": {
"id": "1",
"name": "John Doe",
"email": "john.doe@gmail.com",
"dob": "1980-01-01",
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "NY",
"zip": "12345"
}
}
}
```
### Key points
* The `data` property contains the main payload.
* `response_type` is set to "object" for single item responses.
* Field names use whole words, except for common acronyms (e.g., dob, SSN, URL).
* IDs are represented as strings.
## Paginated responses
For requests that return lists of data (e.g., a list of customers), the response structure is similar but includes pagination information:
* `data` contains an array of objects, typically with summarized information.
* `response_type` is set to "array".
* `meta` includes additional pagination-related information.
### Example: Paginated response
```json JSON theme={null}
{
"meta": {
"api_request_id": "f1b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"page_number": 4,
"page_size": 50,
"total_items": 1500,
"sort_order": "asc",
"sort_by": "name"
},
"response_type": "array",
"data": [
{
"id": "c1b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"label": "John Doe",
"name": "John Doe",
"email": "john.doe@gmail.com"
},
{
"id": "a9b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"name": "Steven Martin",
"email": "steve@martinco.com"
},
{
"id": "f6b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b",
"name": "John Doe",
"email": "john.doe@gmail.com"
}
]
}
```
### Pagination metadata
The `meta` object in paginated responses includes:
* `page_number`: Current page number
* `page_size`: Number of items per page
* `total_items`: Total number of items across all pages
* `sort_order`: Sorting order ("asc" or "desc")
* `sort_by`: Field used for sorting
## Failed requests
For failed requests, the Straddle API uses HTTP status codes to indicate the nature of the error:
* 4xx status codes: Used for client-side errors (e.g., validation errors, permission issues)
* 5xx status codes: Used for server-side errors
The response structure for errors is different from successful requests:
* There is no `data` property.
* `response_type` is set to "error".
* An `error` object provides details about the error.
### Example: Error response
```json JSON theme={null}
{
"meta": {
"api_request_id": "f1b1b1b1-1b1b-1b1b-1b1b-1b1b1b1b1b1b"
},
"response_type": "error",
"error": {
"status": 400,
"type": "/field_validation",
"title": "Invalid input data",
"detail": "The request contains invalid field values",
"items": [
{
"reference": "#WS01",
"detail": "Payment window has closed for the day."
},
{
"reference": "representative/2/email",
"detail": "Email address must be unique"
},
{
"reference": "representative/3/email",
"detail": "Email address must be unique"
}
]
}
}
```
### Error object structure
The `error` object in error responses includes:
* `status`: HTTP status code (integer)
* `type`: Predefined general type of error (e.g., "/field\_validation")
* `title`: Generic message for this type of issue
* `detail`: Specific message regarding this exact request
* `items`: Array of error objects with more specific details
Each error item in the `items` array contains:
* `reference`: Identifier for the error (e.g., field name, error code)
* `detail`: Detailed description of the specific error
## Best practices for handling responses
1. **Check `response_type`**: Always check the `response_type` to determine how to parse the response.
2. **Handle Pagination**: When working with paginated responses, use the metadata to implement proper pagination in your application.
3. **Error Handling**: Parse the `error` object in failed requests to provide meaningful feedback to users or for debugging.
4. **Use `api_request_id`**: Log the `api_request_id` for all requests. This is crucial for troubleshooting and communicating with Straddle support.
5. **Parsing Data**: When working with successful responses, always access the payload through the `data` property.
## Conclusion
Understanding the Straddle API response format is key to building robust integrations. By following this structure, you can effectively handle successful responses, paginate through large datasets, and gracefully manage errors in your applications.
For more detailed information on specific API endpoints and their responses, refer to our [API Reference](/api-reference) documentation.
# Node.js SDK for Straddle
Source: https://docs.straddle.com/api-reference/sdk/node
Install and configure the official Straddle Node.js SDK. Authenticate, make API calls, handle errors, and integrate ACH payments in JavaScript or TypeScript.
The Straddle Node.js SDK provides type-safe access to the Straddle API, with built-in TypeScript support and convenient methods for all API operations.
The SDK includes comprehensive TypeScript definitions and supports all modern JavaScript environments including Node.js, Deno, and Bun.
## Installation
Install the SDK using npm:
```bash theme={null}
npm install @straddlecom/straddle
```
Or using yarn:
```bash theme={null}
yarn add @straddlecom/straddle
```
## Setup and configuration
Import the appropriate client based on your needs:
```typescript theme={null}
import Straddle from '@straddlecom/straddle';
```
Create a new instance of the Straddle client:
```typescript theme={null}
const client = new Straddle({
apiKey: process.env['STRADDLE_API_KEY'],
environment: 'sandbox', // or 'production'
});
```
Never hardcode your API key directly in your code. Use environment variables or a secure configuration
management system.
## Implementation examples
For account customers (non-platform), the flow is simpler as the account context is inferred from the API key:
```typescript theme={null}
import Straddle from '@straddlecom/straddle';
async function accountFlow() {
const client = new Straddle({
apiKey: process.env['STRADDLE_API_KEY'],
environment: 'sandbox'
});
// 1. Create a customer
const customer_response = await client.customers.create({
device: {
ip_address: '192.168.0.1'
},
email: 'customer@example.com',
name: 'Customer Name',
phone: '+15555555555',
type: 'individual'
});
const customer = customer_response.data;
// 2. Link a bank account
const paykey_response = await client.bridge.link.bankAccount({
customer_id: customer.id,
routing_number: '011000028',
account_number: '000123456789',
account_type: 'checking'
});
const paykey = paykey_response.data;
// 3. Create a charge
const charge = await client.charges.create({
amount: 1,
config: {
balance_check: 'required'
},
consent_type: 'internet',
currency: 'USD',
description: 'Monthly subscription fee',
device: {
ip_address: '192.168.1.1'
},
external_id: 'external_id',
paykey: paykey.paykey,
payment_date: '2025-01-30'
});
}
accountFlow().catch(console.error);
```
This example demonstrates the complete flow for Embed customers:
```typescript theme={null}
import Straddle from '@straddlecom/straddle';
async function embedFlow() {
const client = new Straddle({
apiKey: process.env['STRADDLE_API_KEY'],
environment: 'sandbox'
});
// 1. Create an organization
const org_response = await client.embed.organizations.create({
name: 'SDK Test Organization in Sandbox'
});
const organization = org_response.data;
// 2. Create an account for the organization
const account_response = await client.embed.accounts.create({
organization_id: organization.id,
account_type: 'business',
business_profile: {
name: 'Last SDK Test',
website: 'straddle.com'
},
access_level: 'standard'
});
const account = account_response.data;
// 3. Create a customer
const customer_response = await client.customers.create({
"Straddle-Account-Id": account.id,
device: {
ip_address: '192.168.0.1'
},
email: 'customer@example.com',
name: 'Customer Name',
phone: '+15555555555',
type: 'individual'
});
const customer = customer_response.data;
// 4. Link a bank account
const paykey_response = await client.bridge.link.bankAccount({
"Straddle-Account-Id": account.id,
customer_id: customer.id,
routing_number: '011000028',
account_number: '000123456789',
account_type: 'checking'
});
const paykey = paykey_response.data;
// 5. Create a charge
const charge = await client.charges.create({
"Straddle-Account-Id": account.id,
amount: 1,
config: {
balance_check: 'required'
},
consent_type: 'internet',
currency: 'USD',
description: 'Monthly subscription fee',
device: {
ip_address: '192.168.1.1'
},
external_id: 'external_id',
paykey: paykey.paykey,
payment_date: '2025-01-30'
});
console.log(charge.data);
}
embedFlow().catch(console.error);
```
## Key features
Complete TypeScript definitions for all request params and response fields, providing excellent IDE support.
Modern promise-based API with async/await support for clean, readable code.
Built-in support for automatic pagination, making it easy to handle large result sets.
Comprehensive error types and helpful error messages for better debugging and error recovery.
## Error handling
The SDK provides specific exception types for different error cases:
```typescript theme={null}
try {
const charge = await client.charges.create({
amount: 1000,
currency: 'USD',
// ... other required params
});
} catch (error) {
if (error instanceof Straddle.APIError) {
console.log(error.status); // HTTP status code
console.log(error.message); // Error message
}
}
```
Common error types include:
* `BadRequestError` (400)
* `UnprocessableEntityError` (422)
* `AuthenticationError` (401)
* `PermissionDeniedError` (403)
* `NotFoundError` (404)
* `RateLimitError` (429)
* `InternalServerError` (>500)
Configure request timeouts:
```typescript theme={null}
// Simple timeout
const client = new Straddle({
timeout: 20 * 1000 // 20 seconds
});
// Per-request timeout
await client.charges.create({
// ... params
}, {
timeout: 5 * 1000 // 5 seconds
});
```
## SDK requirements
Node.js 18 LTS or higher
TypeScript >= 4.5
For more detailed information about the SDK structure and usage, refer to our [NPM Package](https://www.npmjs.com/package/@straddlecom/straddle).
# Python SDK for Straddle
Source: https://docs.straddle.com/api-reference/sdk/python
Install and configure the official Straddle Python SDK. Authenticate, make API calls, handle errors, and integrate ACH payments into your Python application.
The Straddle Python SDK provides convenient access to the Straddle API from any Python application. The SDK includes type definitions and offers both synchronous and asynchronous clients powered by httpx.
The SDK supports Python 3.8+ and provides comprehensive type hints through TypedDict and Pydantic models.
## Installation
Install the SDK using pip:
```bash theme={null}
pip install straddle
```
For development environments, we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/) to manage your API keys:
```bash theme={null}
pip install python-dotenv
```
## Setup and configuration
Import the appropriate client based on your needs:
```python theme={null}
from straddle import AsyncStraddle
```
Create a new instance of the Straddle client:
```python theme={null}
client = AsyncStraddle(
api_key=os.environ.get("STRADDLE_API_KEY"),
environment="sandbox", # or "production"
)
```
Never hardcode your API key directly in your code. Use environment variables or a secure configuration
management system.
## Implementation examples
For account customers (non-platform), the flow is simpler as the account context is inferred from the API key:
```python theme={null}
import asyncio
from straddle import AsyncStraddle
from pydantic.v1.datetime_parse import parse_date
from straddle.types import DeviceUnmaskedV1Param
async def account_flow():
client = AsyncStraddle(
api_key=os.environ.get("STRADDLE_API_KEY"),
environment="sandbox"
)
# 1. Create a customer
customer_response = await client.customers.create(
device=DeviceUnmaskedV1Param(ip_address="192.168.0.1"),
email="customer@example.com",
name="Customer Name",
phone="+15555555555",
type="individual"
)
customer = customer_response.data
# 2. Link a bank account
paykey_response = await client.bridge.link.bank_account(
customer_id=customer.id,
routing_number="011000028",
account_number="000123456789",
account_type="checking"
)
paykey = paykey_response.data
# 3. Create a charge
charge = await client.charges.create(
amount=1,
config={"balance_check": "required"},
consent_type="internet",
currency="USD",
description="Monthly subscription fee",
device={"ip_address": "192.168.1.1"},
external_id="external_id",
paykey=paykey.paykey,
payment_date=parse_date("2025-01-30")
)
print(charge.data)
if __name__ == '__main__':
asyncio.run(account_flow())
```
This example demonstrates the complete flow for Embed customers using the async client:
```python theme={null}
import asyncio
from straddle import AsyncStraddle
from pydantic.v1.datetime_parse import parse_date
from straddle.types import DeviceUnmaskedV1Param
from straddle.types.embed import BusinessProfileV1Param
async def embed_flow():
client = AsyncStraddle(
api_key=os.environ.get("STRADDLE_API_KEY"),
environment="sandbox"
)
# 1. Create an organization
org_response = await client.embed.organizations.create(
name="SDK Test Organization in Sandbox",
)
organization = org_response.data
# 2. Create an account for the organization
account_response = await client.embed.accounts.create(
organization_id=organization.id,
account_type="business",
business_profile=BusinessProfileV1Param(
name="SDK Test",
website="straddle.com"
),
access_level="standard"
)
account = account_response.data
# 3. Create a customer
customer_response = await client.customers.create(
straddle_account_id=account.id,
device=DeviceUnmaskedV1Param(ip_address="192.168.0.1"),
email="customer@example.com",
name="Customer Name",
phone="+15555555555",
type="individual"
)
customer = customer_response.data
# 4. Link a bank account
paykey_response = await client.bridge.link.bank_account(
straddle_account_id=account.id,
customer_id=customer.id,
routing_number="011000028",
account_number="000123456789",
account_type="checking"
)
paykey = paykey_response.data
# 5. Create a charge
charge = await client.charges.create(
straddle_account_id=account.id,
amount=1,
config={"balance_check": "required"},
consent_type="internet",
currency="USD",
description="Monthly subscription fee",
device={"ip_address": "192.168.1.1"},
external_id="external_id",
paykey=paykey.paykey,
payment_date=parse_date("2025-01-30"),
)
print(charge.data)
if __name__ == '__main__':
asyncio.run(embed_flow())
```
## Key features
Built-in type hints with TypedDict for requests and Pydantic models for responses, providing excellent IDE
support and catching errors early.
First-class async/await support through the AsyncStraddle client, perfect for high-performance applications.
Built-in support for automatic pagination, making it easy to handle large result sets.
Comprehensive error types and helpful error messages for better debugging and error recovery.
## Error handling
The SDK provides specific exception types for different error cases:
```python theme={null}
try:
charge = await client.charges.create(
amount=1000,
currency="USD",
# ... other required params
)
except straddle.APIConnectionError as e:
print("Connection error:", e.__cause__)
except straddle.RateLimitError as e:
print("Rate limit exceeded:", e.status_code)
except straddle.APIStatusError as e:
print("API error:", e.status_code)
print("Response:", e.response)
```
Common error types include:
* `BadRequestError` (400)
* `UnprocessableEntityError` (422)
* `AuthenticationError` (401)
* `PermissionDeniedError` (403)
* `NotFoundError` (404)
* `RateLimitError` (429)
* `InternalServerError` (>500)
Configure request timeouts:
```python theme={null}
import httpx
# Simple timeout
client = AsyncStraddle(timeout=20.0) # 20 seconds
# Detailed timeout configuration
client = AsyncStraddle(
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0)
)
```
## SDK requirements
Python 3.8 or higher
For more detailed information about the SDK structure and usage, refer to our [Pypi Package](https://pypi.org/project/straddle/).
# Ruby SDK for Straddle
Source: https://docs.straddle.com/api-reference/sdk/ruby
Install and configure the official Straddle Ruby SDK. Authenticate, make API calls, handle errors, and integrate ACH payments into your Ruby application.
The Straddle Ruby library provides convenient access to the Straddle REST API from any Ruby 3.2.0+ application. The library includes comprehensive support for all API endpoints with built-in error handling.
The SDK supports Ruby 3.2.0+ and provides a clean, idiomatic Ruby interface to the Straddle API.
## Installation
Install the SDK by adding it to your application's `Gemfile`:
```ruby theme={null}
gem "straddle"
```
Then run:
```bash theme={null}
bundle install
```
For development environments, we recommend using [dotenv](https://github.com/bkeepers/dotenv) to manage your API keys:
```ruby theme={null}
gem "dotenv", groups: [:development, :test]
```
## Setup and configuration
Require the necessary gems in your Ruby application:
```ruby theme={null}
require "bundler/setup"
require "straddle"
```
Create a new instance of the Straddle client:
```ruby theme={null}
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"], # This is the default and can be omitted
environment: "sandbox" # or "production", defaults to "sandbox"
)
```
Never hardcode your API key directly in your code. Use environment variables or a secure configuration
management system.
## Implementation examples
The Straddle Ruby SDK uses symbols for hash keys in method parameters. This follows Ruby conventions and provides better performance than string keys.
For account customers (non-platform), the flow is simpler as the account context is inferred from the API key:
```ruby theme={null}
require "bundler/setup"
require "straddle"
# Initialize the client
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"],
environment: "sandbox"
)
# 1. Create a customer
customer_response = straddle.customers.create(
device: { ip_address: "192.168.0.1" },
email: "customer@example.com",
name: "Customer Name",
phone: "+15555555555",
type: "individual"
)
customer = customer_response.data
# 2. Link a bank account
paykey_response = straddle.bridge.link.bank_account(
customer_id: customer.id,
routing_number: "011000028",
account_number: "000123456789",
account_type: "checking"
)
paykey = paykey_response.data
# 3. Create a charge
charge = straddle.charges.create(
amount: 100, # Amount in cents ($1.00)
config: { balance_check: "required" },
consent_type: "internet",
currency: "USD",
description: "Monthly subscription fee",
device: { ip_address: "192.168.1.1" },
external_id: "external_id",
paykey: paykey.paykey,
payment_date: "2025-01-30" # Can also use Date objects: Date.new(2025, 1, 30) # Can also use Date objects: Date.new(2025, 1, 30)
)
puts charge.data
```
This example demonstrates the complete flow for Embed customers:
```ruby theme={null}
require "bundler/setup"
require "straddle"
# Initialize the client
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"],
environment: "sandbox"
)
# 1. Create an organization
org_response = straddle.embed.organizations.create(
name: "SDK Test Organization in Sandbox"
)
organization = org_response.data
# 2. Create an account for the organization
account_response = straddle.embed.accounts.create(
organization_id: organization.id,
account_type: "business",
business_profile: {
name: "SDK Test",
website: "straddle.com"
},
access_level: "standard"
)
account = account_response.data
# 3. Create a customer
customer_response = straddle.customers.create(
straddle_account_id: account.id,
device: { ip_address: "192.168.0.1" },
email: "customer@example.com",
name: "Customer Name",
phone: "+15555555555",
type: "individual"
)
customer = customer_response.data
# 4. Link a bank account
paykey_response = straddle.bridge.link.bank_account(
straddle_account_id: account.id,
customer_id: customer.id,
routing_number: "011000028",
account_number: "000123456789",
account_type: "checking"
)
paykey = paykey_response.data
# 5. Create a charge
charge = straddle.charges.create(
straddle_account_id: account.id,
amount: 100, # Amount in cents ($1.00)
config: { balance_check: "required" },
consent_type: "internet",
currency: "USD",
description: "Monthly subscription fee",
device: { ip_address: "192.168.1.1" },
external_id: "external_id",
paykey: paykey.paykey,
payment_date: "2025-01-30"
)
puts charge.data
```
## Key features
Clean, Ruby-style interface following community conventions with snake\_case methods and intuitive hash parameters.
The client is thread-safe, allowing you to share a single instance across multiple threads in your application.
Built-in retry logic for transient errors with configurable retry strategies.
Comprehensive error classes that map to HTTP status codes for precise error handling.
## Error handling
The SDK provides specific exception types for different error cases:
```ruby theme={null}
begin
charge = straddle.charges.create(
amount: 1000,
currency: "USD",
# ... other required params
)
rescue Straddle::Errors::BadRequestError => e
puts "Bad request: #{e.message}"
puts "Status: #{e.status_code}"
puts "Response body: #{e.response_body}" if e.respond_to?(:response_body)
rescue Straddle::Errors::UnprocessableEntityError => e
puts "Validation error: #{e.message}"
puts "Errors: #{e.errors}" if e.respond_to?(:errors)
rescue Straddle::Errors::AuthenticationError => e
puts "Authentication failed: #{e.message}"
rescue Straddle::Errors::PermissionDeniedError => e
puts "Permission denied: #{e.message}"
rescue Straddle::Errors::NotFoundError => e
puts "Resource not found: #{e.message}"
rescue Straddle::Errors::RateLimitError => e
puts "Rate limit exceeded: #{e.message}"
puts "Retry after: #{e.retry_after}" if e.respond_to?(:retry_after)
rescue Straddle::Errors::InternalServerError => e
puts "Server error: #{e.message}"
rescue Straddle::Errors::APIError => e
# Catch all other API errors
puts "API error: #{e.message}"
end
```
Common error types include:
* `BadRequestError` (400)
* `UnprocessableEntityError` (422)
* `AuthenticationError` (401)
* `PermissionDeniedError` (403)
* `NotFoundError` (404)
* `RateLimitError` (429)
* `InternalServerError` (>=500)
Configure request timeouts:
```ruby theme={null}
# Configure timeout in seconds
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"],
timeout: 30 # 30 seconds
)
# Or configure with more granular settings
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"],
timeout: {
connect: 5,
read: 30,
write: 10
}
)
```
Configure automatic retries:
```ruby theme={null}
straddle = Straddle::Client.new(
api_key: ENV["STRADDLE_API_KEY"],
max_retries: 3,
retry_delay: 1.0 # seconds
)
```
## SDK requirements
Ruby 3.2.0 or higher
Bundler for dependency management
For more detailed information about the SDK structure and usage, refer to our [API Documentation](https://docs.straddle.com) and [GitHub repository](https://github.com/straddleio/straddle-ruby).
# 2024 changelog and product updates
Source: https://docs.straddle.com/changelog/updates/2024
Product updates, new features, and platform announcements for the Straddle ACH payments and identity verification platform throughout 2024.
> Keep track of Straddle's latest updates and improvements
## Integrations
* **Direct Webhook Connections:** Route Straddle notifications directly to Slack, Microsoft Teams, Discord, and HubSpot without needing custom HTTP endpoints. Learn more on the [Integrations page](/integrations/overview).
## Documentation
* **Plaid Link Guide:** Published a [step-by-step guide](/integrations/open-banking/plaid) for connecting Straddle with Plaid Link.
## Announcing Straddle!
We're excited to announce the public launch of Straddle! We're building modern account-to-account payments that actually work, handling the full stack from identity verification to open banking connections to money movement.
## Community
* **Developer Slack Launched:** We launched our [developer community on Slack](https://straddlers.slack.com) - a space for real talk, early access, code samples, and shaping our roadmap. Join us!
## Security & Compliance
* **SOC 2 Type II Certified:** We achieved our SOC 2 Type II certification, proving our commitment to security. View the report in our [Trust Center](https://trust.straddle.com/item/soc-2-type-ii-attestation).
# 2025 changelog and product updates
Source: https://docs.straddle.com/changelog/updates/2025
Product updates, new features, and platform announcements for the Straddle ACH payments and identity verification platform throughout 2025.
# We build for you.
**You'll See Fewer Paykey Rejections**
You can now manually review certain Paykeys that would normally auto-reject. These paykeys are created with a `review` status, allowing you to `accept` or `reject` them either in the dashboard or programmatically via our API.
**Get the Full Picture on Every Verification**
Retrieve comprehensive verification data to understand the "why" behind every paykey status and streamline your approval workflow.
```json theme={null}
"verificationDetails": {
"id": "456e7890-e89b-12d3-a456-426614174001",
"decision": "review",
"messages": {
"NM01": "Account Holder is not a match for Customer."
},
"codes": ["NM01"],
"breakdown": {
"nameMatch": {
"decision": "review",
"reason": "Account Holder is not a match for Customer.",
"matchedName": "John Smith",
"correlationScore": 0.21,
"namesOnAccount": ["John Smith", "Jane Smith"]
}
```
**Account Balance Updates**
For accounts linked using an open banking token or Bridge, you can now receive balance updates when the following events occur:
* When a new Paykey is created
* When the new refresh endpoint is explicitly called, at most once per hour
* When a charge or payout is created, if the balance was last updated more than one hour ago
You will receive the balance update within [Paykey webhook events](https://straddle.dev/api-reference#webhook/post/paykeyeventv1).
**Trigger Re-Verification**
You are able to set the paykey's status back to pending triggering automated re-verification.
**Sandbox Outcome for Paykey Review Status**
To test the new review status, set the sandbox outcome to "review" when creating a Paykey.
Check out this guide to learn more: [Paykey Guide](https://docs.straddle.io/guides/bridge/paykeys)
## Idempotent requests and custom metadata
* You can now add custom `metadata` when creating or updating representatives. This `metadata` will be included in the response when retrieving `representative` details via a GET request.
* To prevent duplicate requests, we've introduced idempotent requests. Include a unique `Idempotency-Key` header in your HTTP requests to utilize this feature.
* We've added dark mode to the onboarding form. It'll automatically match whatever theme you're using on your device.
## Ruby SDK and overall updates
* We've released a new version of our existing Node and Python SDKs.
* We've added a new Ruby SDK for Straddle, check it out here: [Ruby SDK](/api-reference/sdk/ruby).
## Sandbox Simulations
* We've improved the ability to simulate various scenarios in the sandbox environment when integrating with Straddle. Follow this guide to learn more about it [Sandbox Simulations](/guides/resources/sandbox-paybybank).
## Quiltt Integration
* We've built a new integration to our Open Banking stack with our partner [Quiltt](https://www.quiltt.io/). This allows you to bring your existing Open Banking connections from **Quiltt Connector** to integrate with Straddle using the [Straddle Bridge API](/guides/bridge/quiltt-token).
## Zapier Integration
* You can now integrate Straddle with Zapier to trigger automated workflows when events occur in Straddle. Check out the new docs for [Zapier integration](/integrations/webhooks/zapier).
## Straddle Reputation
We're excited to introduce Straddle Reputation, a powerful new fraud prevention system that leverages consortium data to identify repeat bad actors and stop friendly fraud before it happens.
### What's New
**Data-driven Fraud Detection**
Access risk signals derived from a vast network of financial institutions, fintechs, neobanks, lenders, gaming platforms, and telcos across the US.
**Friendly Fraudster Identification**
Identify consumers with histories of fraudulent activities across multiple institutions before they can harm your business.
**Reputation Risk Score**
Receive a numerical risk score specifically designed to identify repeat bad actors, enabling more informed decisioning.
**Historical Insights**
Access detailed transaction history metrics including ACH fraud, card disputes, account closures, and more to understand the full context of risk signals.
**Reputation Codes**
Interpret risk with specific reason codes that explain exactly which risk factors were identified for a consumer identity.
**Built Into Customer Profiles**
Reputation data is automatically integrated into every customer profile, providing seamless access to risk intelligence throughout your payment flows.
**New Documentation**
[**How Straddle Reputation helps fight friendly fraud**](https://docs.straddle.com/guides/identity/reputation)
## Marketplace Platforms
We've evolved Straddle Embed to support two distinct platform types with different customer relationship models.
### What's New
[**Marketplace
Platforms**](https://docs.straddle.com/guides/embed/overview#marketplace-platform-model)
A new model enabling platform-level [customers](https://docs.straddle.com/guides/identity/customers) who can transact
with multiple accounts (sellers).
[**SaaS
Platform**](https://docs.straddle.com/guides/embed/overview#saas-platform-model)
Maintains the existing 1:1 customer-to-account relationship for vertical SaaS providers whose end users interact with individual businesses.
**Platform-Level Customers**
Marketplace platforms can now create customers at the platform level with centralized profiles, allowing seamless transactions across multiple sellers.
**New Documentation**
Learn more about both models in our [Straddle Embed: Platform
Guide](https://docs.straddle.com/guides/embed/overview).
## Payment Reporting API
We've launched a powerful new reporting endpoint that makes it easier to search, filter, and analyze your payment data.
### What's New
**Unified Payment Search**
Search across both charges and payouts with a single API endpoint, simplifying how you access and analyze your payment data.
**Advanced Filtering**
Filter payments by type, status, amount ranges, date ranges, customer IDs, and more to find exactly the transactions you need.
**Flexible Sorting**
Sort results by created date, payment date, effective date, amount, or ID in ascending or descending order.
**Pagination Support**
Control result set size with customizable page size and pagination to efficiently process large datasets.
**Full-Text Search**
Find payments using free-text search across relevant payment fields for quick information retrieval.
**New Documentation**
Check out the new reporting endpoint in our [API Reference](https://docs.straddle.com/api-reference/payments/search).
## API Logs
Introducing detailed and searchable API logs within the Straddle Dashboard to help you monitor and troubleshoot your integration.
### What's New
**Advanced Search and Filtering**
Find the exact requests you need with powerful filtering by method, status code, timestamp, and duration.
**Faster Troubleshooting**
Identify and resolve integration issues more efficiently with complete request/response data and status codes available in real time.
**Improved Observability**
Quickly identify bottlenecks or errors across your payment flows with comprehensive performance metrics and response times.
**Historical Data Access**
Access up to 30 days of historical API logs to track down intermittent issues or analyze usage patterns over time.
## Dashboard V2
We've completely rebuilt the [Straddle dashboard](https://dashboard.straddle.com) from the ground up, focusing on developer
experience, workflow efficiency, and powerful insights to help your team move faster.
### What's New
**Work smarter, not harder**
Navigate with confidence through our intuitive layout designed for developer productivity. Access critical information with fewer clicks.
**Business metrics**
Transform complex data into actionable insights with our improved interactive charts, real-time metrics, and comprehensive reporting tools. Spot trends faster and make data-driven decisions with confidence.
**Built for speed**
Experience lightning-fast response times with our rebuilt architecture. Page loads are up to 70% faster, API responses are optimized, and resource utilization is significantly reduced.
## Business Identity and Chargeback Protection
We've expanded our identity verification capabilities with a comprehensive solution specifically for business customers.
### What's New
**Business Verification Engine**
Verify business customers with advanced checks for EIN, legal business name, business address, and people associated with the business.
**Business Identity Codes**
New "BI" prefixed verification codes provide detailed insights into verification results across multiple categories including tax ID verification, address verification, entity type, and business standing.
**Chargeback Protection**
Businesses using Business Identity verification now receive chargeback protection after 48 hours for verified business customers.
**Risk Scoring**
Numerical risk scores from 0 to 1 help assess business verification status for more intelligent decision-making.
**New Documentation**
Learn more about integrating and interpreting Business Identity in our [Business Identity
guide](/guides/identity/business_identity).
## SDKs
* **Python SDK:** Launched the [Straddle Python SDK](/api-reference/sdk/python) with type definitions and sync/async clients.
* **Node.js SDK:** Launched the [Straddle Node.js SDK](/api-reference/sdk/node) with TypeScript support for Node.js, Deno, and Bun.
## Webhooks
* **Polling Endpoints:** Added the ability to get a stream of events by [polling webhook
endpoints](/webhooks/overview/polling), useful for local testing or batch processing.
* **Storage Integrations:** Send Straddle webhook data directly to AWS S3, Azure Blob Storage, or Google Cloud Storage.
## Developer Tools
* **Interactive Playground:** Launched a new interactive developer playground at [straddle.dev](https://straddle.dev).
* **Postman Collection:** Published an official Postman collection at [https://www.postman.com/strddl](https://www.postman.com/strddl).
## Website
* **New Marketing Site:** Launched a revamped marketing site at [straddle.com](https://straddle.com) with clearer
product explanations.
## Platform
* **API Status Page:** Launched a dedicated API status page at [status.straddle.com](https://status.straddle.com) with
support for email/webhook subscriptions.
# 2026 changelog and product updates
Source: https://docs.straddle.com/changelog/updates/2026
Product updates, new features, and platform announcements for the Straddle ACH payments and identity verification platform throughout 2026.
# We build for you.
**Webhooks and dashboard actions in Trace**
Trace now shows the webhooks Straddle sent for an entity and the actions your team took on it in the dashboard, next to its API calls and status changes. Every event that touched the entity reads in order on one timeline.
Calls and dashboard actions show whether a user or an API key made them. Filter the timeline to **API logs**, **User logs**, **Webhooks**, or **Entity history** to read one source at a time, and click a webhook row to see the payload your endpoint received.
**Readable traces for busy entities**
A funding event can carry hundreds of payouts. When an entity has three or more related entities of one kind, Trace keeps the three most recent on the graph and groups the rest into a cluster. Open the cluster to page through its members and add the ones you need to the graph.
**A rebuilt timeline and event lanes**
Each timeline row shows how long after the start of the trace it happened, what kind of event it is, and which entity it belongs to. Select a row to open its full details in a side panel. In **Event lanes**, columns cover only the stretches of time that had activity, and you can collapse a lane to a strip that marks where its events fall. Times display in your time zone, with Eastern Time on hover.
**User Logs**
[User Logs](https://dashboard.straddle.com/user-logs) lists every action people took in the dashboard, such as **Refund Charge** or **Review Paykey**, with the endpoint it called underneath. Search the list, sort by time or duration, and filter by user, method, or outcome. Click a user's name to see only their actions, or click an API key on API Logs to do the same for that key. Open User Logs from the developer menu in the dashboard header.
Trace and User Logs are available to users with the developer or admin role.
**Product announcements in the dashboard**
New Straddle features now appear as a card in the bottom-right corner of the [Straddle Dashboard](https://dashboard.straddle.com), so you hear about them without checking the changelog. Each card links to the full changelog entry.
Dismiss a card and it won't appear again for you. When more than one announcement is waiting, the card shows the newest first, and its arrows step through the rest.
**Handle Paykeys in Review from Bridge**
The Bridge widget's `onSuccess` callback can now return paykeys with either an `active` or `review` status. A successful callback confirms that the paykey was created, but does not guarantee that it is active.
Always inspect `payload.data.status`. Paykeys in `review` require approval or rejection in the Dashboard or through the API, and payments submitted with them remain on hold until the review is resolved. See the [Bridge widget guide](/guides/bridge/widget#3-handle-the-widget-callback) for integration guidance.
**Trace**
When a payment fails, the explanation is rarely on the payment. It's in what came before: when the customer was created, when the paykey was added, what changed along the way. Open any customer, paykey, charge, payout, or funding event in the [Straddle Dashboard](https://dashboard.straddle.com) and click **Trace logs** to get all of it on one timeline. A graph of the connected entities sits beside it.
* **Understand one customer.** Follow a customer through every paykey, payment, and status change tied to them, without opening five pages to do it.
* **Find the root cause.** Read the sequence that produced a failure instead of working backwards from the final status.
Click a row for the full request and response, a node to follow the chain, or switch to **Event lanes** for one lane per entity on a shared clock. You can also start from an ID at [Trace](https://dashboard.straddle.com/trace). See the [dashboard walkthrough](https://help.straddle.com/article/how-to-trace-an-entity-in-the-dashboard).
**Universal search**
Find any charge, payout, customer, paykey, account, or funding event from the search bar in the [Straddle Dashboard](https://dashboard.straddle.com) header. Type a partial name, email, amount, or description and results appear instantly, grouped by entity type. Press Cmd+K (Mac), Ctrl+K (Windows), or `/` to open search from anywhere in the dashboard.
The **All** tab shows top matches. Open a type tab to page through just that type. Each row shows the date and context like amount and status, so you can confirm the right record before clicking through. Search handles typos, so "Swanosn" finds "Swanson." See the [dashboard walkthrough](https://help.straddle.com/article/how-to-use-search-in-the-dashboard) for tips on searching by entity type.
**Upload proof of authorization via API**
No more email threads. When a payment is held or a bank requests evidence, upload the authorization record straight to the payment with [`POST /v1/charges/{id}/authorization`](/guides/payments/statuses#provide-proof-of-authorization) or `POST /v1/payouts/{id}/authorization`. Send a PDF, PNG, JPG, DOC, or DOCX up to 10 MB.
**Confirm receipt instantly**
The charge and payout objects return the uploaded document, and the `charge` and `payout` webhooks include it, so you know it landed without polling. See the [Proof of Authorization guide](https://help.straddle.com/article/proof-of-authorization-poa-guide) for what makes a POA compliant.
**Alerts and notifications widget**
A new widget sits at the top of the [Straddle Dashboard](https://dashboard.straddle.com) and surfaces what needs your attention. Two tabs separate action-required *Alerts* from informational *Notifications*, and every row deep-links to the page where you can investigate or resolve. See the [dashboard walkthrough](https://help.straddle.com/article/how-to-use-the-alerts-and-notifications-widget-in-the-dashboard) for the full event catalog and what each tab looks like in practice.
**Email notifications**
The same events also land in your inbox. Add one or more [mailboxes](https://help.straddle.com/article/how-to-set-up-email-notifications-in-the-dashboard) (for example `ops@yourcompany.com`) on any account, and Straddle delivers email notifications there for charge failures, items under review, blocked paykeys, and completed charges, payouts, and funding events. No webhook handler required.
Refund a successfully paid [charge](https://straddle.dev/api-reference#tag/charge/POST/v1/charges/\{id}/refund) directly from the dashboard or API. Refunds return funds to the customer's original bank account and link back to the source charge via [`related_payments`](/guides/payments/statuses#refund-paid-charges) for clean reconciliation. Partial and full refunds are both supported; one refund per charge. See the [step-by-step dashboard walkthrough](https://help.straddle.com/article/how-to-refund-a-paid-charge-in-the-dashboard).
**Get account settings via API**
Programmatically retrieve the settings for any account using the new [GET /v1/account\_settings/\{account\_id}](https://docs.straddle.com/api-reference/accounts/account-settings) endpoint. Pull configuration details directly into your own tools and dashboards without manual lookups.
**Resubmit endpoints in the API reference**
Dedicated API reference pages are now live for resubmitting [charges](https://docs.straddle.com/api-reference/charges/resubmit) and [payouts](https://docs.straddle.com/api-reference/payouts/resubmit), making it easier to integrate retry logic for failed, reversed, or cancelled payments while preserving the original bank and payment details.
You can now quickly [resubmit](/guides/payments/statuses#resubmit-failed-payments) failed, reversed, or cancelled [charges](https://straddle.dev/api-reference#tag/charge/POST/v1/charges/\{id}/resubmit) or [payouts](https://straddle.dev/api-reference#tag/payout/POST/v1/payouts/\{id}/resubmit) while automatically preserving their original bank and payment details.
**Self-Service Capabilities and Limit Management**
Account holders can now view, configure, and request changes to their payment capabilities and transaction limits directly from the dashboard or via API request, no support ticket required.
**Request Limit Increases**
From the Capabilities tab on an [Account](https://dashboard.straddle.com/accounts) page or [Company Profile](https://dashboard.straddle.com/company-profile), you can now request changes to account limits. Adjustable fields include `max_amount`, `daily_amount`, `monthly_amount`, and `monthly_count`. Submitted requests enter a compliance review workflow, and you'll be notified once a decision is made.
**Enable New Capabilities**
Request activation of additional payment types, customer types, and consent types from the same capabilities tab. You can also configure signed agreement settings to require formal contracts for high-value transactions.
**API Support**
Use the [POST /v1/accounts/capability\_requests](https://docs.straddle.com/api-reference/capabilityrequests/create) endpoint to programmatically request capability changes.
**Funding Event CSV Export**
You can now export a full breakdown of any funding event directly from the [dashboard](https://dashboard.straddle.com/funding). Request a CSV from the funding event details page and receive an itemized report in your inbox.
**Unified Login**
Access all your organizations with a single login. Seamlessly switch between them to streamline your payment operations without the hassle of managing multiple credentials.
**User Invites for Platforms**
Platform admins can now invite users to organizations directly, no support ticket required. Just head to the [Accounts](https://dashboard.straddle.com/accounts) tab, select an account, and send an invite from the Users tab.
**Introducing Straddle Ledger**
Meet the Straddle Ledger: a centralized, double-entry system built for modern finance. Get real-time visibility into every charge, payout, return, and exception with faster fund access, same-day payout capabilities, and clearer bank statements. Every state change, tracked. Every dollar, accounted for.
**Faster Liquidity**
The Straddle Ledger uses the earliest processing windows to speed up funding timelines. If using same-day ACH windows, charges post to the customer's account the same day which speeds up your funding by a day.
**Efficient Payouts**
Payouts now qualify for same-day funding when submitted by the [first same-day ACH window](https://help.straddle.com/article/same-day-ach-vs-standard-ach-cut-off-times#ach-cut-off-times). To take advantage of this, ensure your account is enabled for 'immediate' funding or contact [compliance@straddle.com](mailto:compliance@straddle.com) to request this capability.
**Clearer Bank Statements**
[Payment descriptions](https://docs.straddle.com/guides/payments/charges#param-description) now appear on bank statements with up to 80 characters of detail helping customers recognize charges at a glance.
**Real-Time Funding Visibility**
Know the moment your money moves. Funding event webhooks fire as soon as status changes and you see updates immediately in the dashboard.
**Under the Hood**
The Straddle Ledger is built for zero double-spends, always-correct balances, and real-time balance limits enforced at the ledger level. It's multi-cloud with self-healing failover, 6 replicas for consensus, and an immutable audit trail baked in from day one.
**What’s Next**
This architecture is the foundation for stored value wallets, multi-currency (including crypto), infinite accounts, and direct-to-rail payments. This is just the beginning.
**Recover Blocked Paykeys Instantly**
When a paykey is blocked (e.g. R29), your customer can't pay or get paid until it's fixed. Unblock in the dashboard once they've updated their bank settings so they can use the paykey again quickly. Note that you can only unblock a paykey once.
View blocked paykeys in the [Overview](https://dashboard.straddle.com/) tab or manage them directly from the specific [Customer](https://dashboard.straddle.com/customers) page.
**API Support for Unblocking**
Use the new [PATCH /v1/paykeys/id/unblock](https://straddle.dev/api-reference#tag/paykeys/PATCH/v1/paykeys/\{id}/unblock) endpoint to programmatically unblock eligible paykeys.
**Handling R29 Returns**
Corporate "positive pay" blocks often cause R29 returns; you can now confirm the customer has added your ACH identifier to their approved list and click Unblock Paykey in the dashboard.
# Install the Straddle plugin
Source: https://docs.straddle.com/developer-tools/agent-plugin/install
Add Straddle skills, Docs MCP, and API MCP to Claude Code, Codex, or Cursor.
Install the Straddle plugin to help your agent plan, build, and test a Straddle integration. The plugin includes Straddle skills and connections to the hosted Docs MCP and API MCP servers.
## Before you start
Prepare the following:
* **Your coding client:** Claude Code or Codex with plugin commands available, or Cursor with team marketplace access.
* **Node.js 22.18 or later:** Required for the Straddle Wizard commands on this page.
* **A sandbox API key:** Get one from the [Straddle dashboard](https://dashboard.straddle.com) to use the API MCP. Docs MCP needs no key.
For Claude Code and Codex, set `STRADDLE_API_KEY` through your secret manager or shell environment before starting the client. Desktop apps must inherit the variable in their own process. Cursor's plugin has a field for the key in **Configure**.
## Install for your client
Choose your client and complete its steps. The Straddle Wizard downloads a released plugin, verifies its checksum, and registers it with Claude Code or Codex. Cursor installs through its team marketplace.
From your project directory, run the installer and confirm its download and installation prompts:
```bash theme={null}
npx @straddlecom/wizard@latest install --client claude
```
The Wizard installs `straddle@straddle` in user scope, including both MCP server declarations.
Check the installed plugin and the Wizard's verification result:
```bash theme={null}
claude plugin list --json
npx @straddlecom/wizard@latest status --json
```
Confirm that `straddle@straddle` is enabled. In the Wizard output, find the `claude` entry in `clients` and confirm `plugin.state` is `installed` and `plugin.verified` is `true`.
Start a new Claude Code session, then enter `/mcp`. Confirm that the plugin's `straddle-api` and `straddle-docs` servers connect.
From your project directory, run the installer and confirm its download and installation prompts:
```bash theme={null}
npx @straddlecom/wizard@latest install --client codex
```
The Wizard installs `straddle@straddle` and configures API MCP to read its bearer token from `STRADDLE_API_KEY`.
Check the plugin, MCP configuration, and Wizard verification result:
```bash theme={null}
codex plugin list --json
codex mcp list --json
npx @straddlecom/wizard@latest status --json
```
Confirm that `straddle@straddle` is enabled and both `straddle-api` and `straddle-docs` appear. The API server's `bearer_token_env_var` must be `STRADDLE_API_KEY`.
In the Wizard output, find the `codex` entry in `clients` and confirm `plugin.state` is `installed` and `plugin.verified` is `true`. Start a new Codex session to load the plugin.
In the Cursor IDE, open **Add Marketplace**, then select **Import from GitHub**. Enter the repository URL, set **Scope** to **Team**, and select **Import**:
```text theme={null}
https://github.com/straddle-build/skills
```
On Enterprise plans, a team administrator must add the marketplace. Cursor follows the repository's default branch when it refreshes the marketplace.
Add **Straddle** from the imported marketplace. Open the plugin's **Configure** dialog and enter your sandbox API key in **Straddle API key** (`STRADDLE_API_KEY`).
Confirm that Cursor lists `straddle-setup`, `straddle-plan`, `straddle-integrate`, and `straddle-test`, along with the plugin's `straddle-api` and `straddle-docs` MCP servers. Reload Cursor if the servers haven't appeared, then check that their tools load.
## Check the connection
Ask your agent to use the API MCP's specification summary tool:
Use straddle-api's summarize-openapi-specs tool to summarize the available Straddle API specification.
Expect a summary of the API specification. This verifies the MCP connection and specification access. Setup checks API key configuration separately.
API MCP connects to `https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd`. Its `execute-request` tool runs Straddle API operations with your key, including writes. Keep your client's tool approval prompts enabled so you can review each request.
## Run Setup
In your project directory, select the sandbox environment and start the Straddle Wizard's Setup workflow:
```bash theme={null}
export STRADDLE_ENVIRONMENT=sandbox
npx @straddlecom/wizard@latest setup
```
Select your client and **Auto** to run the workflow in your terminal, or **Manual** for a prompt to paste into your agent. Setup checks your project, CLI, SDK, environment, and MCP connections, then writes `straddle-setup.md` with the results and next actions.
## Install skills in another client
For a client supported by the skills installer, install the skills and choose your client when prompted:
```bash theme={null}
npx skills add straddle-build/skills
```
This route copies the skills into your client. Add MCP connections separately using [Connect MCP](/developer-tools/mcp/install).
## Update or remove the plugin
For a Wizard-managed installation, use the matching client name. For example, update Claude Code's plugin:
```bash theme={null}
npx @straddlecom/wizard@latest update --client claude
```
Replace `claude` with `codex` for Codex. Restart your client, then repeat its verification steps.
To remove the plugin and its marketplace, run:
```bash theme={null}
npx @straddlecom/wizard@latest remove --client claude
```
For Codex, use `--client codex`. To also remove the client-level Straddle MCP entries, run `npx @straddlecom/wizard@latest mcp remove --client codex`.
In Cursor, refresh the team marketplace to update, or enable **Auto Refresh**. To remove the installation, uninstall **Straddle**, then remove the marketplace if your team no longer uses it.
# Use the CLI with coding agents
Source: https://docs.straddle.com/developer-tools/cli/agent-use
Discover commands, inspect context, preview requests, and consume machine-readable results.
Give your agent the installed CLI and [configured credentials and context](/developer-tools/cli/auth-context). Use runtime discovery to plan each task against the commands that version supports.
## Discover and inspect a command
Read the command description and find a payment workflow:
```bash theme={null}
straddle agent-context --pretty
straddle which "reconcile funding" --json
straddle reconcile --help
```
`agent-context` includes `schema_version`, command names and flags, authentication requirements, and `runtime_context`. It reports the selected environment and account without opening the local store. `which` searches the built-in workflow descriptions; use resource help, such as `straddle charges --help`, for API operations.
## Choose an output mode
Choose the following mode for your caller:
| Caller | Option | Behavior |
| - | - | - |
| Terminal user | Default | Readable resource tables or detail output. |
| Terminal user who wants rich formatting | `--human-friendly` | Enables rich terminal formatting and color. |
| Script that needs JSON | `--json` | Selects JSON without changing confirmation defaults. |
| Coding agent | `--agent` | Defaults to `--json --compact --no-input --no-color --yes`. |
Piped or redirected resource output uses JSON unless another supported output format is selected. Piping doesn't enable the other `--agent` defaults. `--human-friendly` keeps piped resource output in JSON.
Explicit flags override agent defaults. To keep full resource fields, use `--agent --compact=false`. To request a smaller set of fields:
```bash theme={null}
straddle payments --agent --select id,status,amount
```
`--select` applies to resource fields, not envelope paths such as `meta.source`. Streaming commands have their own output shape: `sync`, for example, emits one JSON event per line.
## Preview a request before sending it
Before a write, check the effective environment and acting account with `agent-context`, inspect the operation's help, and prepare the request body. For a charge body saved as `charge.json`:
```bash theme={null}
straddle charges create --help
straddle charges create --stdin --dry-run --agent < charge.json
```
The dry run validates required inputs and prints the request preview to stderr without sending it. Review the method, URL, account header, and body. This preview verifies request construction; the API validates permissions and payment conditions when you send the request.
`--agent` includes `--yes`, so commands that require confirmation can proceed without another prompt. Obtain approval for the exact write before removing `--dry-run`.
## Read fresh results and handle errors
For a fresh API result, bypass both local fallback and the HTTP response cache:
```bash theme={null}
straddle payments --page-size 10 --data-source live --no-cache --agent
```
List commands return one page by default. Add `--all` when the task requires every page. On reads that include provenance, inspect `meta.source` and `meta.synced_at` to distinguish API results from local data.
Capture stdout, stderr, and the process exit code separately. A failed command can report diagnostics as text on stderr even with `--agent`. Follow the [error recovery guide](/developer-tools/cli/troubleshooting#respond-to-an-error) before retrying a write.
Use `straddle api` to discover the raw interfaces. If you have a verified endpoint path, preview it with the shared credentials and account rules:
```bash theme={null}
straddle api get /v1/customers --param page_size=1 --dry-run --agent
```
After reviewing the preview, remove `--dry-run` to send the read. Add `--no-cache` when it must reach the API.
# Configure credentials and account context
Source: https://docs.straddle.com/developer-tools/cli/auth-context
Select an API key, environment, integration type, and acting account before your first API read.
Connect the [installed CLI](/developer-tools/cli/install) to the environment and account you want to work with. Start with a sandbox API key from the [Straddle dashboard](https://dashboard.straddle.com).
Choose how the CLI receives your key:
Set `STRADDLE_API_KEY` in your shell or through your secret manager. Replace the placeholder locally:
```bash theme={null}
export STRADDLE_API_KEY="YOUR_SANDBOX_API_KEY"
```
This variable overrides a token saved with `auth set-token`. Enter keys outside agent prompts and shared scripts; shell history can retain commands that contain them.
Save the key in the CLI's owner-only configuration file:
```bash theme={null}
straddle auth set-token YOUR_SANDBOX_API_KEY
```
The default file is `~/.config/straddle/config.toml`. The command contains the key, so account for shell history when entering it.
Inspect credential presence and source:
```bash theme={null}
straddle auth status --json
```
`authenticated: true` means a credential is present. `verified: false` means this check hasn't tested it against the API.
Use sandbox while building and testing:
```bash theme={null}
export STRADDLE_ENVIRONMENT=sandbox
```
Sandbox is the default. Use `production` with a production key when you're ready for production operations. A configured `STRADDLE_BASE_URL` or `base_url` can override the standard host, so verify the resolved environment in step 4.
Choose the command that matches who owns the customers and payments:
| Integration | Command | Ownership |
| - | - | - |
| Direct business | `straddle setup --type account` | One business collects or sends its own payments. |
| SaaS platform | `straddle setup --type saas` | Your clients own their customers. |
| Marketplace | `straddle setup --type marketplace` | Your platform owns the customers. |
For a SaaS or marketplace platform, select the embedded account for account-level work:
```bash theme={null}
straddle use-account ACCOUNT_ID
```
This selection stays in effect until changed. `straddle use-account --clear` returns to a context without an acting account. Direct business integrations use their key's account and omit this step.
Inspect `runtime_context.environment`, `integration_type`, and `acting_account`:
```bash theme={null}
straddle agent-context --pretty
```
Then request one customer from the selected environment:
```bash theme={null}
straddle customers list --page-size 1 --data-source live --no-cache --json
```
A successful response, including an empty list, confirms that the key can perform this operation. Resolve any [authentication or scope error](/developer-tools/cli/troubleshooting) before continuing.
## Choose an account for one command
For a platform payment read, override the saved account with `--account`:
```bash theme={null}
straddle payments --account ACCOUNT_ID --data-source live --no-cache --json
```
The CLI applies `Straddle-Account-Id` by operation and integration type. Marketplace customer, paykey, and Bridge operations use platform ownership. Account-management operations take IDs in the path or body. See [account scoping](/developer-tools/mcp/account-scoping) for the ownership rules.
Credentials live in `config.toml`; integration type and the saved account live in `platform.toml`. `STRADDLE_CONFIG` selects the credentials file and places `platform.toml` beside it. `STRADDLE_PLATFORM_CONFIG` selects the platform file explicitly. The `--config` flag changes only the credentials file.
A profile applies saved flag values to one invocation. Inspect it with `straddle profile show PROFILE_NAME`, then use `--profile PROFILE_NAME` on compatible commands. `profile use` prints values; it doesn't activate a persistent profile. Explicit flags override saved values.
A saved `account` acts as an explicit `--account`, including on commands that reject it. Run `use-account` and profile inspection without `--profile`. Profiles can also supply sync filters or `path-context`; review [sync completeness](/developer-tools/cli/local-data#check-sync-completeness) before using them for analysis.
# Install the Straddle CLI
Source: https://docs.straddle.com/developer-tools/cli/install
Install the CLI on macOS, Linux, or Windows and verify the command is available.
Install `straddle` with a package manager or a release archive. Release binaries support x64 and ARM64 on macOS, Linux, and Windows.
On macOS, install from the Straddle tap:
```bash theme={null}
brew install straddle-build/tap/straddle
```
With Node.js 18 or later, install the CLI globally:
```bash theme={null}
npm install -g @straddlecom/cli
```
To try it without a global installation, run `npx @straddlecom/cli --help`. Keep npm's optional dependencies enabled; they provide the binary for your platform.
On macOS or Linux, use the shell installer:
```bash theme={null}
curl -fsSL https://raw.githubusercontent.com/straddle-build/straddle-cli/main/install.sh | sh
```
The installer downloads a release, verifies its SHA-256 checksum, and installs to `~/.local/bin`. Set `STRADDLE_INSTALL_DIR` for the installer process to choose another directory.
Download the archive for your operating system and architecture from [Straddle CLI releases](https://github.com/straddle-build/straddle-cli/releases). Compare its SHA-256 checksum with the release's `checksums.txt`, then extract the binary into a directory on `PATH`.
macOS release binaries are signed and notarized. Gatekeeper needs a network connection to check notarization on the first launch of a quarantined download.
Check the version and available commands:
```bash theme={null}
straddle version
straddle --help
```
A version number and command list confirm that your shell can run the CLI. If the command isn't found, add the installation directory to `PATH` and open a new terminal.
[Configure credentials and context](/developer-tools/cli/auth-context), then make a read request to confirm the API key works in the selected environment.
With a Go toolchain that meets the release's [module requirements](https://github.com/straddle-build/straddle-cli/blob/v1.0.4/go.mod), install from source:
```bash theme={null}
go install github.com/straddle-build/straddle-cli/cmd/straddle@latest
```
Add your Go binary installation directory to `PATH`, then run `straddle version`.
# Synchronize and query local data
Source: https://docs.straddle.com/developer-tools/cli/local-data
Prepare a scoped SQLite store for search, SQL, reconciliation, and payment analysis.
Synchronize Straddle resources to answer questions across payments, customers, paykeys, and funding events. The CLI stores the data in SQLite at `~/.local/share/straddle/data.db` by default.
## Prepare the data for analysis
With [credentials and account context configured](/developer-tools/cli/auth-context), inspect the context and fetch the resources needed for payment analysis:
```bash theme={null}
straddle agent-context --pretty
straddle sync --resources payments,funding-events --full --max-pages 0 --strict --json
```
`--full` restarts from the beginning instead of a saved checkpoint. `--max-pages 0` removes the default cap of 100 pages per resource. Sync bypasses the HTTP response cache and adds or updates returned records. It retains previously synchronized records that are absent from later API lists, including during a full sync.
For an interrupted sync, rerun with the same context and resources without `--full` to use its saved progress. Before an investigation that needs refreshed historical records, run the full command again.
## Check sync completeness
Read the JSON event stream and the `sync_summary` fields `success`, `warned`, and `errored`. Check each resource you need, including dependent resources added by sync. Naming a parent resource also synchronizes its parent-keyed dependents.
The following results need attention before you treat the data as complete:
| Result | Action |
| - | - |
| `sync_warning` for denied access | Confirm the key and account can read that resource. |
| `sync_warning` with `max_pages_cap_hit` | Repeat with `--max-pages 0` or a deliberate narrower scope. |
| `sync_anomaly` | Inspect malformed or dropped records, resolve the reported cause, and synchronize again. |
| A resource error | Resolve the error and rerun that resource. |
| A required resource missing from the run | Add it to `--resources` and synchronize again. |
`--strict` makes per-resource errors fail the command. Access warnings remain warnings, so a zero exit code alone doesn't prove complete coverage.
Query filters still apply during a full sync. `--param`, `--resource-param`, and `--global-param` can narrow the fetched data. `--latest-only` limits a resource to its first page when `--since` is absent, even with `--full --max-pages 0`.
In CLI v1.0.4, `--since` produces a `resource_not_incremental` warning for every supported sync resource and sends the request without a date filter. For a date-limited sync, use a query parameter supported by that resource's API operation.
The command shown here uses no saved profile. If you add `--profile`, inspect it first with `straddle profile show PROFILE_NAME`. Saved filters and `latest-only` still apply. A saved `path-context` can change the environment used by sync without changing the context of later queries.
## Query the local store
Search the synchronized data or run a read-only query:
```bash theme={null}
straddle search "failed" --type payments --data-source local --json
straddle sql "SELECT id FROM payments LIMIT 20" --json
```
`search` uses SQLite full-text search. For live filtered searches, use the resource command, such as `straddle payments --help`. SQL accepts one `SELECT` or `WITH` statement and runs against a read-only snapshot of the current context. Resource JSON is available in each table's `data` column.
If you sync to a custom `--db` path, pass that path to `search`, `sql`, and analytics commands that read it. Generated API read commands use the default store for local fallback.
## Keep the same environment and account
Local rows are separated by the resolved API origin and acting account. A context without an acting account has its own rows; it isn't an all-account view. Direct business integrations use no acting account.
Keep the environment and account selection the same for sync and analysis. Different profiles can share rows when they resolve to the same environment and account. Integration type controls request headers and account selection, rather than adding a separate database partition.
For a marketplace, customers and paykeys remain platform-owned. Sync fetches them without an account header, then stores them under the selected acting account's local context. That local grouping doesn't make those customers or paykeys account-owned.
Records written by versions before scoped storage remain hidden from scoped reads. A nonzero `hidden_legacy_records` count in diagnostics or read metadata means you need to resync the intended context.
## Choose between API, local data, and the response cache
Read commands that support both sources accept the following options:
| Option | Read behavior |
| - | - |
| `--data-source auto` | Try the API, update the local store after a successful supported read, and fall back locally for network failures. |
| `--data-source live` | Use the API path, with no local fallback. |
| `--data-source local` | Read synchronized data in the current context. |
The HTTP response cache is separate from SQLite and can reuse GET responses for five minutes. `--data-source live --no-cache` requests a fresh API result. `--no-cache` leaves your SQLite data intact. Commands such as `reconcile` and `sql` always read local data.
Use the synchronized store for reconciliation, payment progress, returns, and charge and payout volume.
# Work with Straddle from your terminal
Source: https://docs.straddle.com/developer-tools/cli/overview
Read API resources, automate tasks, and investigate synchronized payment data with the Straddle CLI.
Use the Straddle CLI to inspect payments, call the Pay by Bank and Embed APIs, and answer questions from a local copy of your data.
Install the CLI, configure your API key and account context, and verify an API read.
## Find the command for your task
Discover payment workflows and inspect their options:
```bash theme={null}
straddle which "reconcile funding" --json
straddle reconcile --help
```
For API operations, inspect the resource's commands with `straddle customers --help`. Coding agents can read the full command description from `straddle agent-context`.
## Choose how to work
Select sandbox or production, your integration type, and an acting account.
Discover commands, preview requests, and consume JSON output.
Prepare a local SQLite store for search, SQL, and payment analysis.
Follow a playbook for payment progress, reconciliation, returns, or charge and payout volume.
In a terminal, resource commands show readable output. Add `--agent` for compact JSON and automation defaults, or `--json` for JSON without changing confirmation behavior. See [output modes](/developer-tools/cli/agent-use#choose-an-output-mode).
# Troubleshoot the Straddle CLI
Source: https://docs.straddle.com/developer-tools/cli/troubleshooting
Resolve installation, credentials, account context, incomplete data, and automation errors.
Start with the version, credential source, and effective context:
```bash theme={null}
straddle version
straddle auth status --json
straddle agent-context --pretty
```
For connectivity and local-store diagnostics, run `straddle doctor --json`. Doctor makes a reachability request to the configured API host. Its credential-presence result needs a successful resource read to confirm authorization.
## The shell can't find the command
Add the installation directory to `PATH` and open a new terminal. The shell installer uses `~/.local/bin` by default. For npm, confirm the global binary directory is on `PATH` and optional dependencies were installed. See [installation methods](/developer-tools/cli/install).
## The API key is rejected
Check `auth status` for the credential source. An exported `STRADDLE_API_KEY` overrides a token saved with `auth set-token`. Pair a sandbox key with sandbox and a production key with production.
Inspect `runtime_context.environment` in `agent-context`. If it differs from `STRADDLE_ENVIRONMENT`, check `STRADDLE_BASE_URL` and the configuration file's `base_url`. After correcting the configuration, verify a fresh read:
```bash theme={null}
straddle customers list --page-size 1 --data-source live --no-cache --json
```
## An account-scoped command is rejected
Inspect the saved integration type and account:
```bash theme={null}
straddle setup
straddle use-account
```
For a platform's account-level work, select the intended account with `straddle use-account ACCOUNT_ID`. Direct business integrations use `setup --type account` and omit `--account`.
An explicit `--account` is rejected on operations that don't accept the account header. A profile can supply that flag too. Inspect the profile without applying it: `straddle profile show PROFILE_NAME`. See [account context](/developer-tools/cli/auth-context) for the setup path.
## Local results are missing or older than expected
Confirm that sync and the query use the same API environment, acting account, and database path. An empty acting account selects its own data, rather than every account.
Inspect the last sync's resource events and `sync_summary`. Access warnings, filters, or a page cap can leave the data incomplete even when sync exits successfully. Follow [sync completeness checks](/developer-tools/cli/local-data#check-sync-completeness), then rerun the resources needed for your task.
If diagnostics report `hidden_legacy_records`, resync in the intended context. For a fresh API read instead of local analysis, use `--data-source live --no-cache`.
## An agent receives unexpected output
Use `--agent` for compact JSON or `--json` for full JSON output. Add `--compact=false` to agent mode when you need fields omitted by compact output. Resource output remains JSON when piped, including with `--human-friendly`.
Parse `sync` as newline-delimited JSON events, not a single object. Keep stderr separate from stdout; errors and request previews can appear there as text. See [agent output modes](/developer-tools/cli/agent-use#choose-an-output-mode).
## Respond to an error
Use the exit code and diagnostics to choose the next action:
| Exit code | Meaning | Next action |
| - | - | - |
| `1` | General command failure | Read stderr and any resource-level events. |
| `2` | Invalid command or arguments | Check the command's `--help` and correct inputs. |
| `3` | Resource not found | Check its ID, environment, and account. |
| `4` | Authentication or permission error | Check the key's source, environment, and permitted resources. |
| `5` | API error | Read the status and response details; resolve the reported condition. |
| `6` | Partial failure detected in a response | Inspect the reported successful and failed operations before retrying. |
| `7` | Rate limited | Wait before retrying and reduce request frequency. |
| `10` | Configuration error | Correct the reported configuration file or environment variable. |
A timeout during a write can leave the result uncertain. Check the resource's current state before retrying. For a request that supports an idempotency key, retain the same key when retrying the same operation.
# Set account scope
Source: https://docs.straddle.com/developer-tools/mcp/account-scoping
Choose when to send Straddle-Account-Id for direct, SaaS, and marketplace requests.
Set account scope for each API MCP request. The `Straddle-Account-Id` header names the embedded account a platform acts for; whether to send it depends on your integration model and the operation.
Set the account in your MCP request separately from the account selected in the Straddle CLI.
## Choose the account
For a platform request, use the Straddle account ID from your application's tenant mapping or an exact account lookup. Resolve an ambiguous match before continuing. For the account model itself, see [Manage embedded accounts](/guides/embed/accounts).
Keep the following facts together when reviewing a request:
| Fact | Example |
| - | - |
| Environment | Sandbox, `https://sandbox.straddle.com` |
| Integration model | SaaS |
| Selected account | The sandbox account ID you supplied |
| Operation | `GET /v1/charges/{id}` |
| Header | `Straddle-Account-Id` set to that account ID |
Confirm the integration model in your platform configuration and integration plan.
## Apply the header rule
Use the following rules for the request you discovered:
| Operation | Direct account | SaaS | Marketplace |
| - | - | - | - |
| Create customer, create paykey through Bridge, initialize Bridge | Omit | Required | Omit |
| Other customer and paykey reads and updates | Omit | Send when an account is selected | Omit |
| Create charge or payout, refund, resubmit, upload charge authorization | Omit | Required | Required |
| Other charge, payout, funding-event, and payment reads and updates | Omit | Send when an account is selected | Send when an account is selected |
| Organizations, accounts, account settings, representatives, linked bank accounts, onboarding | Omit | Omit | Omit |
When a SaaS or marketplace row says “send when an account is selected,” omit the header if no account is selected. Select the account explicitly for a task about one tenant.
Marketplace customers and paykeys belong to the platform, so their requests omit the header. Charges and payouts identify the seller's account when the operation requires it.
## Pass scope to API MCP
For an account-scoped request, include the selected ID in `execute-request`'s `headers`. Replace the placeholder with the account you confirmed:
```json theme={null}
{
"Straddle-Account-Id": ""
}
```
For account-management operations such as `GET /v1/accounts/{account_id}`, the path identifies the account and the header stays omitted.
## Switch to another account
Confirm the new account ID, review the operation's header rule, and rebuild the request before sending it. Any write preview must show the new target before you approve it.
For a first authenticated read, follow [Read an account through API MCP](/developer-tools/mcp/api-requests).
# Read an account through API MCP
Source: https://docs.straddle.com/developer-tools/mcp/api-requests
Discover a current operation and inspect one sandbox account with your coding agent.
Use API MCP to read an existing sandbox account and verify that your configured key can reach it. The workflow discovers the operation, reviews the request, and inspects the result.
## Before you start
Prepare the following:
* [Connect API MCP](/developer-tools/mcp/install) with a sandbox API key.
* Choose an existing sandbox account ID that your key can read.
* Confirm the request host is `https://sandbox.straddle.com`.
The account ID goes in the request path. Account-management requests omit `Straddle-Account-Id` for every integration model.
## Discover and run the read
Ask the agent to discover the account read and show you its inputs:
Use straddle-api's search-openapi-operations to find the operation that gets one account by ID. Read its current schema and capture the Scalar document-version and operation IDs from this result. Ask me for the sandbox account ID, then show the proposed GET request to [https://sandbox.straddle.com](https://sandbox.straddle.com) with Straddle-Account-Id omitted. Wait for me to confirm the read.
Discovery returns the operation's schema for your review before execution.
Check the proposed values:
| Input | Expected value |
| - | - |
| `method` | `GET` |
| `serverBaseUrl` | `https://sandbox.straddle.com` |
| `path` | `/v1/accounts/` followed by your chosen account ID |
| `xScalarDocumentId` | The discovered `x-scalar-document-version-id`. |
| `xScalarOperationId` | The discovered operation's `x-scalar-operation-id`. |
| Account header | Omitted. |
Your client supplies the bearer token. Keep the key out of the prompt and tool arguments.
Confirm the proposed request and let the agent call `execute-request` once. Review the client's tool approval prompt if it appears.
Ask the agent to report the HTTP status, returned account ID, account status, and request ID when available. Keep personal and business details out of the summary unless your task needs them.
A successful response verifies access to that sandbox account with the configured key. Confirm the returned account ID matches the one you selected.
For a failed response, keep the status and request ID and follow [MCP troubleshooting](/developer-tools/mcp/troubleshooting).
## Use current Scalar IDs
Take both IDs from `search-openapi-operations` in the same session. Contract publication can change them.
The OpenAPI `operationId`, such as `getAccount`, is a human-readable name. `execute-request` needs the Scalar UUID from `x-scalar-operation-id`.
## Adapt the workflow
For another read, discover that operation's schema and review its parameters first. Put query parameters in `path`, for example `/v1/accounts?page_size=1`. Apply the [account-scope rules](/developer-tools/mcp/account-scoping) for the resource and integration model.
For implementation and sandbox writes, use the [Straddle skills](/developer-tools/skills/use-kit). They prepare request previews and choose the SDK, CLI, or API MCP route for each operation. [Authentication and permissions](/developer-tools/mcp/safety) explains those choices.
# Search Straddle documentation
Source: https://docs.straddle.com/developer-tools/mcp/docs-search
Get source-backed integration guidance from your coding agent with Docs MCP.
Use Docs MCP to find Straddle guides and API reference material while you work in your coding agent. Documentation search needs no API key.
## Connect Docs MCP
[Install the Straddle plugin](/developer-tools/agent-plugin/install), or add only `straddle-docs` with the [direct connection instructions](/developer-tools/mcp/install).
The server address is:
```text theme={null}
https://straddle-build-straddle-openapi.apidocumentation.com/mcp
```
## Ask a focused question
Include the resource, integration model, and behavior you need to understand. Ask the agent to cite the documentation it used.
Use straddle-docs to find the account-scope rules for a SaaS integration. Explain when customer, paykey, and charge requests use Straddle-Account-Id. Link to the source pages.
The agent uses `search-documentation` with your question. A useful answer names the applicable rule and provides a source you can open.
## Apply the result
Open the linked guide or API reference. Confirm that it covers your integration model and the operation you plan to use.
For a code change, have the agent read your installed SDK's methods and models before writing the implementation. Documentation explains the flow; the installed package determines the code available in your project.
Run your application tests and the sandbox scenarios in your integration plan. Use [Straddle Test](/developer-tools/skills/catalog) to record the results.
## Ask about an error
Give the agent the error code and relevant operation, with secrets and personal data removed:
Use straddle-docs to find guidance for a 401 response from GET /v1/accounts in sandbox. Explain which client and environment settings to check, and cite the documentation.
To inspect a resource in your Straddle account, use [API MCP](/developer-tools/mcp/api-requests).
## Read documentation without MCP
Give your agent the [documentation index](https://straddle-build-straddle-openapi.apidocumentation.com/llms.txt) to find pages directly. This is also useful when your client has no MCP support.
# Connect MCP
Source: https://docs.straddle.com/developer-tools/mcp/install
Add the hosted Straddle Docs MCP and API MCP servers to your coding agent.
Connect Docs MCP for documentation search and API MCP for Straddle requests. If you want integration skills too, [install the Straddle plugin](/developer-tools/agent-plugin/install), which includes both connections.
## Before you start
Use a client that supports remote HTTP MCP servers. For API requests, get a sandbox API key from the [Straddle dashboard](https://dashboard.straddle.com) and supply it as `STRADDLE_API_KEY` in the environment that starts your client.
Restart the client after setting the variable. A desktop app must inherit the variable in its own process, including when you open it outside a terminal. Docs MCP needs no credential, so you can connect it independently.
## Add the servers
Choose your client. For documentation search alone, add only the `straddle-docs` entry or command.
From your project directory, register both servers in local scope:
```bash theme={null}
claude mcp add --transport http --scope local \
straddle-docs \
https://straddle-build-straddle-openapi.apidocumentation.com/mcp
claude mcp add --transport http --scope local \
straddle-api \
https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd \
--header 'Authorization: Bearer ${STRADDLE_API_KEY}'
```
Keep the single quotes around the header so Claude Code receives the variable reference. Start Claude Code from that environment, enter `/mcp`, and confirm both connections.
Register the hosted servers:
```bash theme={null}
codex mcp add straddle-docs \
--url https://straddle-build-straddle-openapi.apidocumentation.com/mcp
codex mcp add straddle-api \
--url https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd \
--bearer-token-env-var STRADDLE_API_KEY
```
Check the configuration before starting a new session:
```bash theme={null}
codex mcp list --json
```
Confirm both server URLs and `bearer_token_env_var: "STRADDLE_API_KEY"` for `straddle-api`.
Open `~/.cursor/mcp.json` for a personal connection, or `.cursor/mcp.json` for a project connection. Merge these entries into the existing `mcpServers` object:
```json theme={null}
{
"mcpServers": {
"straddle-docs": {
"url": "https://straddle-build-straddle-openapi.apidocumentation.com/mcp"
},
"straddle-api": {
"url": "https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd",
"headers": {
"Authorization": "Bearer ${env:STRADDLE_API_KEY}"
}
}
}
}
```
In **Customize**, confirm both servers are enabled and their tools appear. For additional options, see [Cursor's MCP guide](https://cursor.com/docs/mcp).
In the Command Palette, select **MCP: Open User Configuration**. For a project connection, open `.vscode/mcp.json`. Merge these entries into the existing `servers` object:
```json theme={null}
{
"servers": {
"straddle-docs": {
"type": "http",
"url": "https://straddle-build-straddle-openapi.apidocumentation.com/mcp"
},
"straddle-api": {
"type": "http",
"url": "https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd",
"headers": {
"Authorization": "Bearer ${env:STRADDLE_API_KEY}"
}
}
}
}
```
Select **MCP: List Servers**, select each server, and then select **Start**. Review the server trust prompt. In chat, open **Configure Tools** and confirm the tools appear.
## Verify each connection
Ask your agent to query Docs MCP:
Use straddle-docs to search for webhook signature verification. Summarize the relevant instructions and link to the source.
Expect a relevant documentation result with a source link.
Ask for a specification summary:
Use straddle-api's summarize-openapi-specs tool to summarize the available Straddle API specification.
Expect a specification summary. This checks discovery; [read a sandbox account](/developer-tools/mcp/api-requests) to verify an authenticated request.
For connection or authentication errors, follow [MCP troubleshooting](/developer-tools/mcp/troubleshooting).
# Connect your agent to Straddle
Source: https://docs.straddle.com/developer-tools/mcp/overview
Search Straddle documentation and work with the API through hosted MCP servers.
Connect your coding agent to Straddle documentation and API tools with the Model Context Protocol (MCP). Straddle provides two hosted servers: Docs MCP for documentation search and API MCP for operation discovery and requests.
## Choose a connection
Use the server that matches your task:
| Server | Use it to | Authentication |
| - | - | - |
| Docs MCP, `straddle-docs` | Find guides, API reference material, and integration instructions. | No API key. |
| API MCP, `straddle-api` | Discover operations and send requests to Straddle. | Your Straddle API key for requests. |
The [Straddle plugin](/developer-tools/agent-plugin/install) connects both servers and adds integration skills. To configure MCP directly, follow [Connect MCP](/developer-tools/mcp/install).
## Work with the API
API MCP exposes the following tools:
| Tool | What it does |
| - | - |
| `summarize-openapi-specs` | Summarizes available specifications, servers, and paths. |
| `search-openapi-operations` | Finds operations and their request schemas. |
| `search-documentation` | Searches available documentation. |
| `execute-request` | Sends an HTTP request for a discovered operation. |
Specification discovery works separately from authenticated API execution. A successful summary proves the connection can read the contract. A successful API request proves access to that operation with the configured key.
API MCP can run reads and writes permitted by your key. Choose the environment and account for each task, and review requests through your client's approval controls. See [Authentication and permissions](/developer-tools/mcp/safety).
## Start a task
Add hosted servers to Claude Code, Codex, Cursor, or VS Code.
Ask a focused question and get source-backed guidance.
Discover the operation and inspect one sandbox account.
Apply the right header for a direct, SaaS, or marketplace integration.
# Authentication and permissions
Source: https://docs.straddle.com/developer-tools/mcp/safety
Understand API key access, client approvals, and the Straddle skills request rules.
API MCP sends requests with your Straddle API key. The key's permissions determine which Straddle operations the server can execute; your client controls when it asks you to approve a tool request.
## Supply the API key
Set `STRADDLE_API_KEY` in the environment that starts your client, or use the Straddle plugin's credential field in Cursor. Direct client configuration stores a reference to the variable. See [Connect MCP](/developer-tools/mcp/install) for the exact syntax.
Use a key from the [Straddle dashboard](https://dashboard.straddle.com). API MCP uses that key as a bearer token and needs no Scalar login. Keep the key in the client environment or credential field, outside prompts, source files, and reports.
A key saved in the Straddle CLI configures the CLI. Configure the MCP client's credential separately.
## Match the environment
Choose the host explicitly in each API request:
| Environment | `serverBaseUrl` |
| - | - |
| Sandbox | `https://sandbox.straddle.com` |
| Production | `https://production.straddle.com` |
Use a key for the same environment. Confirm the key's environment in the dashboard and the host in the request.
## Review API execution
The API MCP's `execute-request` can perform reads, creates, updates, deletes, and sensitive-data operations permitted by the key. A production key can authorize production writes.
Keep tool approval prompts enabled. Before approving execution, inspect the method, host, path, account header, and request body. For a write, check the intended effect and the idempotency key as well.
## Understand the skill rules
The Straddle skills add instructions for integration work. These are workflow rules followed by the agent, separate from the server's API permissions:
| Skill rule | What you review |
| - | - |
| Use sandbox for integration writes. | The explicit sandbox host and matching key. |
| Preview a write before asking for approval. | Account, operation, payload summary, external ID, and idempotency key. |
| Ask again when the target or payload changes. | The revised request. |
| Route customer, paykey, charge, and payout creation through the SDK or CLI. | The generated code or CLI preview. |
| Route deletes, unmasking, and paykey reveal through the SDK or CLI. | The specific approved action and handling of sensitive output. |
The agent follows these routing instructions. The server still accepts any operation permitted by the supplied key.
## Interpret verification
Documentation search and specification discovery can succeed without an authenticated Straddle request. Verify API access with a permitted read against the environment and account you intended.
A successful read proves access to that operation and account. Follow [Read an account through API MCP](/developer-tools/mcp/api-requests) for a focused check.
# Troubleshoot MCP
Source: https://docs.straddle.com/developer-tools/mcp/troubleshooting
Resolve connection, authentication, operation-discovery, and account-scope errors.
Start with the failing step: connection, specification discovery, or the Straddle request. Each checks a different part of the setup.
## The server is missing or disconnected
Check the server address in your client's MCP settings:
| Server | Address |
| - | - |
| `straddle-docs` | `https://straddle-build-straddle-openapi.apidocumentation.com/mcp` |
| `straddle-api` | `https://mcp.scalar.com/mcp/d5d1b1c2-ae5b-432d-b795-4fcb31cfdedd` |
Use the [connection instructions](/developer-tools/mcp/install) for your client, then restart the connection. In Claude Code, inspect `/mcp`. In Codex, run `codex mcp list --json`. In Cursor, check **Customize**; in VS Code, use **MCP: List Servers**.
If the URL is correct, inspect the client's MCP output for connection errors and confirm your network can reach that hosted address.
## Discovery succeeds but the request returns 401
Specification discovery checks the contract, so it can succeed without a valid API key. For a `401`, check the following:
1. Supply `STRADDLE_API_KEY` to the process that starts your client.
2. Confirm the key belongs to the same environment as `serverBaseUrl`.
3. Restart the client or MCP connection after changing the credential.
For Codex, confirm `bearer_token_env_var` is `STRADDLE_API_KEY`. For Claude Code, the header must keep the literal variable reference shown in [Connect MCP](/developer-tools/mcp/install). For the Cursor plugin, check its **Configure** credential field.
## The request returns 403 or 404
For `403`, check whether the key can use the operation and selected account. For `404`, confirm the resource ID and environment, then review the [account header rule](/developer-tools/mcp/account-scoping).
Use the resource's exact ID from the same environment. Keep the method, path, HTTP status, and request ID from the failure so the next investigation has concrete evidence.
## Scalar cannot find the operation
“Failed to get operation” points to the operation ID. “Does not belong to the given document version” points to the document and operation pair.
Repeat `search-openapi-operations` in the current session. Use `x-scalar-document-version-id` and the matching operation's `x-scalar-operation-id` from that result. The OpenAPI name, such as `getAccount`, is not the Scalar operation ID.
Then rebuild the request with those IDs. See [API requests](/developer-tools/mcp/api-requests).
## The request targets the wrong environment
Inspect `serverBaseUrl` in the tool request. Set it to the resolved host, such as `https://sandbox.straddle.com`.
Set the account in the MCP request separately from the CLI's selected account. Include the header when the [operation requires it](/developer-tools/mcp/account-scoping).
## Docs MCP lists API execution tools
Use Docs MCP's `search-documentation` tool for documentation. Send API tasks through `straddle-api`, where the client is configured with your Straddle key.
The hosted server controls its tool list. Check the server URL to confirm which connection supplied the tools.
## Prepare an error report
Include the client version, server name, tool name, method and path, environment, HTTP status, and request ID when available. Describe what you expected and what happened. Remove API keys, paykey tokens, and personal data before sharing the report.
# Build your Straddle integration with AI
Source: https://docs.straddle.com/developer-tools/overview
Plan, build, and test with Claude Code, Codex, or Cursor.
Straddle skills guide your coding agent from project setup through sandbox testing and production readiness. Start a guided integration with the Wizard, or choose a skill for the task you're working on.
## Start an integration
Run the Straddle Wizard from your application directory to start the integration workflow:
```bash theme={null}
npx @straddlecom/wizard@latest
```
Choose your coding agent and follow the workflow through setup, planning, implementation, sandbox testing, and a production readiness review.
Set up your coding agent, approve an integration plan, and review the sandbox test results.
## Work in your coding agent
The Straddle plugin adds skills and connections to Straddle's Model Context Protocol (MCP) servers. Use skills to guide a development task and MCP to search documentation or send API requests.
Plan an integration, build a payment flow, test in sandbox, or audit existing code in your agent session.
Search guides and API reference pages with Docs MCP. Use API MCP to discover operations and send requests with your Straddle API key.
API MCP supports the operations your API key permits, including writes. Review each request in your agent's tool approval prompt before it runs.
## Investigate payments
Playbooks walk you through an operational task and explain the results. Choose a workflow to inspect payment progress, investigate returns, or compare payment records with funding events.
Find the workflow for your question, run it with the CLI, and interpret the results.
## Use the CLI and SDKs
Use the [Straddle CLI](/developer-tools/cli/overview) to call the API from your terminal and return JSON for scripts and agents. [Choose an SDK](/developer-tools/sdks) to call the API from your application.
# Build your first integration
Source: https://docs.straddle.com/developer-tools/quickstart
Use the Straddle Wizard to plan, build, and test Pay by Bank in your application.
Add Straddle to your application with your coding agent. The Wizard guides the work from a plan you review to code changes and recorded sandbox test results.
## Before you begin
Prepare the following:
* An application repository and Node.js 22.18 or later.
* Claude Code, Codex, or Cursor. For Auto mode, install and sign in to the client's command-line tool: `claude`, `codex`, or `cursor-agent`.
* A sandbox API key from the [Straddle Dashboard](https://dashboard.straddle.com), available as `STRADDLE_API_KEY` in the environment that starts your agent.
Use your secret manager or shell configuration to supply the API key. The [plugin installation guide](/developer-tools/agent-plugin/install) covers client setup and connection checks.
## Build and verify
In a terminal at the repository root, select sandbox:
```bash theme={null}
export STRADDLE_ENVIRONMENT=sandbox
```
If you set `STRADDLE_BASE_URL`, use `https://sandbox.straddle.com`. The Wizard reports conflicting environment settings before the request steps start.
Launch the guided integration:
```bash theme={null}
npx @straddlecom/wizard@latest
```
Confirm the detected language and framework. Choose charges, payouts, or both; your integration type; an SDK; and a notification path. Select **Not decided yet** for a choice you want to work through with the agent.
Select your client and **Auto** to let the Wizard start it. In **Manual**, follow the displayed setup steps and paste the Wizard's generated message into your agent. Review and accept any plugin download or installation needed for the run.
The agent checks the project and writes `straddle-integration-plan.md`. Give it the application context it asks for. For a charge integration, adapt this request in the agent session:
Add Pay by Bank to this application's checkout. Follow the Straddle Wizard program for this repository. Identify how the app stores customers, collects payments, and receives payment updates. Ask me to resolve the integration type and bank connection method before writing the plan. Show the files you propose to change and the sandbox scenarios you will test.
Read the plan's application changes, account rules, and test scenarios. Approve the plan when it matches the integration you want. If the repository already uses another payment provider, the Wizard also includes a migration step.
The agent implements the approved plan, then runs its test workflow. Review each sandbox write preview, including the environment, acting account, operation, and payload, before approving it.
Complete any application interaction the agent needs, such as connecting a bank through the Bridge widget. The agent records the checks it ran and any scenario that still needs attention in `straddle-test-evidence.md`.
Inspect the saved run:
```bash theme={null}
npx @straddlecom/wizard@latest status
```
Open `straddle-integration-report.md` for the code changes and `straddle-test-evidence.md` for the results. A finished Test step has `Status: complete` for the current approved plan. Review the latest run's scenario table and its `live-observed` evidence for sandbox behavior.
Read `straddle-go-live-report.md` for the production readiness review and any remaining gaps. Review the changed files and the agent's **Verify before merging** checklist before merging your integration.
## Continue an unfinished run
After resolving a missing setting, unanswered question, or failed check, continue from the same repository:
```bash theme={null}
npx @straddlecom/wizard@latest resume
```
The Wizard reads the plan and reports to find the first unfinished step. See [Run and resume an integration](/developer-tools/wizard/integrate) for completion states, Manual mode, and finishing after sandbox testing.
# Choose your tools
Source: https://docs.straddle.com/developer-tools/routing
Choose a guided integration, an agent skill, API tools, or a payment playbook.
Start with the [Straddle Wizard](/developer-tools/quickstart) to build and test an integration with your coding agent. For a specific job, choose the tool that fits the result you need.
## Choose by task
The following tools support integration work and payment operations.
| You want to | Use | What you get |
| - | - | - |
| Build your first Straddle integration | [Wizard](/developer-tools/quickstart) | A guided plan, implementation, sandbox tests, and readiness review. |
| Add Straddle skills to your coding agent | [Straddle plugin](/developer-tools/agent-plugin/install) | Integration instructions and connections to Docs MCP and API MCP. |
| Plan, migrate, test, or review an integration | [Skills](/developer-tools/skills/catalog) | A focused workflow with a plan or report in your repository. |
| Find a guide or API explanation from your agent | [Docs MCP](/developer-tools/mcp/docs-search) | Documentation search. |
| Discover an API operation and send a request | [API MCP](/developer-tools/mcp/api-requests) | Operation details and requests authenticated with your API key. |
| Call the API or automate terminal work | [Straddle CLI](/developer-tools/cli/overview) | Commands, JSON output, and local payment data. |
| Call Straddle from application code | [SDKs](/developer-tools/sdks) | A client library for your application language. |
| Investigate payments, returns, or funding | [Playbooks](/playbooks/overview) | A task walkthrough with commands and guidance for interpreting results. |
API MCP supports requests allowed by your API key, including writes. Review the [authentication and permissions](/developer-tools/mcp/safety) before sending requests.
## Put the tools to work
The Wizard coordinates the integration steps in your coding agent. The plugin supplies skills, and the skills use documentation, API tools, and your application code to carry out each step. Your application calls Straddle through an SDK or the HTTP API.
Once payments are running, use the CLI and playbooks to investigate individual records or analyze synchronized data.
Start in your application repository and review the resulting plan and test evidence.
Choose a playbook by the question you need to answer.
# Choose an SDK
Source: https://docs.straddle.com/developer-tools/sdks
Install a Straddle SDK and open the reference for your application language.
Use a Straddle SDK to call the API from your application. Choose your language, install the package, and follow its client setup example.
## Install your SDK
Each language reference covers request methods, response types, authentication, and error handling.
Install the package for a TypeScript or JavaScript application:
```bash theme={null}
npm install @straddlecom/straddle
```
Open the [TypeScript setup guide](https://github.com/straddle-build/straddle-typescript#usage) or [API reference](https://github.com/straddle-build/straddle-typescript/blob/main/api.md).
Install the package in your Python environment:
```bash theme={null}
pip install straddle
```
Open the [Python setup guide](https://github.com/straddle-build/straddle-python#usage) or [API reference](https://github.com/straddle-build/straddle-python/blob/main/api.md).
Add the module to your Go project:
```bash theme={null}
go get github.com/straddle-build/straddle-go
```
Open the [Go setup guide](https://github.com/straddle-build/straddle-go#usage) or [API reference](https://github.com/straddle-build/straddle-go/blob/main/api.md).
Install the gem:
```bash theme={null}
gem install straddle
```
Open the [Ruby setup guide](https://github.com/straddle-build/straddle-ruby#usage) or [API reference](https://github.com/straddle-build/straddle-ruby/blob/main/api.md).
Add the package to your .NET project:
```bash theme={null}
dotnet add package Straddle
```
Open the [.NET setup guide](https://github.com/straddle-build/straddle-dotnet#usage) or [API reference](https://github.com/straddle-build/straddle-dotnet/blob/main/api.md).
## Configure your application
Load your sandbox API key in your backend process and pass it to the SDK client. Set the API base URL to `https://sandbox.straddle.com`. The setup guide for each language shows the client options and supported environment variables.
For SaaS and marketplace integrations, include the account context required by each operation. See the [account-scope table](/developer-tools/mcp/account-scoping) for the `Straddle-Account-Id` rules.
## Build with your coding agent
The [Straddle integration workflow](/developer-tools/quickstart) helps your coding agent choose an SDK, implement your payment flow, and test it in sandbox. For an existing integration, choose a task from the [skill catalog](/developer-tools/skills/catalog).
# Choose a Straddle skill
Source: https://docs.straddle.com/developer-tools/skills/catalog
Find the skill and output for your integration task.
Choose a skill by the result you need. The released Straddle plugin v0.1.2 includes eight task skills and one shared best-practices skill.
## Task skills
Use the following names when asking your agent to run a skill:
| Skill | Use it to | Result |
| - | - | - |
| `straddle-get-started` | Choose the product, integration model, SDK, and documentation for your repository. | Orientation and a recommended next skill. |
| `straddle-setup` | Check your repository, CLI, SDK, environment, and MCP connections. | `straddle-setup.md` with readiness findings. |
| `straddle-plan` | Define files, SDK methods, account rules, notifications, and tests before implementation. | `straddle-integration-plan.md` for your approval. |
| `straddle-integrate` | Implement the approved plan and run approved sandbox setup. | Code changes and `straddle-integration-report.md`. |
| `straddle-migrate` | Add Straddle code beside an existing provider integration. | `straddle-migration-plan.md`, approved code changes, and `straddle-migration-report.md`. |
| `straddle-test` | Verify the finished integration against its approved integration or migration plan. | `straddle-test-evidence.md`. |
| `straddle-go-live` | Review code, sandbox evidence, and operational setup for production readiness. | `straddle-go-live-report.md`. |
| `straddle-audit` | Investigate an integration failure or review existing Straddle code. | `straddle-audit-report.md` with findings, evidence, and recovery steps. |
Setup reports missing dependencies and configuration so you can resolve them. Integrate builds from an approved plan. Test records failures for follow-up through Integrate, and Audit changes code only after you approve a specific finding.
## Shared guidance
`straddle-best-practices` supplies the product, account-scope, credential, SDK, and request rules used by the task skills. It also answers Straddle behavior questions. For a workflow that runs API operations, choose Integrate or Test.
## Add Straddle beside another provider
Migrate includes guidance for Stripe, Plaid, Moov, Modern Treasury, Dwolla, Paya, Payliance, and other payment or bank-linking providers. It inspects the existing integration and asks which provider roles you want Straddle to handle.
Review its migration plan before approving code changes. The existing provider path stays in place behind the switch you choose. Customer-data transfer and traffic cutover need their own plan.
## Run your chosen skill
Follow [Use Straddle skills](/developer-tools/skills/use-kit) for client-specific invocation and the guided sequence. For payment investigations, use the separate [Playbooks catalog](/playbooks/overview).
# Build with Straddle skills
Source: https://docs.straddle.com/developer-tools/skills/overview
Guide your coding agent through planning, implementation, testing, and review.
Use Straddle skills to turn an integration task into a plan, code changes, and verification evidence. Each skill gives your coding agent a defined job and the Straddle references it needs to complete it.
[Install the Straddle plugin](/developer-tools/agent-plugin/install) to add the skills and hosted MCP connections to your client. For a guided sequence, start the [Straddle Wizard](/developer-tools/wizard/overview) in your application directory.
## Choose your starting point
Select the task that matches your project:
Run Setup, approve a plan, and build and test your Straddle flow.
Plan a change, add Straddle beside a provider, or audit existing code.
Install the plugin in Claude Code, Codex, or Cursor.
Check skill discovery, configuration, plans, and test results.
## Work from your application
The skills inspect your repository and installed SDK to ground their suggestions in the code you use. They ask you to choose the integration model and notification path, then record those decisions in the plan.
Application code uses the Straddle SDK. Docs MCP supplies documentation, API MCP discovers operations and performs permitted requests, and the CLI supplies diagnostics and sandbox helpers. [MCP permissions](/developer-tools/mcp/safety) explain how API access and skill instructions work together.
## Review the result
Each stage produces something you can inspect: a setup report, an integration plan, a code diff, test evidence, or a readiness report. Review those artifacts before moving to the next stage. A passing test report describes the scenarios that ran; the report also records gaps that need follow-up.
For questions about existing payments, choose a task from [Playbooks](/playbooks/overview).
# Troubleshoot Straddle skills
Source: https://docs.straddle.com/developer-tools/skills/troubleshooting
Resolve missing skills, configuration gaps, blocked plans, and incomplete evidence.
Use the skill's report and the Wizard's status to find the step that needs attention.
## Find a missing skill
For a Wizard-managed installation, inspect the cached bundle and client installation:
```bash theme={null}
npx @straddlecom/wizard@latest status --json
npx @straddlecom/wizard@latest skill list
```
`skill list` lists the skills in the Wizard's bundle and may prompt to download a release. In `status`, check the selected client's `plugin.state` and `plugin.verified` fields.
If the plugin is missing, follow [Install the Straddle plugin](/developer-tools/agent-plugin/install). For a mismatched Wizard-managed copy, update it and restart the client:
```bash theme={null}
npx @straddlecom/wizard@latest update --client claude
```
Use `--client codex` for Codex. In Cursor, refresh the team marketplace and check the installed skill names in the IDE. The Wizard's status cannot verify Cursor team-marketplace installations.
## Resolve a marketplace conflict
The Wizard stops if a marketplace named `straddle` points to a different directory from its verified plugin bundle. Choose whether to keep that installation or let the Wizard manage it.
To switch to the Wizard, remove the existing Straddle plugin and marketplace through your client, then run the [installation steps](/developer-tools/agent-plugin/install). Keep your other marketplaces in place.
## Resolve a configuration finding
Setup distinguishes missing configuration from checks that failed. Correct the named setting, then run Setup again:
```bash theme={null}
npx @straddlecom/wizard@latest setup
```
For API MCP, supply `STRADDLE_API_KEY` to the coding client's process separately from the Straddle CLI's saved credentials. Check [MCP authentication](/developer-tools/mcp/safety) and select the sandbox environment explicitly.
If discovery succeeds but an authenticated request fails, use [MCP troubleshooting](/developer-tools/mcp/troubleshooting).
## Unblock Integrate or Test
Integrate needs an approved `straddle-integration-plan.md`. Test accepts an approved integration or migration plan and needs the corresponding code.
Run Plan when the integration plan is missing. If the plan changed after approval, review the revised file and approve it again before continuing. Keep the approval attached to the current plan.
## Interpret incomplete test evidence
Read the individual rows in `straddle-test-evidence.md`. A scenario can be blocked by missing configuration, waiting for approval, or require a person to complete a browser flow. The report names what ran and what still needs evidence.
Correct the specific cause, then rerun Test. If a check found an implementation defect, return to Integrate before testing again.
## Audit an existing failure
Ask your agent to investigate with Audit:
Use the straddle-audit skill to investigate the Straddle failure in this repository. Ask me for the sanitized error and request ID if you need them. Write the findings and recovery steps to straddle-audit-report.md.
Audit checks each finding against the installed SDK and API contract. Review its proposed fix before authorizing code changes.
# Use Straddle skills
Source: https://docs.straddle.com/developer-tools/skills/use-kit
Run a guided integration or invoke a focused skill in your coding agent.
Run the Straddle Wizard for a complete integration, or name a skill directly when you need one stage.
## Before you start
[Install the Straddle plugin](/developer-tools/agent-plugin/install), open your application directory, and make your sandbox API key available to the coding client. Select the sandbox environment explicitly for integration work.
The skills use your repository, installed SDK, and choices to define the integration. Have your integration model and, for a platform, the account you want to act for ready.
## Run a guided integration
Start the Wizard from your application directory:
```bash theme={null}
export STRADDLE_ENVIRONMENT=sandbox
npx @straddlecom/wizard@latest
```
The Wizard runs Setup, Plan, Integrate, Test, and Go Live readiness. It adds Migrate after Plan when your application uses another payment provider. Select **Auto** to run the coding agent from your terminal, or **Manual** to receive a message for your own agent session.
Follow [Build your first integration](/developer-tools/quickstart) for the plan review, sandbox approvals, and test evidence at each stage.
To continue an interrupted program, run:
```bash theme={null}
npx @straddlecom/wizard@latest resume
```
The Wizard resumes from the files the skills wrote. See [Run and resume an integration](/developer-tools/wizard/integrate) for the complete workflow.
## Invoke one skill
Choose a name from the [skill catalog](/developer-tools/skills/catalog). For example, start a planning session:
Enter the plugin's skill command in your project session:
```text theme={null}
/straddle:straddle-plan
```
Ask Codex to use the installed skill:
Use the straddle-plan skill to plan a Straddle integration in this repository.
Ask Cursor to use the installed skill:
Use the straddle-plan skill to plan a Straddle integration in this repository.
Run the skill through the Wizard:
```bash theme={null}
npx @straddlecom/wizard@latest skill run straddle-plan
```
## Continue from the result
Keep the plan and reports in the application repository. They carry decisions and evidence between stages.
When Test reports a failure, ask Integrate to address it, then run Test again. When you need to diagnose code that already exists, run Audit and review its findings before approving fixes.
# Wizard commands
Source: https://docs.straddle.com/developer-tools/wizard/commands
Run an integration, continue saved work, or select a focused Straddle skill.
Run the Wizard from your application repository. Add a command after the package name to select a task:
```bash theme={null}
npx @straddlecom/wizard@latest plan
```
## Build and review
The following commands run the complete program or one skill.
| Command | Result |
| - | - |
| No command | Guided Setup, Plan, Integrate, Test, and Go Live readiness, with Migrate after Plan when another provider is detected. |
| `setup` | Project and tool readiness report in `straddle-setup.md`. |
| `get-started` | Guidance on the product, integration model, SDK, and documentation for your project. |
| `plan` | Integration plan in `straddle-integration-plan.md`. |
| `integrate` | Implementation of the approved plan and an integration report. |
| `test` | Verification of the integration and `straddle-test-evidence.md`. |
| `migrate` | A plan and implementation that add Straddle beside an existing payment provider. |
| `go-live` | Production readiness review in `straddle-go-live-report.md`. |
| `audit` | Review of an existing integration with findings in `straddle-audit-report.md`. |
See the [skill catalog](/developer-tools/skills/catalog) for each workflow's prerequisites and outputs. Sandbox requests in Integrate and Test use the configured sandbox key and the skill's request previews and approvals.
## Continue and inspect
Use the following commands for saved work.
| Command | Result |
| - | - |
| `resume` | Continue at the first unfinished step from the plan and reports. |
| `status` | Show the local bundle, client, plugin, MCP configuration, key presence, environment, and saved run. |
| `status --json` | Return the status report as JSON, including `run` and `configurationErrors`. |
| `log` | Write and open a local HTML view of recorded session events and available transcripts. |
| `skill list` | List the selected bundle's skills and versions. It can prompt to download a plugin release. |
| `skill run SKILL_NAME` | Run one named workflow skill. Use a name from `skill list`, such as `straddle-plan`. |
`status` reads local state. Check the setup or test report's authenticated-read result when you need evidence that your API key works.
## Manage the plugin and MCP connections
Select a client explicitly for configuration commands:
```bash theme={null}
npx @straddlecom/wizard@latest install --client codex
```
The following commands show the proposed client configuration changes before running them.
| Command | Result |
| - | - |
| `install` | Load the Straddle plugin through the client's installation path. |
| `update` | Update the plugin to the release selected by the Wizard. |
| `remove` | Remove the Straddle plugin and its marketplace entry. |
| `mcp add` | Configure `straddle-api` and `straddle-docs` as needed for the client. |
| `mcp remove` | Show or run the client's removal steps for the Straddle MCP connections. |
Cursor configuration commands print steps to complete in the client. Follow [plugin installation](/developer-tools/agent-plugin/install) for client-specific details.
## Options
Use the following options to select the project, client, or output.
| Option | Use |
| - | - |
| `--dir PATH` | Work in the selected repository. Defaults to the current directory. |
| `--client claude\|codex\|cursor` | Select the coding agent. |
| `--mode auto\|manual` | Start the agent from the Wizard or receive a message to paste into your own session. Also changes the mode on `resume`. |
| `--exclude GLOB` | Add a sensitive path to the Wizard's exclusions. Repeat for more paths. |
| `--json` | Return JSON from `status` or `skill list`. |
| `--yes` | Accept plugin downloads and installation, update, removal, or MCP configuration commands. Sandbox write approval remains part of the skill workflow. |
| `--help` | Print command help. |
| `--version` | Print the Wizard version. |
Pass `--bundle PATH` to use a local Straddle skills directory. The Wizard labels it as a local bundle and checks that it has a compatible plugin structure. Use this option when testing changes to skills.
# Run and resume an integration
Source: https://docs.straddle.com/developer-tools/wizard/integrate
Use Auto or Manual mode, review the results, and continue from the first unfinished step.
Run the Wizard in your application repository to carry a Straddle integration through planning, implementation, sandbox testing, and production readiness review. Complete the [quickstart prerequisites](/developer-tools/quickstart#before-you-begin) first.
## Start the program
Choose how the Wizard works with your coding agent.
Start the guided run and select your installed, signed-in command-line client:
```bash theme={null}
npx @straddlecom/wizard@latest --mode auto
```
The Wizard opens Claude Code, Codex, or `cursor-agent` in the terminal for the program. The agent continues through the listed steps and pauses when it needs your decision or approval.
Prepare a message for the agent session you manage:
```bash theme={null}
npx @straddlecom/wizard@latest --mode manual
```
Choose your client, follow the displayed setup steps, and paste the generated message into that agent. When the work stops, return to the Wizard and select **I'm back: read the files**, or run `resume` later.
Confirm the project context and integration choices. The program runs Setup, Plan, Integrate, Test, and Go Live readiness. When the repository uses another payment provider, Migrate runs after Plan and writes its own plan and report.
## Review decisions as the agent works
Read `straddle-integration-plan.md` before approving the proposed application changes and test scenarios. The agent records your approval against that version of the plan. An edit to the plan requires another review and approval.
Review sandbox request previews separately from code changes. A preview identifies the environment, acting account, operation, and payload. The skill asks for approval before it sends the write. On a resumed run, it presents sandbox writes for approval again.
Claude Code Auto runs show a checklist in the status line. Codex Auto runs show it on a local page whose address the Wizard prints. In Cursor and Manual runs, the Wizard reads the files after the session or when you return.
## Read the results
The following files record the work at the repository root.
| File | What to review |
| - | - |
| `straddle-setup.md` | Project readiness and unresolved configuration. |
| `straddle-integration-plan.md` | Integration decisions, proposed changes, scenarios, and recorded approval. |
| `straddle-migration-plan.md` and `straddle-migration-report.md` | The migration plan and implementation result, when Migrate runs. |
| `straddle-integration-report.md` | Implementation results and remaining work. |
| `straddle-test-evidence.md` | The latest test run, scenario results, authenticated reads, and observed sandbox resources. |
| `straddle-go-live-report.md` | Production readiness and remaining gaps. |
Reports after Plan identify the approved plan they used. The Wizard counts them as finished only when their completion status and plan hash match. Use the test evidence's `live-observed` rows to identify behavior verified against Straddle sandbox.
Inspect progress or open the recorded session log:
```bash theme={null}
npx @straddlecom/wizard@latest status
npx @straddlecom/wizard@latest log
```
`status` shows the saved run and local configuration. `log` creates a local HTML page from recorded session events and available transcripts. Review the report and **Verify before merging** checklist with the code changes.
## Resume from the first unfinished step
Continue from the same repository after resolving the finding or question that stopped the run:
```bash theme={null}
npx @straddlecom/wizard@latest resume
```
The Wizard reads the plan and reports to choose the next step. In Auto, it reopens the agent session when a saved session ID is available, or starts a session at that step. In Manual, it prints the next message to paste. Change the mode with `resume --mode auto` or `resume --mode manual`.
A partial or blocked report keeps its step unfinished. Changing an approved plan also makes reports for the earlier plan unfinished. Fix the reported issue and resume; the work already written stays in the repository.
## Finish after sandbox testing
The Wizard offers **Finish here (skip Go Live)** when Test is complete and Go Live is the only remaining step, unless a Go Live report already exists for that plan. This records the skipped review in the run.
When you're ready to assess production readiness, run:
```bash theme={null}
npx @straddlecom/wizard@latest go-live
```
Read the readiness report and resolve its gaps before moving the integration to production.
# Set up a project with the Wizard
Source: https://docs.straddle.com/developer-tools/wizard/overview
Check your repository, coding agent, and sandbox configuration before building an integration.
Use the Straddle Wizard to prepare an application for integration work and run the Straddle skills in your coding agent. It detects project context, helps load the plugin, and records where the work stands.
For the complete path from setup to sandbox results, follow [Build your first integration](/developer-tools/quickstart).
## Check project readiness
Use Node.js 22.18 or later. Open the repository that will call Straddle, then start the focused setup workflow:
```bash theme={null}
npx @straddlecom/wizard@latest setup
```
Check the detected language, framework, installed Straddle SDK, and existing payment provider. Correct the detected values when needed.
Choose the payment operations, integration type, SDK, and notification path. Unresolved choices stay visible for the agent to discuss with you.
Select Claude Code, Codex, or Cursor. In Auto mode, the Wizard starts the signed-in command-line client in your terminal. In Manual mode, it gives you the message and setup steps for your own agent session.
The Wizard offers the plugin installation or update needed by the selected client. Cursor installation uses the steps shown in the client. See [Install the Straddle plugin](/developer-tools/agent-plugin/install) for each client's setup.
The Setup skill writes `straddle-setup.md` at the repository root. Read its checks for the CLI, API key presence, environment, integration type, acting account, SDK, and MCP connections.
Resolve any blocking finding, then run the setup command again to check the result. Setup records what is ready and what needs work in that report.
## Check configuration before requests
Set `STRADDLE_API_KEY` in the environment that starts your agent and declare `STRADDLE_ENVIRONMENT=sandbox`. If you use `STRADDLE_BASE_URL`, set it to `https://sandbox.straddle.com`.
The Wizard reads key presence and declared environment from these shell variables. A key saved only in the Straddle CLI's credential configuration needs to be supplied to the agent's environment as well.
MCP discovery shows that your agent can find the server's tools. Use the setup report's authenticated-read result to check whether the key authorizes the requested API operation. These results appear separately in the report.
## Start the integration
Once the project is ready, run the full program:
```bash theme={null}
npx @straddlecom/wizard@latest
```
The program runs Setup, Plan, Integrate, Test, and Go Live readiness. It adds Migrate after Plan when it detects another payment provider.
Follow the plan, approvals, and reports through an integration.
Run planning, testing, migration, or review on its own.
# Create paykeys from raw bank account details
Source: https://docs.straddle.com/guides/bridge/bank-account
Use the Straddle Bridge API to create paykeys directly from raw routing and account numbers without an open banking provider, with built-in verification.
This guide provides a detailed walkthrough on using Straddle's Bridge API to create paykeys directly from bank account information.
## Implementation steps
Ensure that bank account details such as the account number, routing number, and account holder's name are collected securely through your frontend. Use encryption or tokenization to protect sensitive data.
Once the bank account details are collected, send the information to your backend server over a secure connection (e.g., HTTPS). Your server should handle the data safely and securely for further processing.
On your backend, send a request to the Straddle Bridge API with the bank account details to create a paykey. Straddle returns a paykey that can be used for future transactions without needing to store sensitive bank information.
Store the `paykey` securely in your system. You can use this `paykey` to create charges, initiate payments, or perform other transactions via Straddle's API in the future, without handling sensitive bank data again.
## Using Bridge with 'raw' bank account details
To create a paykey using bank account details, make a POST request to the Straddle Bridge API. Here's the HTTP request details:
```bash Bridge a Bank Account theme={null}
curl -X POST https://api.straddle.com/v1/bridge/bank_account \
-H "Authorization: Bearer YOUR_STRADDLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"routing_number": "011000138",
"account_number": "123456789",
"account_type": "checking",
"metadata": {
"user_reference": "user_12345"
}
}
```
Replace `YOUR_STRADDLE_API_KEY` with your actual Straddle API key, and fill in the appropriate values for `customer_id`, `routing_number`, `account_number`, and `account_type`.
## Handling the API response
Upon successful creation of a paykey, the Straddle API responds with a JSON object. Here's an example of what you might receive:
```json theme={null}
{
"data": {
"paykey": "05f5d55cb14f7e8a0ec2e5689376e3b4665efc34834d30995babbd5010b39913",
"bank_data": {
"routing_number": "011000138",
"account_number": "******6789",
"account_type": "checking"
},
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"label": "BANK OF AMERICA, N.A. - *6789",
"source": "bank_account",
"institution_name": "BANK OF AMERICA, N.A.",
"status": "active",
"created_at": "2024-09-14T06:47:39.5648743Z",
"updated_at": "2024-09-14T06:47:39.5648746Z"
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f"
},
"response_type": "object"
}
```
# Create a paykey from a Mastercard token
Source: https://docs.straddle.com/guides/bridge/mastercard-consent
Use a Mastercard Open Finance connection for charges and payouts through Straddle.
Use this guide after your customer connects a checking account through Mastercard Open Finance. Straddle uses that connection to retrieve account data, verify ownership, and return a [paykey](/guides/bridge/paykeys) for charges and payouts.
Straddle calls the following values from one Mastercard consent receipt a *Mastercard token*:
* Receipt ID.
* Mastercard customer ID.
* Mastercard account ID.
Need a Mastercard token? See [Create a Mastercard token for Straddle](/integrations/open-banking/mastercard).
## Before you begin
Complete the following:
* [Create a customer in Straddle](/api-reference/customers/create). The customer cannot be `inactive` or `rejected`.
* Use a Mastercard consent receipt that includes `moneyTransferDetails`, `accountOwner`, and `availableBalanceLive` for the same account.
Mastercard does not include the account type in the consent receipt. Straddle records a paykey created from a Mastercard token as a `checking` account.
## Create the paykey
Send the following IDs to `POST /v1/bridge/mastercard`.
| Request field | What to send |
| - | - |
| `customer_id` | The Straddle customer ID. |
| `mastercard.consent_receipt_id` | `data[].receipt.receiptId` from Mastercard. |
| `mastercard.customer_id` | `data[].receipt.customerId` from Mastercard. |
| `mastercard.account_id` | The `data[].receipt.products[].accountId` value for the selected account. |
The Mastercard values must come from the same consent receipt.
```bash Create a paykey from a Mastercard token theme={null}
curl --request POST https://sandbox.straddle.com/v1/bridge/mastercard \
--header "Authorization: Bearer YOUR_STRADDLE_API_KEY" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
--data '{
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"mastercard": {
"consent_receipt_id": "cr_4pfI2r1X8aOHrDDwrwC01NHTxOXlT1",
"customer_id": "3465230025077724000",
"account_id": "4633415743960374024"
},
"external_id": "bank-connection-4412",
"metadata": {
"nickname": "Primary checking"
}
}'
```
For retry behavior, see [Idempotency keys for safe API retries](/api-reference/idempotency).
`inline` processing is the default. If Straddle returns a `pending` paykey, processing continues asynchronously and Straddle sends status changes through [paykey webhook events](/webhooks/overview/events).
## Read the response
An inline request that creates an `active` paykey returns `201 Created`.
```json theme={null}
{
"data": {
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"paykey": "2cd3e7b4.02.e271f11e0bd28fd609e5f7a426dabb2fc67646c7908ce8769c92c8c9448bce5e",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"external_id": "bank-connection-4412",
"label": "FINBANK - *0725",
"source": "mastercard",
"institution_name": "FINBANK",
"status": "active",
"status_details": {
"message": "Successfully matched account holder with customer.",
"reason": "ok",
"source": "system",
"changed_at": "2026-09-01T18:35:12.4821903Z"
},
"bank_data": {
"routing_number": "011401850",
"account_number": "**0725",
"account_type": "checking"
},
"balance": {
"account_balance": 723419,
"status": "completed",
"updated_at": "2026-09-01T18:35:12.4821899Z"
},
"config": {
"processing_method": "inline",
"sandbox_outcome": "standard"
},
"metadata": {
"nickname": "Primary checking"
},
"created_at": "2026-09-01T18:35:12.4821897Z",
"updated_at": "2026-09-01T18:35:12.4821903Z"
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f",
"api_request_timestamp": "2026-09-01T18:35:12.4832104Z"
},
"response_type": "object"
}
```
Store `data.paykey` for charges and payouts. Straddle uses the available balance returned by Mastercard and falls back to the cleared balance when Mastercard does not return an available balance.
Store the Mastercard token with the account connection. You'll need the consent receipt ID to revoke Mastercard access.
## Act on the paykey status
Use `data.status` to decide the next action.
| Status | Payment behavior |
| - | - |
| `active` | Create charges and payouts with the paykey. |
| `review` | Create charges and payouts. Straddle holds the payments until review resolves. |
| `pending` | Wait for asynchronous processing to finish before using the paykey. |
| `rejected` | Do not use the paykey for charges or payouts. |
For a `review` result, follow the [manual review process](/guides/bridge/paykeys#manual-review-process). See [Paykey status details](/guides/bridge/paykeys#paykey-status-details) for the full lifecycle.
## Recover from errors
For an `inline` request, use the HTTP status code to decide how to handle the error. For asynchronous processing, use the paykey status from [paykey webhook events](/webhooks/overview/events).
Treat `error.detail` and `status_details.message` as diagnostic text. Do not match their contents in code.
Recognized Mastercard token failures return `422 Unprocessable Entity` during `inline` processing. Straddle maps them to these diagnostic messages:
| Diagnostic message | Recovery |
| - | - |
| `The Mastercard consent is not valid for this account, or does not grant the access this request requires.` | Verify `mastercard.consent_receipt_id`, `mastercard.customer_id`, and `mastercard.account_id`. Confirm that the consent receipt includes all three required products for the account. |
| `The Mastercard consent has been revoked.` | Create a new Mastercard token, then retry with a new idempotency key. |
| `The Mastercard consent has expired.` | Create a new Mastercard token, then retry with a new idempotency key. |
| `The Mastercard consent has reached its usage limit.` | Create a new Mastercard token, then retry with a new idempotency key. |
| `Mastercard did not return ACH routing and account numbers.` | Use an account that returns the ACH details required to create a paykey. |
| `Mastercard is not enabled.` | Ask your Straddle contact to enable Mastercard for the request environment. |
| `Mastercard partner token is not available.` | Contact Straddle and include `meta.api_request_id`. |
| `Customer not found.` | Verify the top-level `customer_id` and the account scope of your API key. |
| `Cannot create paykey as customer is inactive.` or `Cannot create paykey as customer is rejected.` | Resolve the customer status or use an eligible customer. |
| `Institution not found for routing number '...'.` | Contact Straddle and include `meta.api_request_id`. |
During asynchronous processing, a failure listed in the table changes the paykey to `rejected` and sends a paykey webhook event. Other failures leave the paykey in `pending` while Straddle retries.
During `inline` processing, a Mastercard failure that is not listed in the table returns `500 Internal Server Error`. Contact Straddle before retrying and include `meta.api_request_id`.
## Keep the Mastercard token available
When you create the Mastercard token, set `maxCalls` and `accessPeriod` for each product. Mastercard's [Generate Third Party Access Key](https://developer.mastercard.com/open-finance-us/documentation/participant-model/partner-linked/client/client-steps/#operation/GenerateThirdPartyAccessKey) example uses `maxCalls: 200`. See [Set the token scope](/integrations/open-banking/mastercard#set-the-token-scope).
Unless your use case has a set expiration date, set `accessPeriod.endTime` as far into the future as your Mastercard configuration allows. Contact Mastercard for more information about access periods and call limits.
If the Mastercard token expires, is revoked, or reaches a call limit, Straddle cannot request a new balance. The paykey can remain `active` and keeps its last bank data and balance.
If Straddle cannot refresh the balance for a charge, the outcome depends on the charge's `config.balance_check` value:
* `disabled`: Straddle does not request a balance.
* `enabled`: The charge can continue without a completed balance check.
* `required`: The charge fails because Straddle cannot verify the balance.
You cannot replace the Mastercard token on an existing paykey. If Mastercard returns a new consent receipt, create a new paykey and [cancel the old paykey](/api-reference/paykeys/cancel).
## Test in sandbox
Create the Mastercard token in Mastercard's sandbox, then send the Bridge request to `https://sandbox.straddle.com`.
Name matching runs when `config.sandbox_outcome` is `standard`. Set `config.sandbox_outcome` to `active`, `rejected`, or `review` to force that paykey status. Use expired, revoked, under-scoped, and exhausted Mastercard tokens to test the recovery paths.
See [Sandbox testing for Pay by Bank](/guides/resources/sandbox-paybybank) for more scenarios.
## Disconnect the account
Complete both actions when the customer disconnects the account:
1. Call Mastercard's [Revoke Third Party Access](https://developer.mastercard.com/open-finance-us/documentation/api-reference/#operation/RevokeThirdPartyAccessKey) operation with the consent receipt ID.
2. [Cancel the Straddle paykey](/api-reference/paykeys/cancel).
Mastercard revocation stops future account data requests. Paykey cancellation stops future payment use through Straddle. Revoking the consent receipt alone does not cancel the paykey.
# Bridge API overview
Source: https://docs.straddle.com/guides/bridge/overview
Use the Straddle Bridge open-banking platform to securely connect customer identities to bank accounts and generate paykeys for initiating ACH payments.
Welcome to the comprehensive guide on **Bridge** and **Paykeys**, essential components of Straddle's **Pay by Bank** solution. This guide is designed to provide you with a deep understanding of how Bridge and Paykeys work together to facilitate secure, seamless account-to-account (A2A) payments.
By integrating Bridge into your application, you can:
* **Enable Open Banking Connections**: Allow customers to connect their bank accounts securely using Bridge.
* **Identity-to-Account**: Generate Paykeys to match customer identities with bank account ownership details.
* **Initiate Secure Payments**: Use Paykeys as secure tokens to initiate payments without exposing sensitive information.
This narrative guide walks you through the concepts, processes, and best practices for integrating Bridge and Paykeys, ensuring a smooth and secure payment experience for your customers.
## What is Bridge?
**Bridge** is Straddle's universal open banking solution that enables customers to connect their bank accounts seamlessly within your application. It serves as the gateway for establishing a secure link between the customer's verified identity and their bank account.
Drop-in widget with connections to over 90% of U.S. banks via open banking, plus support for manual bank account entry
Accept existing tokens from other open banking providers like Plaid, MX, and Finicity
Create secure payment tokens linking verified identities to bank accounts
Provide a seamless way for customers to connect their bank accounts
Your application never touches sensitive account data, simplifying compliance with data protection regulations
Dramatically reduce fraud risk by ensuring the person initiating a payment is the verified owner of the linked bank account
Unlike other open-banking solutions, Bridge provides multiple ways to connect your application to bank accounts:
An embeddable interface that allows customers to connect their bank accounts directly within your application.
Use existing tokens from your existing open banking provider with support for "processor tokens" from Plaid, MX, and Finicity.
Allow customers to manually enter their bank account details when open banking isn't an option.
## What are Paykeys?
A **Paykey** is a new kind of payment token generated upon successful **Bridge** connection. It represents the verified linkage between the customer's identity and their bank account, enabling you to initiate payments securely without exposing sensitive financial information.
The key innovation of Paykeys is that they cryptographically link a verified identity to confirmed bank account ownership. This linkage dramatically reduces fraud risk compared to traditional ACH payments.
By ensuring the person initiating a payment is the owner of the bank account, Paykeys significantly reduce the risk of unauthorized transactions.
Paykeys help meet KYC and AML requirements by tying verified identities to bank accounts, simplifying regulatory compliance.
Sensitive bank details are never exposed, reducing the risk of data breaches and simplifying PCI DSS compliance.
Once created, Paykeys can be reused for multiple transactions, streamlining the payment process for returning customers.
Take a deep dive into the what and why of Paykeys [here](/guides/bridge/paykeys).
## How Bridge creates Paykeys
From your perspective as a developer integrating with Straddle, the Paykey generation process via Bridge is streamlined and mostly handled internally by Straddle. Here's an overview of the steps involved:
Create a customer using Straddle's Customers API.
* You collect and submit basic customer information (name, email, phone, address)
* Straddle performs robust identity verification and KYC/AML checks internally
* You receive a `customer_id` for the verified customer
Use Bridge to connect the customer's bank account.
* Initiate the Bridge flow (widget, API, or manual entry)
* Customer provides their bank account information through the chosen method
* Bridge securely handles the bank account connection, extracting bank account numbers and ownership details
Straddle performs crucial matching to link identity and account ownership.
* Straddle compares the verified identity information with the bank account ownership details
* The WALDO algorithm is used to check for name matches, address correlation, and other identifying factors
* This step ensures that the person whose identity was verified is indeed the owner of the connected bank account
Upon successful matching, Straddle generates the Paykey.
* Straddle creates a secure, cryptographic token (the Paykey) that represents the verified identity-account linkage
* The Paykey is returned to you via the Bridge API response
Securely store and use the Paykey for payments.
* Store the Paykey securely in your system
* Use the Paykey to initiate payments via Straddle's Payments API
Straddle handles the complex parts of this process internally, including robust identity verification, bank account validation, and the crucial identity-to-account ownership matching. This not only simplifies your integration but also provides a strong foundation for secure, low-fraud payments.
## Integrating Bridge into your application
### Step-by-step integration
You must create a `customer` before you can connect with Bridge. View the [Customers API](/api-reference/customers/create) for more information.
Decide how you want customers to connect their bank accounts:
Use the embeddable widget for a seamless experience
Use Bridge with tokens from providers like Plaid
Allow manual input of bank details
Follow the implementation guide for your chosen method:
Add the following script tag to the `` of your HTML:
```html theme={null}
```
Make a POST request to generate a Bridge token:
```bash Request theme={null}
curl -X POST https://api.straddle.com/v1/bridge/initialize \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705"}'
```
```json Response theme={null}
{
"data": {
"bridge_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.....1GKotLEn7JOEofzwd-559LpS3Mg-RlhqMerr1zA5HY0"
},
"meta": {
"api_request_id": "029758cc-d273-465c-aefe-2310407e153c"
},
"response_type": "object"
}
```
Add the following script to your page to initialize the Bridge widget:
```html theme={null}
```
In the `onSuccess` callback, you'll receive a paykey object. Here's an example of what it looks like:
```json theme={null}
{
"data": {
"paykey": "05f5d55cb14f7e8a0ec2e5689376e3b4665efc34834d30995babbd5010b39913",
"bank_data": {
"routing_number": "011000138",
"account_number": "******7890",
"account_type": "checking"
},
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"label": "BANK OF AMERICA, N.A. - *7890",
"source": "straddle",
"institution_name": "BANK OF AMERICA, N.A.",
"status": "active",
"created_at": "2024-09-14T06:47:39.5648743Z",
"updated_at": "2024-09-14T06:47:39.5648746Z"
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f"
},
"response_type": "object"
}
```
Send the entire callback payload to your backend and inspect `data.status` before beginning a downstream workflow. An `active` paykey is ready for payment origination; a paykey in `review` requires approval or rejection before you treat it as active. See [Handle the Widget Callback](/guides/bridge/widget#3-handle-the-widget-callback) for the complete integration guidance.
Use your existing integration with Plaid, MX, or Finicity to obtain a processor token for the customer's previously connected bank account.
Make a server-side POST request to the Bridge API to create a Paykey using the third-party token:
```bash Create Paykey from Plaid Token theme={null}
curl -X POST https://api.straddle.com/v1/bridge/plaid \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"plaid_token": "plaid_processor_token"
}'
```
Use the Bridge API to create a Paykey from existing bank account details:
```bash Create Paykey from Bank Account theme={null}
curl -X POST https://api.straddle.com/v1/bridge/bank_account \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123456789",
"account_holder": "John Doe",
"routing_number": "110000000",
"account_number": "000123456789",
"account_type": "checking"
}'
```
Store the Paykey securely and use it for future payment initiation.
```json Paykey Response Example theme={null}
{
"data": {
"paykey": "05f5d55cb14f7e8a0ec2e5689376e3b4665efc34834d30995babbd5010b39913",
"bank_data": {
"routing_number": "011000138",
"account_number": "******7890",
"account_type": "checking"
},
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"label": "BANK OF AMERICA, N.A. - *7890",
"source": "straddle",
"institution_name": "BANK OF AMERICA, N.A.",
"status": "active",
"created_at": "2024-09-14T06:47:39.5648743Z",
"updated_at": "2024-09-14T06:47:39.5648746Z"
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f"
},
"response_type": "object"
}
```
## Best practices
* Always use HTTPS for all API calls and data transmissions.
* Implement proper error handling to manage failed Paykey generations or bank connections.
* Regularly rotate your API keys and use environment-specific keys (test/live).
* Implement webhook handlers to receive real-time updates on Paykey and payment statuses.
* Provide clear instructions and support for customers during the bank connection process.
## Frequently asked questions
The Paykey generation process is highly secure, using BLAKE3 hashing, encryption, and strict access controls. Sensitive data is never exposed or stored in plain text.
Yes, Paykeys are designed to be reusable for multiple payments, including one-time, recurring, and subscription payments. Ensure secure management and compliance with tokenization standards.
Bridge accepts tokens from providers like Plaid, MX, and Finicity. By providing the token to Bridge, it can retrieve bank account details and generate a Paykey without requiring the customer to reconnect their bank account.
If a mismatch is detected between the customer's verified identity and bank account ownership details, Paykey generation fails. Handle this gracefully by informing the customer and providing options to rectify the issue.
## Additional resources
# Paykeys: secure tokens for bank payments
Source: https://docs.straddle.com/guides/bridge/paykeys
Paykeys are reusable tokens linking verified customer identities to bank accounts to enable secure ACH charges, payouts, and recurring bank payments.
**Paykeys** are a cornerstone of Straddle's Pay by Bank stack. They are secure tokens that represent a customer's verified identity *and* their bank account.
The creation of a Paykey involves advanced identity matching through Straddle's proprietary name matching algorithm (WALDO). This algorithm compares the customer's known identity (obtained via Straddle ID) with the account ownership details retrieved from the customer's financial institution through open banking. This ensures that the individual initiating the payment is the legitimate owner of the bank account, significantly reducing the risk of fraud.
This guide explores how Paykeys work, the security measures in place, and how they integrate with other components of the Straddle ecosystem to facilitate secure payments.
Verifies that the customer connecting the bank account is its legitimate owner
Manages variations in PII, such as typos, nicknames, and cultural naming conventions
Identifies and prevents potential fraudulent activities before they occur.
Embeds regulatory compliance checks into the bank verification process
## How Bridge creates Paykeys
Bridge is Straddle's connectivity platform that securely links customers' bank accounts to your application. When a customer connects their bank account through Bridge, a Paykey is generated to securely represent this connection. Here's how the process works:
Before connecting a bank account, the customer is onboarded and their identity is verified using Straddle ID. This ensures compliance with KYC (Know Your Customer) and AML (Anti-Money Laundering) regulations.
The customer connects their bank account using the Bridge Widget, an embeddable interface within your application.
Alternatively, Bridge accepts existing tokens from providers like Plaid, MX, or Finicity, leveraging customers' pre-existing bank connections.
Paykeys name matching is also possible with manual bank entry.
WALDO is Bridge's proprietary algorithm for verifying bank account ownership.
WALDO compares the customer's verified identity with the bank account ownership details
The algorithm accounts for minor discrepancies, such as nicknames, middle names, typos, and cultural naming conventions.
Prevent fraudulent activities and unauthorized access to bank accounts.
The verification occurs instantly in the API response
A Universally Unique Identifier (UUID) is generated to represent the link between the customer and their bank account.
The UUID is hashed using a cryptographic hash function (BLAKE3) to ensure it cannot be reverse-engineered. The hashed value is encoded (e.g., Base64 or URL-safe encoding) to produce the Paykey.
The result is a secure, unique token (the Paykey) that represents the customer-bank account linkage.
Based on WALDO's verification results, the paykey is assigned an initial status:
* active
* rejected
* review (requires manual review)
The Paykey object is securely returned to your application. It includes the paykey, masked bank account details, the available balance, and the current verification status.
Your application never has to transmit PII or bank account details to Straddle.
The Paykey authorizes payments without exposing sensitive details.
By integrating Bridge and utilizing the WALDO algorithm to create Paykeys, you provide a secure and efficient way to process payments, enhancing both security and user experience.
## Paykey object definition
The **Paykey** object represents a secure, tokenized link between a customer and their bank account. It is used to authorize payments without exposing sensitive financial information.
## Paykey attributes
| Field | Type | Description |
| - | - | - |
| `id` | string | Unique identifier for the paykey, generated by Straddle. |
| `customer_id` | string | Unique identifier of the customer associated with this paykey. |
| `label` | string | Human-readable label for the paykey, often including the bank name and masked account number. |
| `source` | string | Method used to create the paykey (e.g., `bank_account`, `plaid`, `mx`, `straddle`). |
| `institution_name` | string | Name of the financial institution associated with the paykey. |
| `status` | string | Current status of the paykey (`pending`, `active`, `inactive`, `rejected`, `review`). |
| `status_details` | object | Additional information about the paykey's status. |
| ↳ `message` | string | A human-readable description of the current status. |
| ↳ `reason` | string | A machine-readable identifier for the specific status. |
| ↳ `source` | string | Identifies the origin of the status change (e.g., 'bank\_decline', 'system'). |
| `paykey` | string | The tokenized paykey value used for transactions. |
| `bank_data` | object | Masked bank account details associated with the paykey. |
| ↳ `routing_number` | string | The bank's routing number. |
| ↳ `account_number` | string | The masked bank account number (e.g., "\*\*\*\*\*\*1234"). |
| ↳ `account_type` | string | The type of bank account (e.g., "checking" or "savings"). |
| `balance` | integer | The available balance of the linked account in cents, if available. |
| `metadata` | object | User-defined key-value pairs for storing additional information about the paykey. |
| `expires_at` | datetime | Expiration date and time of the paykey, if applicable. |
| `created_at` | datetime | Timestamp of when the paykey was created. |
| `updated_at` | datetime | Timestamp of the most recent update to the paykey. |
## Verification results
On paykey creation, Straddle performs name matching and determines whether the bank account is open and ready for transactions. The verification data Straddle uses to evaluate each paykey can be retrieved from the `/paykeys/{id}/review` endpoint. Use these insights to help you decide whether to `accept` or `reject` paykeys in `review` status, or to `cancel` `active` paykeys if needed.
## Review attributes
| Field | Type | Description |
| - | - | - |
| `id` | string | Unique identifier for this verification record. |
| `decision` | string | Overall verification decision (`accept`, `review`, or `reject`). |
| `messages` | object | Key-value pairs of verification codes and their human-readable descriptions. |
| `breakdown` | object | Detailed results for each verification check performed. |
| ↳ `name_match` | object | Results from comparing the customer name to the matched name on the account. \*These fields will be null when an account is linked using account and routing number only. |
| ↳ `names_on_account` | array | List of account holder names retrieved from the bank. |
| ↳ `matched_name` | string | The name from the account that was compared to the customer name. |
| ↳ `customer_name` | string | The customer's name. |
| ↳ `correlation_score` | number | Numerical score representing name similarity (0-100). |
| ↳ `decision` | string | Decision for this check (`accept`, `review`, or `reject`). |
| ↳ `reason` | string | Human-readable explanation for the decision. |
| ↳ `codes` | array | List of verification codes related to this check (e.g., `NM01`). |
| ↳ `account_validation` | object | Results from account validation checks. \*These fields will be null when open banking tokens are used. |
| ↳ `decision` | string | Decision for this check (`accept`, `review`, or `reject`). |
| ↳ `reason` | string | Human-readable explanation for the decision (empty if accepted). |
| ↳ `codes` | array | List of verification codes related to this check. |
| ↳ `created_at` | datetime | Timestamp of when the verification was performed. |
| ↳ `updated_at` | datetime | Timestamp of the most recent update to the verification record. |
| `meta` | object | Request metadata. |
| ↳ `api_request_id` | string | Unique identifier for this API request. |
| ↳ `api_request_timestamp` | datetime | Timestamp of when the API request was processed. |
| `response_type` | string | Type of response returned (typically `object`). |
## Paykey status details
| Status | Description |
| - | - |
| `pending` | Initial status when the paykey is created and awaiting verification, or when reprocessing is triggered. |
| `active` | Paykey has been verified and is ready for use in transactions. |
| `review` | Paykey requires manual review due to verification issues (e.g., name variations). |
| `inactive` | Paykey is no longer active and cannot be used for transactions. |
| `rejected` | Paykey failed verification or was rejected by the financial institution. |
* The `account_number` in the `bank_data` object is always masked for security reasons. Use the unmasked paykey data endpoint to access the full account number when necessary and authorized.
* The `balance` field is only available for certain integration types and may not always be present.
* The `source` field indicates the method used to create the paykey, which can affect the available features and verification process.
* The `metadata` object can contain up to 20 key-value pairs, each with a maximum length of 40 characters for keys and 500 characters for values.
* The `created_at` and `updated_at` fields are automatically managed by Straddle and cannot be modified directly.
* The `expires_at` field is only applicable for certain types of paykeys and integration methods.
* Paykeys in `review` status can be manually approved or rejected via PATCH `/paykeys/{id}/review`.
* Use GET `/paykeys/{id}/review` (or confirm if different endpoint) to retrieve verification details.
### Example Paykey object
```json theme={null}
{
"id": "pk_1234567890abcdef",
"customer_id": "cus_9876543210fedcba",
"label": "Chase Checking (...1234)",
"source": "bank_account",
"institution_name": "Chase",
"status": "active",
"status_details": {
"message": "Paykey is active and ready for use",
"reason": "verified",
"source": "system"
},
"expires_at": "2024-12-31T23:59:59Z",
"created_at": "2023-06-15T10:30:00Z",
"updated_at": "2023-06-15T10:30:00Z",
"paykey": "vzeNDwK7KQIm4yEog683uElbp9GRLEFXGK98D",
"bank_data": {
"routing_number": "123456789",
"account_number": "******1234",
"account_type": "checking"
},
"metadata": {
"user_id": "user_5678",
"account_nickname": "My Primary Checking"
}
}
```
## Paykey verification and manual review
When a paykey is created, it goes through an automated verification process that can result in one of three decisions:
Immediate Approval
The paykey passes all verification checks and is ready for use in payments immediately.
Manual Review Required
The paykey has verification issues (e.g., name variations) that require human review before approval.
Verification Failed
The paykey fails verification due to significant issues and cannot be used for payments.
### Verification codes and their meaning
A paykey's verification decision and status are determined by the codes it receives during processing. If any rejection code is present, the paykey is `rejected` regardless of other successful verification results. Other codes result in the paykey status being transitioned to `review`. Paykeys that pass verification become `active`.
Paykeys must be in `review` status to have their verification outcome modified.
| Straddle Code | Meaning |
| :- | :- |
| **NM01** | Account Holder is not a match for Customer. |
| **BR104** | The bank account owner's information does not match with the information provided. |
| Straddle Code | Meaning |
| :- | :- |
| **BR101** | The bank account is either closed, invalid, or in a negative status |
| **BR102** | The bank account is either ineligible for debit activity or deemed to have a high probability of return |
| **BR105** | The bank account requested for verification has not been contributed by the participant bank |
| **BR106** | The bank account has been closed as a result of unacceptable use by the customer |
| **BR107** | The bank account has been removed from the Contributor's source |
| **BR108** | The bank account will not accept any debit activity |
| **BR109** | The bank account has been closed and removed from the Contributor's source |
| **BR110** | The bank account is closed in the last processing cycle |
| **BR111** | The bank account has a history of available balance being less than zero |
| **BR112** | The bank account provided is not a demand deposit account (non-DDA account) |
| **BR113** | The bank account has a high probability of return |
| **BR114** | Likely an invalid account number/routing number |
| **BR115** | Bank account owner information does not match with the information provided (open banking) |
| **BR116** | Bank Data Provider returned invalid owner information error |
| **BR117** | Bank Data Provider returned invalid length for account number and routing number error |
| **BR119** | The bank account owner's DOB doesn't match with the bank data provider |
| **BR120** | The bank account owner's SSN or tax ID doesn't match with the bank data provider |
### Manual review process
Manual paykey review gives you control over verification decisions. When a paykey has a `review` status, you can evaluate verification details and make informed decisions about whether to approve or reject the paykey, either through the dashboard or programmatically. This helps you prevent fraudulent accounts, manage risk, and ensure only legitimate payment methods are activated on your platform.
Name information is only available for paykeys linked through Open Banking. Paykeys connected using account and routing number don't include account holder name data, so `name_match` fields in the review response are `null`. Use Open Banking connections where possible to enable full name verification at review time.
You can view all paykeys requiring review at the bottom of the [Overview](https://dashboard.straddle.com) page, or update their status programmatically using the review endpoint:
1. **Review Details**: Access detailed verification information that may include names on the bank account and matched name in the dashboard or retrieve it from the `review` endpoint.
2. **Manual Decision**: Resolve the paykey status by setting it to `active` or `rejected`.
3. **Retry Verification**: Optionally refresh the verification process to re-evaluate the paykey.
The review process ensures that edge cases and minor discrepancies don't automatically reject legitimate paykeys, while maintaining security standards.
**Payment Processing During Paykey Review**
Payments are held while paykeys are under review. All transactions associated with a paykey in review status are held until the paykey is either approved or rejected.
Review paykeys promptly to avoid payment backlogs. Delayed reviews can cause multiple payments to queue up and process simultaneously once the paykey is approved. This can result in unexpected batch processing of charges or payouts for a single account.
**Paykey Review Response**
Sample responses from the `/paykeys/{id}/review` endpoint.
Accounts linked via open banking show `null` for account validation details because validation is performed by the open banking provider. However, the same validation checks are still conducted. They're just handled upstream by the provider rather than Straddle.
```json theme={null}
{
"data": {
"paykey_details": {...},
"verification_details": {
"id": "019a1743-d6db-7771-8f7f-09e43a08d1c8",
"decision": "accept",
"messages": {},
"breakdown": {
"name_match": {
"decision": "accept",
"reason": "Successfully matched account holder with customer.",
"codes": [],
"matched_name": "John Michael Doe",
"customer_name": "John Doe",
"correlation_score": 0.95,
"names_on_account": [
"John Michael Doe",
"Jane Doe"
]
},
"account_validation": {
...
}
},
...
}
}
}
```
```json theme={null}
{
"data": {
"paykey_details": {...},
"verification_details": {
"id": "01995295-954b-73cd-bd55-74dfff6ef4c6",
"decision": "reject",
"codes": ["BR101"],
"messages": {
"BR101": "The bank account is either closed, invalid, or in a negative status."
},
"breakdown": {
"name_match": {...},
"account_validation": {
"decision": "reject",
"reason": "The bank account is either closed, invalid, or in a negative status. Derived using the routing number and account number.",
"codes": ["BR101"]
}
},
...
}
}
}
```
An account that is linked using account and routing number has a null name match object since this data is not returned by the provider. Straddle recommends using an open banking login where possible.
```json theme={null}
{
"data": {
"paykey_details": {...},
"verification_details": {
"id": "456e7890-e89b-12d3-a456-426614174001",
"decision": "review",
"messages": {
"NM01": "Account Holder is not a match for Customer."
},
"breakdown": {
"name_match": {
"decision": "review",
"reason": "Account Holder is not a match for Customer.",
"matched_name": "John Smith",
"correlation_score": 0.10,
"names_on_account": ["John Smith", "Jane Smith"]
},
"account_validation": {...}
},
...
}
}
}
```
## Account balance updates
For accounts linked using an open banking token or Bridge, you can receive balance updates when the following events occur:
* When a new Paykey is created
* When the new [refresh](https://straddle.dev/api-reference#tag/paykeys/PATCH/v1/paykeys/\{id}/refresh_balance) endpoint is explicitly called, at most once per hour
* When a charge or payout is created
You receive the balance update within a [Paykey webhook event](https://straddle.dev/api-reference#webhook/post/paykeyeventv1).
**Manually trigger balance updates:** You can also trigger a balance refresh by calling our new `/paykeys/{id}/refresh_balance` endpoint.
## Using Paykeys
Paykeys are used in place of customer and bank account details when creating charges or payouts. Here's an example of creating a charge using a paykey:
```shellscript theme={null}
curl -X POST https://sandbox.straddle.com/v1/charges \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"paykey": "a1b2c3***.02.******x9y8z7",
"amount": 1000,
"currency": "usd",
"description": "Monthly subscription fee",
"payment_date": "2023-06-01",
"consent_type": "internet",
"device": {
"ip_address": "192.168.1.1"
},
"external_id": "charge_123",
"config": {
"balance_check": "enabled"
}
}'
```
## Ongoing management & unblocking
When a Paykey is blocked (e.g., R29), your customer can't pay or get paid until it's fixed. Unblock in the Dashboard once they've updated their bank settings, with no support wait, so they can use the Paykey again quickly. View blocked Paykeys in the [Overview](https://dashboard.straddle.com/) tab or manage them directly from the specific Customer page.
Use the new `PATCH /v1/paykeys/{id}/unblock` endpoint to programmatically reactivate eligible Paykeys.
### Handling R29 returns
Corporate "positive pay" blocks often cause R29 returns; you can now confirm the customer has added your ACH identifier to their approved list and select "Unblock Paykey" in the Dashboard.
## Benefits of Paykeys
### For businesses
Prevent unauthorized account use and save on potential fraud-related losses.
Simplify adherence to KYC and AML regulations.
Automate identity matching, reducing the need for manual reviews while providing human oversight for edge cases.
Enhance reputation by ensuring secure transactions.
### For customers
Protect customers from unauthorized use of their bank accounts.
Eliminate the need for additional verification steps in most cases.
Ensure personal data is handled securely and used appropriately.
Build trust in the platform's ability to protect financial information.
## Further reading
* [Paykeys API Reference](/api-reference/paykeys)
# Create paykeys from Plaid processor tokens
Source: https://docs.straddle.com/guides/bridge/plaid-token
Exchange Plaid processor tokens for Straddle paykeys to enable verified ACH charges and payouts for customers connected through Plaid Link.
This guide provides a detailed walkthrough on integrating Plaid with Straddle to create paykeys for account-to-account payments. By leveraging Plaid's bank connections and Straddle's payment infrastructure, you can offer a seamless and secure payment experience to your users.
## Prerequisites
Before you begin, ensure you have:
* A Straddle account with API access
* A Plaid account with API access
## Implementation steps
Integrate Plaid Link into your frontend to allow users to securely connect their bank account. Plaid Link is the front-end module that facilitates the connection between the user's bank account and your application.
Once the user connects their bank account using Plaid Link, Plaid returns a public token. Exchange this public token for an access token via Plaid’s API, which allows you to access the user's account information.
With the access token obtained from Plaid, request a Straddle processor token from Plaid. This token allows you to link the user's bank account to Straddle's payment processing system.
Pass the Straddle processor token to Straddle's Bridge API. Straddle returns a `paykey` which is linked to the user's bank account, allowing future transactions to be processed.
Store the `paykey` securely in your system. Use this `paykey` to create charges, initiate payments, or perform other transactions via Straddle's API in the future.
## Setting up Plaid
### Create a `link_token`
In order to integrate with Plaid Link, you first need to create a `link_token`. A `link_token` is a short-lived, one-time use token that is used to authenticate your app with Link. To create one, make a [`/link/token/create`](https://plaid.com/docs/api/link/#linktokencreate) request with your `client_id`, `secret`, and a few other required parameters from your app server. View the [`/link/token/create`](https://plaid.com/docs/api/link/#linktokencreate) documentation for a full list of `link_token` configurations.
To see your `client_id` and `secret`, visit the [Plaid Dashboard](https://dashboard.plaid.com/developers/keys).
```curl theme={null}
curl -X POST https://sandbox.plaid.com/link/token/create \
-H 'Content-Type: application/json' \
-d '{
"client_id": "${PLAID_CLIENT_ID}",
"secret": "${PLAID_SECRET}",
"client_name": "Plaid Test App",
"user": { "client_user_id": "${UNIQUE_USER_ID}" },
"products": ["auth"],
"country_codes": ["US"],
"language": "en",
"webhook": "https://webhook.example.com",
"redirect_uri": "https://domainname.com/oauth-page.html"
}'
```
**Integrate with Plaid Link**
Once you have a `link_token`, all it takes is a few lines of client-side JavaScript to launch Link. Then, in the `onSuccess` callback, you can call a simple server-side handler to exchange the Link `public_token` for a Plaid `access_token` and a Straddle `processor_token`.
```javascript theme={null}
```
## Obtaining a Straddle processor token from Plaid
Once you have the access token, you can use it to obtain a Straddle processor token. This token is specific to Straddle and allows secure communication between Plaid and Straddle.
```javascript theme={null}
# Exchange the public token from Plaid Link for an access token.
curl \
-H 'Content-Type: application/json' \
-d '{
"client_id": "${PLAID_CLIENT_ID}",
"secret": "${PLAID_SECRET}",
"public_token": "${PUBLIC_TOKEN}"
}' \
-X POST \
https://sandbox.plaid.com/item/public_token/exchange
# Create a processor token for a specific account id.
curl \
-H 'Content-Type: application/json' \
-d '{
"client_id": "${PLAID_CLIENT_ID}",
"secret": "${PLAID_SECRET}",
"access_token": "${ACCESS_TOKEN}",
"account_id": "${ACCOUNT_ID}",
"processor": "straddle"
}' \
-X POST \
https://sandbox.plaid.com/processor/token/create
```
Note that `'straddle'` is the specific processor you're requesting the token for. This tells Plaid to generate a token compatible with Straddle's systems.
## Using the Straddle Bridge API with Plaid token
Once you have obtained the Straddle processor token from Plaid, you can use it to create a paykey via Straddle's Bridge API. Here's the correct HTTP request format:
```bash Bridge a Plaid Token theme={null}
curl -X POST https://api.straddle.com/v1/bridge/plaid \
-H "Authorization: Bearer YOUR_STRADDLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"plaid_token": "processor-sandbox-123abc...",
"metadata": {
"nickname": "My Bank Account"
}
}'
```
Replace `YOUR_STRADDLE_API_KEY` with your actual Straddle API key, and fill in the appropriate values for `customer_id` and `plaid_token`. The `metadata` field is optional but can be useful for storing additional information related to the Plaid account.
When creating a paykey, the account holder's name is matched against the customer's name. Therefore, when using a Plaid token, to get an active paykey, the customer's name must match the Plaid token's account holder's name. In sandbox, the Plaid account holder's name is usually defaulted to **Alberta Bobbeth Charleson**. This can be changed in the Plaid system.
In sandbox, this behavior can be overridden by specifying a [sandbox outcome](/guides/resources/sandbox-paybybank) in the request.
## Handling the Straddle API response
The Straddle API responds with a paykey object. Here's an example of what you might receive:
```json theme={null}
{
"data": {
"paykey": "05f5d55cb14f7e8a0ec2e5689376e3b4665efc34834d30995babbd5010b39913",
"bank_data": {
"routing_number": "011000138",
"account_number": "******7890",
"account_type": "checking"
},
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"label": "CHASE BANK - *7890",
"source": "plaid",
"institution_name": "CHASE BANK",
"status": "active",
"created_at": "2024-09-14T06:47:39.5648743Z",
"updated_at": "2024-09-14T06:47:39.5648746Z",
"metadata": {
"plaid_account_id": "5f7a8b9c0d1e2f3g4h5i6j7k"
}
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f"
},
"response_type": "object"
}
```
Note that the `source` field is set to "plaid" in this case, indicating that the paykey was created using a Plaid token.
You should store this paykey securely for future use in transactions.
## Best practices and security considerations
1. **Token Security**: Never expose Plaid access tokens or Straddle processor tokens to the frontend. Always handle these server-side.
2. **Error Handling**: Implement robust error handling for both Plaid and Straddle API calls.
3. **Metadata Usage**: Use the metadata field to store relevant information, such as the Plaid account ID, for future reference.
4. **Token Refreshing**: Be aware of token expiration policies for both Plaid and Straddle. Implement token refresh mechanisms as needed.
5. **Compliance**: Ensure you're complying with both Plaid and Straddle's terms of service and data handling requirements.
6. **Logging**: Implement comprehensive logging for debugging and audit purposes, but be careful not to log sensitive information.
## Troubleshooting common issues
1. **Invalid Processor Token**: Ensure you're using 'straddle' as the processor when requesting the token from Plaid.
2. **Authentication Errors**: Double-check your API keys for both Plaid and Straddle.
3. **Expired Tokens**: If you're getting authentication errors, your tokens might have expired. Implement a token refresh mechanism.
4. **Account Not Supported**: Some bank accounts may not be supported for ACH transactions. Handle these cases gracefully in your UI.
5. **Rate Limiting**: Be aware of rate limits on both Plaid and Straddle APIs. Implement appropriate backoff strategies if you hit these limits.
By following this guide, you should be able to successfully integrate Plaid with Straddle, leveraging the strengths of both platforms to provide a robust, secure payment solution for your users.
# Create paykeys from Quiltt tokens
Source: https://docs.straddle.com/guides/bridge/quiltt-token
Exchange Quiltt processor tokens for Straddle paykeys to enable verified ACH charges and payouts for customers connected through the Quiltt platform.
## Prerequisites
Before you begin, ensure you have:
* A Straddle account with API access
* A Quiltt account with processor token capabilities
* Quiltt Connector configured with `ACCOUNT_NUMBERS` and `ACCOUNT_BALANCE_REFRESHES` features
For a complete integration guide including Quiltt Connector setup, see our [detailed Quiltt integration guide](/integrations/open-banking/quiltt).
## Quick start
Follow these steps to create a paykey from a Quiltt processor token.
### Step 1: Obtain a Quiltt processor token
After your user connects their bank account through Quiltt Connector, create a processor token:
```bash theme={null}
curl https://api.quiltt.io/v1/accounts/{accountId}/processor_tokens \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {QUILTT_API_KEY}' \
--data '{
"processor": "STRADDLE",
"issuer": "QUILTT"
}'
```
### Step 2: Create a Paykey via Bridge API
Use the processor token to create a paykey:
```bash theme={null}
curl -X POST https://api.straddle.com/v1/bridge/quiltt \
-H "Authorization: Bearer YOUR_STRADDLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"quiltt_token": "processor-sandbox-123abc...",
"metadata": {
"nickname": "My Bank Account"
}
}'
```
### Step 3: Handle the response
A successful response returns the paykey and associated bank data:
```json theme={null}
{
"data": {
"paykey": "05f5d55cb14f7e8a0ec2e5689376e3b4665efc34834d30995babbd5010b39913",
"bank_data": {
"routing_number": "011000138",
"account_number": "******7890",
"account_type": "checking"
},
"id": "0191ef49-892c-7460-99d1-f5589d7d9989",
"customer_id": "0191ef41-8de5-716c-bfa4-41cd79e85705",
"label": "CHASE BANK - *7890",
"source": "quiltt",
"institution_name": "CHASE BANK",
"status": "active",
"created_at": "2024-09-14T06:47:39.5648743Z",
"updated_at": "2024-09-14T06:47:39.5648746Z",
"metadata": {
"quiltt_connection_id": "conn_5f7a8b9c0d1e2f3g4h5i6j7k",
"quiltt_account_id": "acc_1a2b3c4d5e6f7g8h9i0j"
}
},
"meta": {
"api_request_id": "243431dd-7deb-4445-820d-55a942ace70f"
},
"response_type": "object"
}
```
Store the `paykey` securely for future transactions. Use it to [create charges](/api-reference/charges/create) and Straddle verifies the account balance before processing.
## Implementation flow
User connects their bank account via Quiltt Connector
Fetch account details using Quiltt's GraphQL API
Create processor token for selected account
Bridge processor token to create Straddle paykey
Store paykey for payment processing
## Troubleshooting
Common issues and their solutions:
| Issue | Solution |
| - | - |
| Invalid processor token | Ensure `processor: "STRADDLE"` and `issuer: "QUILTT"` |
| Authentication errors | Verify your Quiltt API key and Straddle API key |
| Missing features | Enable `ACCOUNT_NUMBERS` in Quiltt Connector |
| Connection not active | Wait for connection status to be `active` |
# Bridge widget for connecting bank accounts
Source: https://docs.straddle.com/guides/bridge/widget
Embed the Straddle Bridge widget in your app for a drop-in UI that securely connects customer bank accounts and returns paykeys for ACH payments.
The Bridge widget allows users to securely connect their bank accounts to your application. Unlike other open banking providers, Straddle handles data exchanges, retrieves bank details and owner information, and generates a secure payment token, all without exposing sensitive information to your frontend.
Before interacting with the Bridge widget, ensure you have created a customer in Straddle. For details on customer creation, see the [Customers Guide](/guides/identity/customers).
## Overview
Users click a button or link to initiate the process.
Return the session's `bridge_token` to your client application.
Pass the `bridge_token` to your implementation of Bridge.
Process the response and save the generated [paykey](/guides/bridge/paykeys) after successful account linking.
## Implementation options
Straddle offers multiple ways to integrate the Widget into your application. Choose the option that best fits your development environment and requirements.
The simplest way to implement the Bridge widget is by using our hosted script. This method is ideal for quick integrations and applications without a specific JavaScript framework.
```html theme={null}
```
For applications using vanilla JavaScript or other frameworks, we offer a JavaScript package that provides more flexibility in implementation.
Check out our [GitHub repository](https://github.com/straddleio/straddle-bridge-client/tree/main/packages/bridge-js) for the latest updates and additional resources.
Install the package:
```bash theme={null}
npm install @straddlecom/bridge-js
```
**or**
```bash theme={null}
yarn add @straddlecom/bridge-js
```
Use the package in your JavaScript code:
```javascript theme={null}
import { straddleBridge } from '@straddlecom/bridge-js'
straddleBridge.init({
mode: 'sandbox', // 'production' or 'sandbox'
token: 'bridge_token', // replace with your token
onSuccess: (payload) => {
console.log('Success event, paykey data is:', payload)
},
onSuccessCTAClicked: () => {
console.log('Success CTA clicked')
},
onClose: () => {
console.log('Straddle widget closed')
},
onLoadError: (error) => {
console.error('Error loading Straddle Bridge Widget', error)
},
style: {
position: 'absolute',
width: '100%',
height: '80%',
top: '200px',
left: '0',
},
debug: true,
})
// To show the widget
straddleBridge.show()
// To hide the widget
straddleBridge.hide()
// To remove the widget from the DOM
straddleBridge.remove()
// To send a custom message to the widget
straddleBridge.send(message)
```
For React applications, we provide a dedicated npm package that offers a more integrated experience with your React components.
Check out our [GitHub repository](https://github.com/straddleio/straddle-bridge-client/tree/main/packages/bridge-react) for the latest updates and additional resources.
Install the package:
```bash theme={null}
npm install @straddlecom/bridge-react
```
**or**
```bash theme={null}
yarn add @straddlecom/bridge-react
```
Use the Bridge component in your React application:
```jsx theme={null}
import React, { useState } from 'react'
import { StraddleBridge } from '@straddlecom/bridge-react'
const StraddleBridgeController = () => {
const [open, setOpen] = useState(true)
const token = 'bridge_token' // replace with your token
const mode = 'sandbox' // 'production' or 'sandbox'
const handleSuccess = (payload) => {
console.log('Success event, paykey data is:', payload)
}
const handleSuccessCTAClicked = () => {
console.log('Success CTA clicked (after a success, when the user clicks the CTA button)')
setOpen(false)
}
const handleClose = () => {
console.log('Straddle widget closed')
}
const handleLoadError = (error) => {
console.error('Error loading Straddle Bridge Widget', error)
}
return (