> For the complete documentation index, see [llms.txt](https://docs.xyb.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xyb.co/xyb-platform-1/xyb-payments/payment-workflows-and-automations/outgoing-fx-payment-workflow.md).

# Outgoing FX Payment Workflow

Build a payment workflow that safely and dynamically handles an outgoing FX transaction. This includes risk checks, balance validation, routing to the right provider, and updating the final status.

**Who is this for?**

Product teams and operations leads who need control over how different payment types (e.g. FX, SEPA, SWIFT) behave at runtime.

**Workflow Summary**

* Trigger: Service-initiated payment (contextual, not event-driven)
* Actions:
  1. Validate payment data
  2. Perform ledger check
  3. Run risk checks
  4. Select provider
  5. Send payment
  6. Update status
  7. Log result

**Step-by-Step Guide**

1. **Create a New Workflow**
   * Go to the Workflows section in the Console
   * Click "Create Workflow"
   * Name: `fx-payment-execution`
   * Choose family: `payments`
   * Choose or create plan: `fx-transfer`
2. **Add Initial Validation Node**
   * Node type: Conditional or Validation
   * Confirm required fields like `amount`, `currency`, `recipient`
3. **Add Ledger Balance Check**
   * Node type: HTTP call or internal service call to `ledger`
   * Action: Verify account has sufficient funds
   * If insufficient: Route to terminal state `REJECTED`
4. **Add Risk Evaluation Step**
   * Node type: Internal service or HTTP call to `risk engine`
   * Provide context (amount, customer, destination country)
   * Handle flags or required holds as needed
5. **Select Payment Provider**
   * Node type: Selection context
   * Criteria: Based on currency, amount, region
   * Output: Set `provider_id`
6. **Initiate the Payment**
   * Node type: HTTP call to `payment-router`
   * Include all required metadata from earlier steps
7. **Update Final Payment Status**
   * Node type: Status update
   * Values: `SETTLED`, `SENT`, or fallback to `FAILED`
8. **Add Logging Nodes**
   * Use `log.atInfo()` after each key transition
   * Capture values like `payment_id`, `provider_id`, or final state
9. **Define Initial and Terminal States**
   * Initial: `PENDING`
   * Terminal: `SETTLED`, `REJECTED`, `FAILED`
10. **Activate the Workflow**

* Save your workflow
* Validate paths
* Set state to `ACTIVE`

**Tips**

* Use parameters for dynamic thresholds and provider rules
* Create variants (v2, v3) for SEPA, instant, or crypto rails
* Include a retry or error-handling node outside payment call

**Troubleshooting**

* Use execution logs to trace status updates
* Check message content to ensure required fields are passed

**Outcome**\
The workflow will fully control how an FX payment is validated, routed, executed, and finalized, with full traceability and custom behavior per use case.

***

Next tutorial: Auto-Create Account When Entity is Created


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xyb.co/xyb-platform-1/xyb-payments/payment-workflows-and-automations/outgoing-fx-payment-workflow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
