Skip to main content

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:
The returned out_document_id already represents the finalized financial document.
The identifier should be persisted and used for:
  • Transaction status queries;
  • Financial reconciliation;
  • Receipt validation;
  • Operational support investigations;
  • Audit trails.

Cash Out Lifecycle

or
Both 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.
Possible causes include:
  • 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:
The transaction may still have been processed successfully. Before retrying:
  1. Query using the same external_id;
  2. Validate webhook notifications;
  3. Validate reconciliation status;
  4. Contact Trio support if necessary.
Creating another request without validation may generate duplicate payouts.

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.
The API returns only the QR Code identifier (ref_id).

Important

The returned data.id should be interpreted as:
and not as the final financial transaction identifier. The final document_id is generated only after successful settlement.

Settlement Flow

Once the payment is completed successfully, Trio sends a settled webhook containing:
  • external_id;
  • ref_id;
  • Final transaction id.
This structure allows the association between:

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:
It does not mean:
  • The QR Code expired;
  • The QR Code was canceled;
  • The operation is permanently closed.
The QR Code remains active and may still receive future payment attempts.

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_id is generated;
  • The QR Code is automatically closed;
  • No further events will occur.
After settlement, additional failed events are not possible.

Response Time Expectations


Retry Recommendation

If no response is received within 500ms during QR Code generation:
  • A new request may be created;
  • A new external_id must 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:
During this period:
  • The same external_id cannot 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.
Avoid:
  • 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 OK immediately;
  • Persist webhook payloads;
  • Maintain audit history;
  • Avoid long-running synchronous processing.
Webhooks should always be treated as the source of truth for final transaction status updates.

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;
  • failed and settled are terminal states;
  • Timeout retries must be handled carefully to avoid duplicate payouts.
For Cash In:
  • The initial request creates only the QR Code reference (ref_id);
  • The final financial transaction exists only after settlement;
  • failed does not necessarily represent a permanent failure;
  • Multiple payment attempts may occur before settlement;
  • The final document_id is received only through webhook notification.
For both operation types:
  • external_id should 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.