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

# Overview

FedNow simulations allow developers to simulate specific events with FedNow payments. It is possible to simulate both
the sending and receiving of funds via this channel. The `failed` and `succeed` simulations represent outcomes for a
FedNow Send payment, where funds attempt to move from your ledger to a third party. The `received` simulation represents
an outcome for a FedNow Receive payment, where funds from a third party are being received on your ledger.

## FedNow Simulation Types

| Simulation Type   | Explanation                                                                                                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fednow.failed`   | Simulate the failure of a FedNow payment. This failure is not simulating a specific reason, just that the payment did not succeed. Payment must be in a `pending` status. |
| `fednow.succeed`  | Simulate the success of an originated FedNow payment. The payment must be in a `pending` status. Will move funds on the account and affect account balances.              |
| `fednow.received` | Simulate an incoming FedNow payment, will affect the destination account's balances as well as create a FedNow object representing the incoming payment.                  |

## Simulate a successful or failed FedNow payment

Initiate a `fednow.failed` or `fednow.succeed` simulation event.

<CodeGroup>
  ```bash bash theme={null}
  POST https://api.sandbox.treasuryprime.com/simulation
  ```
</CodeGroup>

### FedNow successful or failed simulation request body

| Parameter    | Type   | Required? | Description                         |
| ------------ | ------ | --------- | ----------------------------------- |
| `type`       | string | Required  | `fednow.failed` or `fednow.succeed` |
| `simulation` | object | Required  | The simulation request sub-object.  |

##### Simulation Sub-Object

| Parameter   | Type   | Required? | Description                                                                               |
| ----------- | ------ | --------- | ----------------------------------------------------------------------------------------- |
| `fednow_id` | string | Required  | ID of the FedNow object the developer has already created, must be in a `pending` status. |

##### Response

No response body is returned. A `202` HTTP status indicates a successful simulation.

#### Verifying a Successful Simulation

To ensure that the simulation was run successfully, call the `GET /fednow/:id` endpoint to confirm that the status of
the status of the payment has been updated accordingly. If you simulated a successful payment then you should also see
transactions on the associated account as well as balance changes.

## Simulate an incoming FedNow payment

Initiate a `fednow.received` simulation event.

<CodeGroup>
  ```bash bash theme={null}
  POST https://api.sandbox.treasuryprime.com/simulation
  ```
</CodeGroup>

### FedNow Received simulation request body

| Parameter    | Type   | Required? | Description                        |
| ------------ | ------ | --------- | ---------------------------------- |
| `type`       | string | Required  | `fednow.received`                  |
| `simulation` | object | Required  | The simulation request sub-object. |

##### Simulation Sub-Object

| Parameter      | Type   | Required? | Description                                                                                                                     |
| -------------- | ------ | --------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `amount`       | string | Required  | Amount of the FedNow payment to receive, must be a positive amount. `payment_type` will determine the direction of the payment. |
| `account_id`   | string | Required  | Destination account ID for the payment to affect.                                                                               |
| `payment_type` | string | Required  | Must be either `credit` or `debit`. Will determine whether funds are deposited or withdrawn from the destination account.       |

##### Response

No response body is returned. A `202` HTTP status indicates a successful simulation.

#### Verifying a Successful Simulation

To ensure that the simulation was run successfully, call the `GET /fednow` endpoint to retrieve FedNow payments. There
will be a new FedNow payment record there for the amount/account/direction specified in the simulation. The destination
account specified will also have new transactions as well as it's balance updated accordingly.
