> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk Currency Conversion

The Bulk Currency Conversion API enables you to perform individual or multiple Foreign Exchange (FX) transactions programmatically with optimal rates and processing efficiency.

## Prerequisites

Before creating currency exchanges, ensure you have:

* **Valid API credentials** with currency exchange permissions .
* **Active account numbers** for both source and destination currencies.
* **Sufficient balance** in your source currency account.

> [!WARNING]
>
> **Important**
>
> You can pre-generate exchange rate quotes using our [Currency Exchange Quote API](https://docs.localpayment.com/docs/quote-currency-conversion.md) and lock in rates by including the `exchangeRateToken` in your bulk request.

***

## API Endpoint

To create bulk exchanges, send a `POST` request to the [Create Bulk FX Conversion](https://docs.localpayment.com/reference/exchange-bulk.md) endpoint.

### Endpoint

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
POST https://api.stage.localpayment.com/currency-exchange
```

### Authentication

Include your access token in all API requests:

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
Authorization: Bearer <your_access_token>
```

### Key Request Parameters

| Parameter | Type | Description |
| - | - | - |
| `externalId` | string | Unique identifier for your transaction |
| `country` | string | ISO country code |
| `currency` | string | Base currency code |
| `account.debited` | object | Source account details |
| `account.credited` | object | Destination account details |

### Example Request (Argentina)

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/currency-exchange \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '{
       "country": "ARG",
       "currency": "ARS", 
       "externalId": "7a9c72a0-7a8e-4f72-b2b3-a04054d3129f",
       "account": {
         "debited": {
           "currency": "ARS",
           "accountNumber": "{{accountNumber}}", 
           "amount": 10000
         },
         "credited": {
           "currency": "EUR",
           "accountNumber": "{{accountNumber}}"
         }
       }
     }'
```

***

## Response Handling

### Success Response

A successful currency exchange returns transaction details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "transactionType": "CurrencyExchange",
  "externalId": "7a9c72a0-7a8e-4f72-b2b3-a04054d3129f",
  "internalId": "8888ad65-aa6e-4643-b9ba-ff62318fd90b", 
  "country": "ARG",
  "currency": "ARS",
  "exchangeRateToken": "",
  "clientCode": "0005",
  "creationDate": "2023-03-21T21:25:14.533+00:00",
  "errors": [],
  "status": {
    "code": "200",
    "description": "COMPLETED",
    "detail": "CURRENCY EXCHANGE"
  },
  "account": {
    "debited": {
      "currency": "ARS", 
      "accountNumber": "{{accountNumber}}",
      "amount": 10000
    },
    "credited": {
      "currency": "EUR",
      "accountNumber": "{{accountNumber}}", 
      "amount": 44.52
    },
    "appliedFx": 224.54
  }
}
```

### Key Response Fields

| Field | Description |
| - | - |
| `internalId` | System-generated transaction ID for tracking |
| `status.code` | Current transaction status code |
| `account.appliedFx` | Exchange rate applied to the conversion |
| `account.credited.amount` | Final converted amount |

***

### Error Response

#### Insufficient Funds

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "7a9c72a0-7a8e-4f72-b2b3-a04054d3129f",
  "internalId": "6fc7e955-7704-4558-8a05-6f4a2c3d9b45",
  "errors": [
    {
      "code": "101",
      "detail": "Insufficient funds in source account"
    }
  ],
  "status": {
    "code": "101", 
    "description": "REJECTED",
    "detail": "Insufficient funds in source account"
  }
}
```

***

## Transaction Status Tracking

Monitor your currency exchanges through multiple channels:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications when transaction status changes. Most efficient for production environments.

> [card] [Status API Endpoint](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.

> [card] [Business Portal View](https://docs.localpayment.com/docs/dashboard-overview.md)
>
> Visual interface for monitoring transactions. Great for manual oversight and detailed transaction analysis.

### Status Lifecycle

| Code | Status | Description |
| :- | :- | :- |
| `103` | `APPROVED` | The currency exchange was approved |
| `200` | `COMPLETED` | The currency exchange was finished |
| `303` | `REJECTED` | This exchange rate token has expired. |
| | | |

> [!NOTE]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Advanced Features

### Using Exchange Rate Quotes

Lock in favorable rates by pre-generating quotes:

1. **Generate Quote**: Call the [Currency Exchange Quote API](https://docs.localpayment.com/reference/currency-exchange-quote.md)
2. **Get Token**: Extract the `exchangeRateToken` from the response
3. **Apply Token**: Include token in your bulk exchange request

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "exchangeRateToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "externalId": "7a9c72a0-7a8e-4f72-b2b3-a04054d3129f",
  "account": {
    // ... rest of request
  }
}
```

### Bulk Processing Tips

**Performance Optimization**

* **Batch requests**: Group multiple exchanges into single API calls when possible.
* **Rate limiting**: Implement exponential backoff for high-volume processing.
* **Webhook handling**: Use webhooks instead of polling for status updates.
* **Error retry logic**: Implement smart retry mechanisms for temporary failures.

***

## Testing & Validation

### Sandbox Environment

Test your integration in our sandbox environment:

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
POST https://api.sandbox.localpayment.com/currency-exchange
```

### Test Scenarios

Validate these scenarios before going live:

* Successful currency exchange with valid accounts
* Error handling for insufficient funds
* Exchange rate token expiration
* Invalid account number handling
* Network timeout scenarios
* Webhook notification processing

***

## Resources & Next Steps

Maximize your integration success with these essential resources

> [card] [Webhook Integration](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up real-time notifications for transaction status updates.

> [card] [Reporting Business Portal](https://docs.localpayment.com/docs/balance-report.md)
>
> Access detailed analytics, reporting tools, and reconciliation features.

> [card] [Transaction Monitoring](https://docs.localpayment.com/reference/transaction-status-error-codes)
>
> Learn to query transaction status and implement comprehensive tracking.

> [card] [API Reference](https://docs.localpayment.com/reference/exchange-bulk.md)
>
> Complete endpoint documentation with interactive examples.

> [!NOTE]
>
> **Pro Tip**
>
> Always test your workflow in our sandbox environment before deploying to production. This ensures your error handling, webhook processing, and status tracking work correctly across all scenarios.

***

> [!NOTE]
>
> **Need Help?**
>
> Contact our [support team](mailto:support@localpayment.com) if you experience any issues or need assistance for integration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.