Airwallex logo

GL accounts via APIBeta

Create, list, retrieve, and update chart of accounts entries programmatically using the GL accounts API.

Copy for LLMView as Markdown
GL accounts via API is in beta
We may include major new functionality or changes before general release. Learn more about beta.

The GL accounts API lets you manage your chart of accounts in Airwallex Spend. Sync GL accounts from your ERP or accounting system so employees and automated workflows can code expenses, bills, and other Spend items with the correct general ledger accounts.

Before you begin

Sync GL accounts from your ERP

A typical sync workflow looks like this:

  1. List existing GL accounts in Airwallex, filtering by external_id or status where needed.
  2. Create GL accounts that exist in your ERP but not yet in Airwallex. Match on external_id before creating. A duplicate external_id or account name causes the create request to fail.
  3. Update GL accounts whose names, codes, or other attributes have changed in your ERP.
  4. Set status to ARCHIVED on update for GL accounts that are no longer active in your ERP.

Use external_id to reference a value from your ERP on create and update so you can match records across systems.

Create a GL account

To create a chart of accounts entry, call the Create GL accountAPI endpoint. Each GL account must have a unique account name (value) within your organization. When you provide an external_id, it must also be unique so you can match the record to your ERP. Use the GL account id as source_id when coding Spend line items.

  1. Send the create request with your ERP identifier as external_id:

    Shell
    1curl -X POST \
    2 'https://api.sandbox.airwallex.com/api/v1/accounting/gl_accounts/create' \
    3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
    4 -H 'Content-Type: application/json' \
    5 -d '{
    6 "request_id": "985461d5-016f-4e1f-a387-5f1380b42d92",
    7 "code": "601022001",
    8 "value": "Travel Costs - Domestic Transportation",
    9 "value_label": "Travel - Domestic Flight | 601022001",
    10 "external_id": "601022001"
    11 }'

    The code field is optional and accepts GL codes up to 64 characters. Omit legal_entity_ids when the GL account applies to all legal entities in your organization.

  2. The response returns the created GL account with its unique Airwallex id:

    JSON
    1{
    2 "id": "ba46f0ff-8081-4db6-8333-4e011fe9561d",
    3 "code": "601022001",
    4 "value": "Travel Costs - Domestic Transportation",
    5 "value_label": "Travel - Domestic Flight | 601022001",
    6 "external_id": "601022001",
    7 "status": "ACTIVE",
    8 "created_at": "2026-06-15T00:00:00Z",
    9 "updated_at": "2026-06-15T00:00:00Z"
    10}

List GL accounts

To retrieve GL accounts, call the List GL accountsAPI endpoint.

  1. Send the request with optional filters:

    Shell
    1curl -G \
    2 'https://api.sandbox.airwallex.com/api/v1/accounting/gl_accounts' \
    3 --data-urlencode 'status=ACTIVE' \
    4 --data-urlencode 'external_id=601022001' \
    5 -H 'Authorization: Bearer {{ACCESS_TOKEN}}'
  2. The response returns a paginated list of GL accounts:

    JSON
    1{
    2 "items": [
    3 {
    4 "id": "ba46f0ff-8081-4db6-8333-4e011fe9561d",
    5 "code": "601022001",
    6 "value": "Travel Costs - Domestic Transportation",
    7 "value_label": "Travel - Domestic Flight | 601022001",
    8 "external_id": "601022001",
    9 "status": "ACTIVE",
    10 "created_at": "2026-06-15T00:00:00Z",
    11 "updated_at": "2026-06-15T00:00:00Z"
    12 }
    13 ],
    14 "page_after": "string",
    15 "page_before": "string"
    16}

Key query parameters include:

ParameterDescription
statusFilter by ACTIVE or ARCHIVED.
external_idFilter by the external ID from your ERP.
legal_entity_idFilter by a specific legal entity ID.
pageA bookmark for pagination. Use the value from page_after or page_before in the previous response.

Get GL account details

To retrieve a specific GL account, call the Get GL accountAPI endpoint.

  1. Use the id from the list or create response:

    Shell
    1curl -G \
    2 'https://api.sandbox.airwallex.com/api/v1/accounting/gl_accounts/{{GL_ACCOUNT_ID}}' \
    3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}'

Update a GL account

To update an existing GL account, call the Update GL accountAPI endpoint.

  1. Send the update request with the fields you want to change:

    Shell
    1curl -X POST \
    2 'https://api.sandbox.airwallex.com/api/v1/accounting/gl_accounts/{{GL_ACCOUNT_ID}}/update' \
    3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
    4 -H 'Content-Type: application/json' \
    5 -d '{
    6 "code": "601022001",
    7 "value": "Travel Costs - Domestic Transportation",
    8 "value_label": "Travel - Domestic Flight | 601022001",
    9 "external_id": "601022001",
    10 "legal_entity_ids": [
    11 "le_U3jlHqQRNHWn2zAKeeT8sx"
    12 ],
    13 "status": "ARCHIVED"
    14 }'
  2. The response returns the updated GL account.

Use GL accounts in Spend APIs

When coding line items on bills or purchase orders, reference a GL account in accounting_field_selections using:

  • type: GENERAL_LEDGER_ACCOUNT
  • source_id: The GL account id (for example, ba46f0ff-8081-4db6-8333-4e011fe9561d).
JSON
1{
2 "accounting_field_selections": [
3 {
4 "type": "GENERAL_LEDGER_ACCOUNT",
5 "source_id": "ba46f0ff-8081-4db6-8333-4e011fe9561d"
6 }
7 ]
8}

For the write contract on earlier API versions, see Accounting field selections.

Next steps

Now that you can manage GL accounts via the API, explore these related guides:

Was this page helpful?