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

# Simulate clearing or refund

> Simulate an authorization.clearing type transaction by including the originaltransactiontoken and amount in your request.

POST/simulate/clearing

Simulate an `authorization.clearing` type transaction by including the `original_transaction_token` and `amount` in your request. To simulate a `refund` type transaction, set the `is_refund` field to `true`.

## Body field details

| Fields | Description |
| - | - |
| original\_transaction\_token string  Required | The unique identifier of the transaction to clear. **Allowable Values:**  Existing transaction token. |
| amount decimal  Required | The amount of the transaction. **Allowable Values:**  Format: 0.00 |
| force\_post boolean  Optional | Set to `true` to simulate a forced clearing transaction. **NOTE:** If you set this field to `true`, you must also set the `original_transaction_token` field to an existing transaction token (the transaction does not need to be related). **Allowable Values:**  `true`, `false` **Default value:** `false` |
| is\_refund boolean  Optional | Set to `true` to simulate a refund transaction. **Allowable Values:**  `true`, `false` **Default value:** `false` |
| mid string  Optional | Merchant Identification number. **Allowable Values:**  50 char max |
| card\_acceptor object  Optional | Contains attributes that describe the merchant. **Allowable Values:** |
| network\_fees array of objects  Optional | Simulates various types of fees levied on the transaction. **Allowable Values:**  A valid array of `network_fees` objects. |
| webhook object  Optional | Allows information to be posted asynchronously to endpoints hosted in your environment. **Allowable Values:**  A valid `webhook` object. |

## The card\_acceptor object

| Fields | Description |
| - | - |
| mcc string  Optional | Merchant category code. **Allowable Values:**  5 char max |
| partial\_approval\_capable boolean  Optional | Whether the response can approve an amount less than or equal to the requested amount. **Allowable Values:**  `true`, `false` **Default value:** `false` |
| name string  Optional | Merchant name. **Allowable Values:**  255 char max |
| address string  Optional | Merchant address. **Allowable Values:**  255 char max |
| city string  Optional | Merchant city. **Allowable Values:**  255 char max |
| state string  Optional | Merchant state. **Allowable Values:**  2 char max |
| zip string  Optional | Merchant ZIP or postal code. **Allowable Values:**  10 char max |
| country string  Optional | Merchant country. **Allowable Values:**  40 char max |
| ecommerce\_security\_level\_indicator string  Optional | Contains the fields representing the security protocol and cardholder authentication type associated with the transaction. **Allowable Values:**  0-9 |

## The network\_fees object

| Fields | Description |
| - | - |
| type string  Required | Specifies the type of fee. - **ISSUER\_FEE** – Fee charged by the issuing bank. Does not impact account balance. - **SWITCH\_FEE** – Fee charged per transaction by the card network. Does not impact account balance. - **PINDEBIT\_ASSOC\_FEE** – Fee associated with a PIN-debit transaction, such as at an ATM. Impacts account balance. - **ACQUIRER\_FEE** – Fee charged by the acquiring bank. Impacts account balance. - **INTERCHANGE\_FEE** – Fee charged per transaction by the card network. Does not impact account balance. - **CUR\_CONV\_CARDHOLDER\_FEE** – Currency conversion fee charged to the cardholder by the card network. Impacts account balance. - **CUR\_CONV\_ISSUER\_FEE** – Currency conversion fee paid for by the issuer. Does not impact account balance. - **CROSS\_BORDER\_ISSUER\_FEE** – Cross-border fee charged by the network, and paid for by the issuer. Does not impact account balance. **Allowable Values:**  `ISSUER_FEE`, `SWITCH_FEE`, `PINDEBIT_ASSOC_FEE`, `ACQUIRER_FEE`, `INTERCHANGE_FEE`, `CUR_CONV_CARDHOLDER_FEE`, `CUR_CONV_ISSUER_FEE`, `CROSS_BORDER_ISSUER_FEE` |
| amount decimal  Optional | Specifies the amount of the fee. **Allowable Values:**  Format: 0.00 |
| credit\_debit string  Optional | Specifies whether the fee credits or debits the account balance. **Allowable Values:**  C, D  The default value depends on the setting of the `type` field, as listed below:  Fee Type / Default  `ISSUER_FEE` / C  `SWITCH_FEE` / D  `PINDEBIT_ASSOC_FEE` / D  `ACQUIRER_FEE` / D  `INTERCHANGE_FEE` / C  `CUR_CONV_CARDHOLDER_FEE` / D  `CUR_CONV_ISSUER_FEE` / C  `CROSS_BORDER_ISSUER_FEE` / C |

## The webhook object

| Fields | Description |
| - | - |
| endpoint string  Optional | Endpoint to which a copy of the response is sent. **Allowable Values:**  - HTTPS URL  - 250 char max  - Empty string not allowed |
| username string  Optional | Username for accessing the endpoint. **Allowable Values:**  50 char max |
| password string  Optional | Password for accessing the endpoint. **Allowable Values:**  No restrictions |

## Sample request body

Send the following request to simulate an `authorization.clearing` type transaction.

```json JSON lines wrap theme={null}
{
  "amount": "2.00",
  "original_transaction_token": "78e61ee3-f811-49b0-ab58-1f485d353b3z"
}
```

Send the following request to simulate a `refund` type transaction.

```json JSON lines wrap theme={null}
{
  "amount": "2.00",
  "original_transaction_token": "ebc1aa7d-0d9d-4205-b963-64693364e52d",
  "is_refund": true
}
```

## Sample response body

The following response shows an `authorization.clearing` type transaction.

```json JSON expandable lines wrap theme={null}
{
  "type": "authorization.clearing",
  "state": "COMPLETION",
  "token": "2b7e3730-92e8-49dc-91c3-10a9186b79d1",
  "user_token": "b2d2c739-a9fe-4af0-9f34-964aae4c3e31",
  "acting_user_token": "b2d2c739-a9fe-4af0-9f34-964aae4c3e31",
  "card_token": "4abf0fe1-2470-4cc8-b83e-c7db9a59bcdb",
  "preceding_related_transaction_token": "78e61ee3-f811-49b0-ab58-1f485d353b3z",
  "gpa": {
    "currency_code": "USD",
    "ledger_balance": 10,
    "available_balance": 0,
    "credit_balance": 0,
    "pending_credits": 0,
    "impacted_amount": -2,
    "balances": {
      "USD": {
        "currency_code": "USD",
        "ledger_balance": 10,
        "available_balance": 0,
        "credit_balance": 0,
        "pending_credits": 0,
        "impacted_amount": -2
      }
    }
  },
  "gpa_order": {
   "token": "3f55f689-7622-4660-9ce9-209a9e6b1a5a",
    "amount": 2,
    "created_time": "2024-07-11T16:30:00Z",
    "last_modified_time": "2024-07-11T16:35:56Z",
    "transaction_token": "1037",
    "state": "COMPLETION",
    "response": {
      "code": "0000",
      "memo": "Approved or completed successfully"
    },
    "funding": {
      "amount": 2,
      "source": {
        "type": "program",
        "token": "**********b4c2",
        "active": true,
        "name": "PFS for simulating transactions",
        "is_default_account": false,
        "created_time": "2024-07-10T00:09:35Z",
        "last_modified_time": "2024-07-10T00:09:35Z"
      }
    },
    "funding_source_token": "**********b4c2",
    "user_token": "b2d2c739-a9fe-4af0-9f34-964aae4c3e31",
    "currency_code": "USD"
  },
  "duration": 196,
  "created_time": "2024-07-11T16:35:56Z",
  "user_transaction_time": "2024-07-11T16:30:00Z",
  "settlement_date": "2024-07-11T00:00:00Z",
  "request_amount": 2,
  "amount": 2,
  "issuer_interchange_amount": 0,
  "currency_code": "USD",
  "approval_code": "015382",
  "response": {
    "code": "0000",
    "memo": "Approved or completed successfully"
  },
  "network": "VISA",
  "subnetwork": "VISANET",
  "acquirer_fee_amount": 0,
  "acquirer": {
    "institution_id_code": "000000",
    "system_trace_audit_number": "000002"
  },
  "user": {
    "metadata": {}
  },
  "card": {
    "metadata": {}
  },
  "card_acceptor": {
    "mid": "11111",
    "mcc": "6411",
    "name": "Aegis Fleet Services",
    "street_address": "111 Main St",
    "city": "Berkeley",
    "state": "CA",
    "zip": "94702",
    "country_code": "USA"
  },
    "pos": {
    "partial_approval_capable": false,
    "purchase_amount_only": false,
    "is_recurring": false
  }
}
```

The following response shows a `refund` type transaction.

```json JSON expandable lines wrap theme={null}
{
  "type": "refund",
  "state": "COMPLETION",
  "token": "8318385b-e1f5-4139-a289-0036d1e4fd3b",
  "user_token": "25380999-767d-4251-9270-9d1343217694",
  "acting_user_token": "25380999-767d-4251-9270-9d1343217694",
  "card_token": "98bf1581-7cfb-4184-992f-586d6a1d0eec",
  "gpa": {
    "currency_code": "USD",
    "ledger_balance": 20,
    "available_balance": 0,
    "credit_balance": 0,
    "pending_credits": 0,
    "impacted_amount": 2,
    "balances": {
      "USD": {
        "currency_code": "USD",
        "ledger_balance": 20,
        "available_balance": 0,
        "credit_balance": 0,
        "pending_credits": 0,
        "impacted_amount": 2
      }
    }
  },
  "duration": 150,
  "created_time": "2024-02-12T22:32:25Z",
  "user_transaction_time": "2024-02-12T22:32:25Z",
  "settlement_date": "2024-02-12T00:00:00Z",
  "request_amount": 2,
  "amount": 2,
  "currency_code": "USD",
  "approval_code": "536048",
  "response": {
    "code": "0000",
    "memo": "Approved or completed successfully"
  },
  "gpa_order_unload": {
    "token": "2c6af635-0c71-43bb-a1c8-94d0143e3d6c",
    "amount": 2,
    "created_time": "2024-02-12T22:32:25Z",
    "last_modified_time": "2024-02-12T22:32:26Z",
    "transaction_token": "11ad414a-2678-4d91-aef1-a10d3b08da64",
    "state": "COMPLETION",
    "response": {
      "code": "0000",
      "memo": "Approved or completed successfully"
    },
    "funding": {
      "amount": 2,
      "source": {
        "type": "program",
        "token": "**********6b51",
        "active": true,
        "name": "PFS for simulating transactions",
        "is_default_account": false,
        "created_time": "2024-01-28T19:20:33Z",
        "last_modified_time": "2024-01-28T19:20:33Z"
      }
    },
    "funding_source_token": "**********6b51"
  },
  "network": "VISA",
  "subnetwork": "VISANET",
  "acquirer_fee_amount": 0,
  "acquirer": {
    "institution_id_code": "000000",
    "system_trace_audit_number": "000005"
  },
  "user": {
    "metadata": {}
  },
  "card": {
    "metadata": {}
  },
  "card_acceptor": {
    "mid": "11111",
    "mcc": "6411",
    "name": "Marqeta Storefront",
    "street_address": "330 Central Ave.",
    "city": "St. Petersburg",
    "state": "FL",
    "zip": "33705",
    "country_code": "USA"
  },
  "pos": {
    "partial_approval_capable": false,
    "purchase_amount_only": false,
    "is_recurring": false
  }
}
```


## Related topics

- [Simulating Transactions Overview](https://www.marqeta.com/docs/core-api/simulating-transactions.md)
- [Event Types](https://www.marqeta.com/docs/core-api/event-types.md)
- [Simulate refund authorization clearing](https://www.marqeta.com/docs/core-api/simulations-card-transactions/refunds/simulate-refund-authorization-clearing.md)
- [Simulate refund](https://www.marqeta.com/docs/core-api/simulations-card-transactions/refunds/simulate-refund.md)
- [Simulate refund authorization](https://www.marqeta.com/docs/core-api/simulations-card-transactions/refunds/simulate-refund-authorization.md)
