Airwallex logo

GL accounts via API

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

Copy for LLMView as Markdown

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 account API 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: this is the identifier you use as field_value_id when coding transactions via the Spend API.

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

    Shell
    1curl -X POST \
    2 'https://api-demo.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 accounts API endpoint.

  1. Send the request with optional filters:

    Shell
    1curl -G \
    2 'https://api-demo.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 account API endpoint.

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

    Shell
    1curl -G \
    2 'https://api-demo.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 account API endpoint.

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

    Shell
    1curl -X POST \
    2 'https://api-demo.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, purchase orders, expenses, or other Spend resources, reference a GL account in accounting_field_selections using:

  • field_id: Chart of accounts
  • field_value_id: The GL account external_id (for example, 601022001)
  • identifier_type: EXTERNAL_ID
JSON
1{
2 "accounting_field_selections": [
3 {
4 "field_id": "Chart of accounts",
5 "field_value_id": "601022001",
6 "identifier_type": "EXTERNAL_ID"
7 }
8 ]
9}

Next steps

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

Was this page helpful?