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

# Airwallex integration

> Connect Airwallex with an API key so End Close reads your settled financial transactions every hour and reconciles them net of fees.

Connecting Airwallex lets End Close read your account's financial transactions every hour and write each settled one as a record in an `airwallex` [data stream](https://endclose.com/docs/concepts/data-streams.md). Each record carries the net amount the transaction moved your balance, with the gross amount and fee kept alongside.

## At a glance

| | |
| - | - |
| **Connects as** | Airwallex API key (client ID and API key), plus a webhook you create in Airwallex |
| **Data synced** | Settled financial transactions: payments, refunds, disputes and fees |
| **Sync frequency** | Every hour |
| **History** | The last 30 days on the first read |
| **Who can set it up** | Admins |
| **Per environment** | Yes. One Airwallex account per End Close environment. |

## Prerequisites

* An End Close admin.
* Access to the Airwallex web app with permission to create API keys and webhooks.

## Connect Airwallex

**1. Create an API key in Airwallex**

In Airwallex, go to **Developer → API keys** and create a key. Copy the client ID and the API key.

**2. Enter the credentials in End Close**

Go to **Settings → Integrations**, choose **Airwallex**, then **Connect**. Fill in the dialog and choose **Connect**.

| Field | What to enter |
| - | - |
| **Environment** | **Production (api.airwallex.com)** or **Demo (api-demo.airwallex.com)** |
| **Client ID** | The client ID from Airwallex |
| **API key** | The API key from Airwallex |
| **Webhook secret** | Leave empty for now. You add it in the last step. |

End Close checks the key with Airwallex before saving it. If Airwallex refuses it, the dialog says why and nothing is saved.

**3. Create the webhook in Airwallex**

The Airwallex card now shows a webhook URL. Copy it. In Airwallex, go to **Developer → Webhooks → Add webhook**, paste the URL, and subscribe to these events:

* `payment_intent.succeeded`
* `refund.settled`
* `payment_dispute.requires_response`
* `payment_dispute.won`
* `payment_dispute.reversed`
* `payment_dispute.lost`
* `payment_dispute.accepted`

**4. Add the webhook secret**

Copy the webhook's signing secret from Airwallex. In End Close, choose **Update credentials**, paste it into **Webhook secret**, and choose **Update**. Leave **API key** blank to keep the one you saved.

The card shows **Add webhook secret** until the secret is saved, because End Close rejects every webhook delivery it can't verify. It then shows **Waiting for first event**, and **Connected** once a delivery arrives. The card also shows when the last event was received, so a webhook deleted in Airwallex shows up as a feed that has gone quiet.

## What End Close reads

Every hour, End Close reads the account's financial transactions: the lines Airwallex adds to your balance for each payment, refund, dispute and fee. The first read covers the last 30 days. The first time it reads the account, End Close creates a stream with the key `airwallex`, named **Airwallex payments**.

Only settled transactions are written. A transaction is pending from capture until its settlement batch, which can take hours or days, and End Close reads it again each hour until it settles. A transaction already in the stream isn't written twice.

| Record field | From Airwallex |
| - | - |
| `external_id` | The financial transaction ID |
| `date` | The transaction's date (UTC) |
| `amount` | The net amount after fees, in cents |
| `direction` | `credit` when the net amount adds to your balance, `debit` when it reduces it |
| `currency` | The transaction's currency |
| `description` | The Airwallex description, or the transaction type and source ID |
| `metadata` | `transaction_type`, `source_type`, `source_id`, `batch_id`, `funding_source_id`, `gross_amount`, `fee_amount`, `created_at`, `settled_at` and `airwallex_account_id` |

Webhook deliveries don't create records. End Close keeps them as events and uses them to show whether the webhook is alive. The money comes from the hourly read, because only the financial transactions show what each payment moved net of fees.

## Disconnect Airwallex

In **Settings → Integrations → Airwallex**, choose **Disconnect**. End Close removes the credentials and the webhook URL. Records and events already received stay. Delete the webhook in Airwallex as well, or Airwallex keeps retrying deliveries that now fail.

## FAQ

> [accordion] Why is a payment from this morning missing?
>
> End Close only writes a transaction once Airwallex settles it with its batch. Pending transactions are read again every hour until they settle.

> [accordion] Why does the record amount differ from the payment amount?
>
> The record holds the net amount the transaction moved your balance, after fees. The gross amount and the fee are in the record's `metadata` as `gross_amount` and `fee_amount`.

> [accordion] Can I connect the Airwallex demo environment?
>
> Yes. Choose **Demo (api-demo.airwallex.com)** under **Environment** when you connect.

## Related

> [card] [Records](https://endclose.com/docs/concepts/records.md)
>
> The fields every record carries.

> [card] [How connections work](https://endclose.com/docs/integrations/how-connections-work.md)
>
> Streams, environments and who can connect.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.