Understanding Cash In and Cash Out IDs
During the integration process with the Trio API, it is important to understand how identifiers behave differently between Cash In and Cash Out operations. These identifiers are essential for:- Financial reconciliation;
- Transaction tracking;
- Idempotency validation;
- Duplicate prevention;
- Transaction lookup;
- Operational investigations.
Identifier Overview
Cash Out
How Cash Out Identifiers Work
For Cash Out operations, the financial transaction is created immediately during the request. Because of this, the API instantly returns the final transaction identifier:out_document_id already represents the finalized financial document.
Recommended Usage
The identifier should be persisted and used for:- Transaction status queries;
- Financial reconciliation;
- Receipt validation;
- Operational support investigations;
- Audit trails.
Cash Out Lifecycle
settled and failed are final states.
Once either status is reached:
- No further events will occur;
- The transaction lifecycle is permanently closed.
Understanding failed
If a Cash Out reaches failed:
- The withdrawal was not completed;
- The transaction is finalized immediately;
- No additional updates will occur.
- Invalid Pix key;
- Banking rejection;
- Insufficient balance;
- Banking processing failures.
Understanding settled
When a Cash Out reaches settled:
- The transfer was completed successfully;
- Funds were delivered;
- The transaction becomes immutable.
Response Time Expectations
Timeout Handling
If a Cash Out request times out:- Query using the same
external_id; - Validate webhook notifications;
- Validate reconciliation status;
- Contact Trio support if necessary.
Cash In
How Cash In Identifiers Work
For Cash In operations, the initial request creates only the QR Code request. At this stage:- The payment has not yet happened;
- No financial settlement exists yet;
- No final transaction document exists.
ref_id).
Important
The returneddata.id should be interpreted as:
document_id is generated only after successful settlement.
Settlement Flow
Once the payment is completed successfully, Trio sends asettled webhook containing:
external_id;ref_id;- Final transaction
id.
Cash In settled Webhook Example
Cash In Lifecycle
Possible lifecycle sequences:Important Lifecycle Behavior
For Cash In operations,failed is not necessarily a final status.
A failed event only means:
- The QR Code expired;
- The QR Code was canceled;
- The operation is permanently closed.
Common failed Scenarios
Examples include:
- Third-party payment attempts;
- Rejected payer validations;
- Business rule validation failures.
Understanding settled
Once a Cash In reaches settled:
- The payment is finalized;
- The final
document_idis generated; - The QR Code is automatically closed;
- No further events will occur.
failed events are not possible.
Response Time Expectations
Retry Recommendation
If no response is received within500ms during QR Code generation:
- A new request may be created;
- A new
external_idmust be used.
external_id and Idempotency
The external_id field is the primary reconciliation identifier between your platform and Trio.
This field must be unique for every operation.
Idempotency Window
Cash In and Cash Out operations enforce an idempotency window of:- The same
external_idcannot be reused; - Duplicate requests may return the previous transaction;
- This prevents accidental duplicate operations.
Best Practices
Recommended:- Use UUIDs;
- Persist all identifiers in your database;
- Associate identifiers with internal orders/payments;
- Query transactions before retrying requests.
- Reusing identifiers;
- Sequential IDs;
- Blind automatic retries;
- Creating new operations without previous validation.
Webhook Processing Recommendations
For production environments:- Process webhooks asynchronously;
- Return
HTTP 200 OKimmediately; - Persist webhook payloads;
- Maintain audit history;
- Avoid long-running synchronous processing.
Final Summary
Cash In and Cash Out operations behave differently and should be handled differently during integration. For Cash Out:- The final transaction identifier is returned immediately;
failedandsettledare terminal states;- Timeout retries must be handled carefully to avoid duplicate payouts.
- The initial request creates only the QR Code reference (
ref_id); - The final financial transaction exists only after settlement;
faileddoes not necessarily represent a permanent failure;- Multiple payment attempts may occur before settlement;
- The final
document_idis received only through webhook notification.
external_idshould always be unique;- All identifiers should be persisted for reconciliation;
- Webhooks should be considered the authoritative source of transaction state;
- Proper timeout and retry handling is critical to prevent duplicate operations and reconciliation inconsistencies.

