POST /api/transactions
Creates a new currency exchange transaction for the authenticated user. The endpoint automatically calculates commissions based on the transaction amount and validates the exchange rate against the current market rate with a tolerance of 0.35 Bs.Authentication
This endpoint requires authentication. Include a valid JWT token in the Authorization header:Request Body
The type of transaction. Must be either
"Comprar" (Buy) or "Vender" (Sell).- Comprar: User buys USD, commission is added to the amount
- Vender: User sells USD, commission is deducted from the amount
The base amount in USD for the transaction. Must be a positive number.The commission is automatically calculated based on this amount:
- 9.99: $0.80 commission
- 14.99: $1.00 commission
- 25: $1.40 commission
- Above 1.40 + (25))
The exchange rate in Bolivares (Bs) per USD. This rate is validated against the current market rate stored in the system.The provided rate must be within 0.35 Bs tolerance of the current rate, otherwise the request will be rejected with a 400 error.
A unique payment reference number for this transaction. This field is checked for duplicates to prevent processing the same payment twice.If a transaction with this reference already exists, the request will fail with a 409 Conflict error.
The payment method used for this transaction (e.g., “Pago Móvil”, “Transferencia”, “Zelle”).
The account information for the recipient. Format depends on the payment method.
Example Request
Response
Success message confirming the transaction was created.
The created transaction object with all calculated fields.
Success Response Example
Error Responses
Returned when required fields are missing, rate validation fails, or commission exceeds the amount for sell transactions.
Returned when the authentication token is missing, invalid, or expired.
Returned when the provided
payment_reference has already been used in another transaction.Returned when an unexpected server error occurs.
Commission Calculation Details
The commission structure is tiered based on the transaction amount:| Amount Range | Commission |
|---|---|
| 9.99 | $0.80 (flat) |
| 14.99 | $1.00 (flat) |
| 25.00 | $1.40 (flat) |
| Above $25.00 | 0.08 × (amount - $25)) |
Examples:
- **0.80
- **1.00
- **1.40
- **1.40 + (1.80
- **1.40 + (3.40
Rate Validation
The system validates that the exchange rate provided by the client is current and hasn’t changed significantly:- The server maintains a current exchange rate (fetched from external services)
- When a transaction is created, the
rate_bsis compared to the server’s rate - If the absolute difference is greater than 0.35 Bs, the transaction is rejected
- This prevents transactions from being processed with stale or incorrect rates
Duplicate Prevention
To prevent accidental duplicate transactions, thepayment_reference field is checked against all existing transactions. If a match is found, the request returns a 409 Conflict error. This ensures that each payment reference can only be used once across the entire system.