I Query data#

You can flexibly query your data to generate financial reports, embed FRAGMENT in your product and build internal dashboards.

a. Basics

#
GraphQL#

FRAGMENT is a GraphQL API, so data in the system is modeled as a graph. Entities in the API are nodes, and their relationships with other entities are edges. Ledgers have Ledger Accounts; Ledger Accounts and Ledger Entries have Ledger Lines; and so on.

FRAGMENT exposes several queries as entry points to the data graph. They return data about a single entity, or a list of entities.

When making a query, you can fetch related entities using expansions. As opposed to a REST interface, where you may require several round-trips to query nested data, expansions are nested queries that you let you retrieve related data in a single request. For example, you can expand from a Ledger Entry to all the Ledger Lines in it in one API call.

Connection types#

FRAGMENT uses connection types to return lists of entities. A connection type is a list of nodes, and a pageInfo object that contains cursors to the next and previous pages of results.

ListLedgerAccounts
query ListLedgerAccounts($ledger: LedgerMatchInput!) {
  ledger(ledger: $ledger) {
    ledgerAccounts {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
Filtering#

You can filter connection types with a filter argument.

For example, you can filter a list of Ledger Accounts by their type:

FilterLedgerAccounts query
query FilterLedgerAccounts(
    $ledger: LedgerMatchInput!,
    $filter: LedgerAccountsFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerAccounts {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
FilterLedgerAccounts variables - by type
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "type": {
      "equalTo": "asset"
    }
  }
}

You can combine filters by adding multiple components to the filter block. Results are AND'd:

FilterLedgerAccounts variables - by type
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "type": {
      "equalTo": "asset",
      "hasParentLedgerAccount": true
    }
  }
}
Pagination#

Fields that return lists support cursor-based pagination:

  • Results are returned under a nodes property as an array. The pageInfo property contains cursors pointing to the next page and previous pages.
  • You can send a cursor to the after (or before) arguments on list fields to retrieve a specific page.
  • The first (or last) argument sets the page size. The default is 20 and the maximum is 200.
  • Once a page size has been set in the initial request, all subsequent pagination requests have to use the same page size.
  • Results are returned in a deterministic order. This is generally reverse chronological, newest first. This sort is by posted date for Ledger Lines and Ledger Entries, or creation date for other entities.

This query uses pagination to retrieve two Ledger Accounts at a time:

GetLedgerAccounts query with pagination
query GetLedgerAccounts(
    $ledgerIk: SafeString!
    $after: String
    $first: Int
    $before: String
  ) {
    ledger(ledger: { ik: $ledgerIk }) {
      ledgerAccounts(
        after: $after
        first: $first
        before: $before
      ) {
        nodes {
          path
          name
          type
        }
        pageInfo {
          hasNextPage
          endCursor
          hasPreviousPage
          startCursor
        }
      }
    }
  }
GetLedgerAccounts variables
{
  "ledgerIk": "ik-used-to-create-ledger",
  "first": 2
}

The response is:

GetLedgerAccounts first page response
{
  "data": {
    "ledger": {
      "ledgerAccounts": {
        "nodes": [
          {
            "path": "assets/test-assets/test:1",
            "name": "Test 1",
            "type": "asset"
          },
          {
            "path": "assets/test-assets/test:2",
            "name": "Test 2",
            "type": "asset"
          }
        ],
        "pageInfo": {
          "hasNextPage": true,
          "endCursor": "<some-end-cursor>",
          "hasPreviousPage": false,
          "startCursor": null
        }
      }
    }
  }
}

To retrieve the next page, send the same query but with the after parameter set on ledgerAccounts:

GetLedgerAccounts next page variables
{
  "ledgerIk": "ik-used-to-create-ledger",
  "after": "<some-end-cursor>"
}

The response is:

GetLedgerAccounts second page response
{
  "data": {
    "ledger": {
      "ledgerAccounts": {
        "nodes": [
          {
            "path": "assets/test-assets/test:3",
            "name": "Test 3",
            "type": "asset"
          },
          {
            "path": "assets/test-assets/test:4",
            "name": "Test 4",
            "type": "asset"
          }
        ],
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": null,
          "hasPreviousPage": true,
          "startCursor": "<some-start-cursor>"
        }
      }
    }
  }
}

To retrieve the previous page of results, send the same query but with the before parameter set on ledgerAccounts. The response is the first page of results.

GetLedgerAccounts previous page variables
{
  "ledgerIk": "ik-used-to-create-ledger",
  "before": "<some-start-cursor>"
}

b. Ledgers

#
Lookup#

Use the ledger query to retrieve a Ledger by the IK used to create it:

GetLedger
query GetLedger($ledger: LedgerMatchInput!) {
  ledger(ledger: $ledger) {
    name
    created
    balanceUTCOffset
    ledgerAccounts {
      nodes {
        name
        type
      }
    }
    schema {
      key
    }
  }
}
GetLedger variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  }
}
List#

Use the ledgers query to list all the Ledgers in your workspace:

ListLedgers
query ListLedgers {
  ledgers {
    nodes {
      name
      created
      balanceUTCOffset
      ledgerAccounts {
        nodes {
          name
          type
        }
      }
      schema {
        key
      }
    }
    pageInfo {
      hasNextPage
      endCursor
      hasPreviousPage
      startCursor
    }
  }
}

The response is a paginated list of Ledgers.

c. Ledger Accounts

#
Lookup#

Use the ledgerAccount query to retrieve a Ledger Account by its path in the Schema:

GetLedgerAccount
query GetLedgerAccount(
  $ledgerAccount: LedgerAccountMatchInput!
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    name
    balance
    type
    lines {
      nodes {
        amount
        posted
      }
    }
  }
}

The IK of the Ledger needs to be provided along with the Ledger Account's path:

GetLedgerAccount Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  }
}
Lookup multiple#

You can also retrieve multiple Ledger Accounts using the ledgerAccounts query and the in filter:

ListLedgerAccounts
query ListLedgerAccounts($ledger: LedgerMatchInput!) {
  ledger(ledger: $ledger) {
    ledgerAccounts {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
GetLedgerAccount Variables with In
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "ledgerAccount": {
      "in": [
        {
          "path": "assets/banks/user-cash"
        },
        {
          "path": "income-root/income-revenue-root"
        }
      ]
    }
  }
}
List#

Use the ledger.ledgerAccounts query to list all Ledger Accounts within a Ledger:

ListLedgerAccounts
query ListLedgerAccounts($ledger: LedgerMatchInput!) {
  ledger(ledger: $ledger) {
    ledgerAccounts {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
ListLedgerAccounts variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  }
}

The response is a paginated list of Ledger Accounts.

List balances#

Since a Ledger Account can have balances in multiple currencies, you can list its balance and balance changes across all currencies:

GetLedgerAccountBalances
query GetLedgerAccountBalances(
  $ledgerAccount: LedgerAccountMatchInput!
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    name
    balances {
      nodes {
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
    end_of_year_balances: balances(at: "1969") {
      nodes {
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
    last_year: balanceChanges(period: "1968") {
      nodes {
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
  }
}
GetLedgerAccountBalances Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  }
}

Read more about handling multi-currency balances in Handle currencies.

Filter by type#

Use the type parameter to filter Ledger Account lists:

FilterLedgerAccounts query
query FilterLedgerAccounts(
    $ledger: LedgerMatchInput!,
    $filter: LedgerAccountsFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerAccounts(filter: $filter) {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

Use type to filter Ledger Accounts by their type:

FilterLedgerAccounts variables - by type
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "type": {
      "equalTo": "asset"
    }
  }
}

You can also filter for multiple types in one query, using in. This can be useful to Generate reports:

FilterLedgerAccounts variables - type in
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "type": {
      "in": ["asset", "liability"]
    }
  }
}
Filter by path#

Use path and wildcard matching (*) in place of template variables to query all instances of Ledger Accounts with template: true.

FilterLedgerAccounts query
query FilterLedgerAccounts(
    $ledger: LedgerMatchInput!,
    $filter: LedgerAccountsFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerAccounts(filter: $filter) {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
FilterLedgerAccounts variables - by external account
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "path": {
      "matches": "liability-root/user:*/pending"
    }
  }
}

Read more about filtering Ledger Accounts in filtering.

Filter by parent#

Use hasParentLedgerAccount to filter Ledger Accounts by their parent status:

FilterLedgerAccounts query
query FilterLedgerAccounts(
    $ledger: LedgerMatchInput!,
    $filter: LedgerAccountsFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerAccounts(filter: $filter) {
      nodes {
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
FilterLedgerAccounts variables - by external account
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "hasParentLedgerAccount": false
  }
}

Read more about filtering Ledger Accounts in filtering.

d. Ledger Lines

#
Lookup#

Use the ledgerLine query to retrieve a Ledger Line by its ID:

GetLedgerLine
query GetLedgerLine(
  $ledgerLine: LedgerLineMatchInput!
) {
  ledgerLine(ledgerLine: $ledgerLine) {
    amount
    currency {
      code
      customCurrencyId
    }
    account {
      name
      type
    }
  }
}
FilterLedgerAccountLines Variables
{
  "ledgerLine": {
    "id": "<ledger line ID>"
  }
}
List#

Use the ledgerAccount.lines query to list the lines in a Ledger Account:

GetLedgerAccountLines
query GetLedgerAccountLines(
  $ledgerAccount: LedgerAccountMatchInput!
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    name
    lines {
      nodes {
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
  }
}
GetLedgerAccountLines Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  }
}
Filter by posted#

Use posted to filter Ledger Lines by their posted timestamp between any two points in time:

FilterLedgerAccountLines
query GetLedgerAccountLines(
  $ledgerAccount: LedgerAccountMatchInput!,
  $filter: LedgerLinesFilterSet!
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    name
    lines(filter: $filter) {
      nodes {
        id
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
  }
}
FilterLedgerAccountLines Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  },
  "filter": {
    "posted": {
      "after": "1969-07-01T00:00:00.000Z",
      "before": "1969-07-30T23:59:59.999Z"
    }
  }
}

The after and before filters are inclusive, so use timestamps for the first and last moments of the period you're querying for.

Filter by key#

Use key to filter Ledger Lines by their keys in your Schema:

FilterLedgerAccountLines
query GetLedgerAccountLines(
  $ledgerAccount: LedgerAccountMatchInput!,
  $filter: LedgerLinesFilterSet!
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    name
    lines(filter: $filter) {
      nodes {
        id
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
  }
}
FilterLedgerAccountLines Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  },
  "linesFilter": {
    "key": {
      "equalTo": "increase_user_balance"
    }
  }
}

e. Ledger Entries

#
Lookup#

Use the ledgerEntry query to retrieve a Ledger Entry by its IK. You provide the IK when posting entries via addLedgerEntry:

GetLedgerEntry
query GetLedgerEntry(
  $ledgerEntry: LedgerEntryMatchInput!
) {
  ledgerEntry(ledgerEntry: $ledgerEntry) {
    id
    ik
    ledger {
      id
      name
    }
    lines {
      nodes {
        amount
        currency {
          code
          customCurrencyId
        }
      }
    }
  }
}
GetLedgerEntry Variables - by IK
{
  "ledgerEntry": {
    "ik": "<ledger entry IK>"
  }
}

When you Reconcile transactions using reconcileTx, the IK is the Transaction's externalId. Query entry.ik in ReconcileTxResult to retrieve it:

Querying IK in reconcileTx
mutation ReconcileTx(
  $entry: LedgerEntryInput!
) {
  reconcileTx(entry: $entry) {
    ... on ReconcileTxResult {
      entry {
        ik
        type
        created
        posted
      }
      lines {
        amount
        account {
          path
        }
      }
    }
    ... on Error {
      code
      message
    }
  }
}

A Ledger Entry can also be retrieved using its ID:

GetLedgerEntry Variables - by ID
{
  "ledgerEntry": {
    "id": "<ledger entry ID>"
  }
}
Lookup multiple#

You can also retrieve multiple Ledger Entries using the ledgerEntries query and the in filter:

ListLedgerEntries
query ListLedgerEntries(
  $ledger: LedgerMatchInput!
  $filter: LedgerEntriesFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerEntries(filter: $filter) {
      nodes {
        ik
        type
        posted
        lines {
          nodes {
            amount
            account {
              path
            }
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
ListLedgerEntries Variables with In
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "ledgerEntry": {
      "in": [
        {
          "ik": "fund-user-1-account"
        },
        {
          "ik": "fund-user-2-account"
        }
      ]
    }
  }
}
List by group#

You can get a paginated list of Ledger Entries in a given group using the ledgerEntryGroup.ledgerEntries expansion:

GetGroupedLedgerEntries
query GetGroupedLedgerEntries(
  $ledger: LedgerMatchInput!,
  $entryGroup: EntryGroupMatchInput!,
) {
  ledger(ledger: $ledger) {
    ledgerEntryGroup(ledgerEntryGroup: $entryGroup) {
      ledgerEntries {
        nodes {
          ik
          description
          posted
        }
        pageInfo {
          endCursor
          hasNextPage
          hasPreviousPage
          startCursor
        }
      }
    }
  }
}
GetGroupedLedgerEntries Variables
{
  "ledgerEntryGroup": {
    "key": "withdrawal",
    "value": "12345"
  },
  "ledger": {
    "ik": "quickstart-ledger"
  }
}

The response is:

GetGroupedLedgerEntries Response
{
  "data": {
    "ledger": {
      "ledgerEntryGroup": {
        "ledgerEntries": {
          "nodes": [
            {
              "ik": "ledger-entry-2",
              "description":"User user-id withdrawal settled",
              "posted": "1969-06-21T02:56:05.000Z"
            },
            {
              "ik": "ledger-entry-1",
              "description": "User user-id initiated withdrawal for 50000.",
              "posted": "1969-06-16T13:32:00.000Z"
            }
          ],
          "pageInfo": {
            "hasNextPage": false,
            "endCursor": null,
            "hasPreviousPage": false,
            "startCursor": null
          }
        }
      }
    }
  }
}
Expand lines#

Use the ledgerEntry.lines expansion to list the Ledger Lines in a Ledger Entry:

GetLedgerEntryLines
query GetLedgerEntryLines(
  $ledgerEntry: LedgerEntryMatchInput!
) {
  ledgerEntry(ledgerEntry: $ledgerEntry) {
    id
    ik
    lines {
      nodes {
        account {
          path
        }
        amount
        currency {
          code
          customCurrencyId
        }
      }
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
    }
  }
}
GetLedgerEntryLines Variables
{
  "ledgerEntry": {
    "ik": "<ledger entry IK>"
  }
}
Filter by posted#

Similar to Ledger Lines, Ledger Entries can be filtered by their posted timestamp between any two points in time using posted:

FilterLedgerEntries
query FilterLedgerEntries(
  $ledger: LedgerMatchInput!,
  $entriesFilter: LedgerEntriesFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerEntries(filter: $entriesFilter) {
      nodes {
        ik
        type
        posted
        lines {
          nodes {
            amount
            account {
              path
            }
          }
        }
      }
    }
  }
}

Use after and before to filter Ledger Entries by their posted timestamp between any two points in time:

FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "posted": {
      "after": "01-01-1968",
      "before": "01-01-1969"
    }
  }
}

Use date to filter Ledger Entries by the date they were posted on:

FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "date": {
      "equalTo": "12-31-1968"
    }
  }
}
Filter by type#

Use type to filter Ledger Entries by their type defined in your Schema:

FilterLedgerEntries
query FilterLedgerEntries(
  $ledger: LedgerMatchInput!,
  $entriesFilter: LedgerEntriesFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerEntries(filter: $entriesFilter) {
      nodes {
        ik
        type
        posted
        lines {
          nodes {
            amount
            account {
              path
            }
          }
        }
      }
    }
  }
}
FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "type": {
      "in": ["withdrawal", "p2p_transfer"]
    }
  }
}

To retrieve Ledger Entries of multiple types, use the in operator:

FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "type": {
      "in": ["withdrawal", "p2p_transfer"]
    }
  }
}
Filter by tag#

Use tag to filter Ledger Entries by tags:

FilterLedgerEntries
query FilterLedgerEntries(
  $ledger: LedgerMatchInput!,
  $entriesFilter: LedgerEntriesFilterSet!
) {
  ledger(ledger: $ledger) {
    ledgerEntries(filter: $entriesFilter) {
      nodes {
        ik
        type
        posted
        tags {
          key
          value
        }
      }
    }
  }
}
FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "tag": {
      "equalTo": {
        "key": "user_id",
        "value": "user-1"
      }
    }
  }
}

Use the in operator to return Ledger Entries that have any of the specified tags:

FilterLedgerEntries Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "entriesFilter": {
    "tag": {
      "in": [{
        "key": "user_id",
        "value": "user-1"
      },{
        "key": "user_id",
        "value": "user-2"
      }]
    }
  }
}

f. Ledger Entry Groups

#

See Group Ledger Entries for more information about how to use Ledger Entry Groups.

Lookup#

Use the ledger.ledgerEntryGroup expansion to lookup a group by key and value.

GetLedgerEntryGroup
query GetLedgerEntryGroup(
  $ledger: LedgerMatchInput!
  $entryGroup: EntryGroupMatchInput!
) {
  ledger(ledger: $ledger) {
    ledgerEntryGroup(ledgerEntryGroup: $entryGroup) {
      key
      value
      created
    }
  }
}
GetLedgerEntryGroup Variables
{
  "entryGroup": {
    "key": "withdrawal",
    "value": "12345"
  },
  "ledger": {
    "ik": "quickstart-ledger"
  }
}

The response is:

GetLedgerEntryGroup Response
{
  "data": {
    "ledger": {
      "ledgerEntryGroup": {
        "key": "withdrawal",
        "value": "12345",
        "created": "1969-06-16T13:32:00.000Z"
      }
    }
  }
}
List#
ListLedgerEntryGroups
query ListLedgerEntryGroups(
  $ledger: LedgerMatchInput!
) {
  ledger(ledger: $ledger) {
    ledgerEntryGroups {
      nodes {
        key
        value
        created
      }
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
    }
  }
}
ListLedgerEntryGroups Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  }
}

The response is:

ListLedgerEntryGroups Response
{
  "data": {
    "ledger": {
      "ledgerEntryGroups": {
        "nodes": [
          {
            "key": "withdrawal",
            "value": "12345",
            "created": "1969-06-16T13:32:00.000Z"
          },
          {
            "key": "withdrawal",
            "value": "54321",
            "created": "1969-06-21T02:56:05.000Z"
          }
        ],
        "pageInfo": {
          "endCursor": null,
          "hasNextPage": false,
          "hasPreviousPage": false,
          "startCursor": null
        }
      }
    }
  }
}
Filter#

You can filter groups by key, created, and/or value

ListLedgerEntryGroups
query ListLedgerEntryGroups(
  $ledger: LedgerMatchInput!
  $filter: LedgerEntryGroupsFilterSet,
) {
  ledger(ledger: $ledger) {
    ledgerEntryGroups(filter: $filter) {
      nodes {
        key
        value
        created
      }
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
    }
  }
}
ListLedgerEntryGroups Variables
{
  "ledger": {
    "ik": "quickstart-ledger"
  },
  "filter": {
    "key": {
      "equalTo": "withdrawal"
    },
    "created": {
      "before": "1969-06-20T00:00:00.000Z"
    }
  }
}

The response is:

ListLedgerEntryGroups Response
{
  "data": {
    "ledger": {
      "ledgerEntryGroups": {
        "nodes": [
          {
            "key": "withdrawal",
            "value": "12345",
            "created": "1969-06-16T13:32:00.000Z"
          }
        ],
        "pageInfo": {
          "endCursor": null,
          "hasNextPage": false,
          "hasPreviousPage": false,
          "startCursor": null
        }
      }
    }
  }
}

h. External Accounts

#
Lookup#

Use the externalAccount query to retrieve an ExternalAccount by its ID at your external system:

GetExternalAccountByExternalIdAndLinkId
query GetExternalAccount(
  $externalId: ID!
  $linkId: ID!
) {
  externalAccount(
    externalAccount: {
      externalId: $externalId
      linkId: $linkId
    }
  ) {
    name
    link {
      __typename
      id
      name
    }
  }
}
GetExternalAccountByExternalIdAndLinkId Variables
{
  "externalId": "<External ID>",
  "linkId": "<Link ID>"
}

Or by its FRAGMENT ID:

GetExternalAccountByFragmentID
query GetExternalAccount($id: ID!) {
  externalAccount(externalAccount: { id: $id }) {
    name
    externalId
    linkId
    link {
      __typename
      id
      name
    }
  }
}
GetExternalAccountByFragmentID Variables
{
  "id": "<Fragment External Account ID>"
}
Txs#

Use the externalAccount.txs query to list Txs synced to an External Account:

ListExternalAccountTxs
query ListExternalAccountTxs(
  $externalAccount: ExternalAccountMatchInput!
  $after: String
  $first: Int
  $before: String
) {
  externalAccount(
    externalAccount: $externalAccount
  ) {
    externalId
    link {
      __typename
      id
      name
    }
    txs(
      after: $after
      first: $first
      before: $before
    ) {
      nodes {
        externalId
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

You may optionally specify before and after to paginate the results and first to specify the page size.

ListExternalAccountTxs Variables
{
  "externalAccount": {
    "externalId": "<External ID>",
    "linkId": "<Link ID>"
  },
  "after": "2023-07-01T00:00:00.000Z",
  "before": "2023-07-30T23:59:59.999Z",
  "first": 20
}

The response is a paginated list of Txs.

Linked Accounts#

Use the externalAccount.ledgerAccounts query to list Ledger Accounts linked to this External Account:

GetExternalAccountLinkedAccounts
query GetExternalAccountLinkedAccounts(
  $externalAccount: ExternalAccountMatchInput!
) {
  externalAccount(
    externalAccount: $externalAccount
  ) {
    externalId
    name
    link {
      __typename
      id
      name
    }
    ledgerAccounts {
      nodes {
        path
        name
        type
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}
GetExternalAccountLinkedAccounts Variables
{
  "externalAccount": {
    "externalId": "<External ID>",
    "linkId": "<Link ID>"
  }
}

The response is a paginated list of Ledger Accounts.

i. Txs

#
Lookup#

Use the tx query to retrieve a Tx by its ID and Account ID at your external system:

GetTxByExternalIds
query GetTx(
  $externalId: ID!
  $externalAccountId: ID!
  $linkId: ID!
) {
  tx(
    tx: {
      externalId: $externalId
      externalAccountId: $externalAccountId
      linkId: $linkId
    }
  ) {
    id
    description
    amount
    currency {
      code
    }
    externalId
    link {
      id
    }
    externalAccount {
      id
      externalId
    }
  }
}
GetTxByExternalIds Variables
{
  "externalAccountId": "<External Account ID>",
  "external": "<External Tx ID>",
  "linkId": "<Link ID>"
}

Or by its FRAGMENT ID:

GetTxByFragmentID
query GetTx(
  $id: ID!
) {
  tx(
    tx: {
      id: $id
    }
  ) {
    id
    description
    amount
    currency {
      code
    }
    externalId
    link {
      id
    }
    externalAccount {
      id
      externalId
    }
  }
}
GetTxByFragmentID Variables
{
  "id": "<Fragment ID>"
}
Unreconciled#

Use the ledgerAccount.unreconciledTx query to list a Ledger Account's unreconciled Txs:

GetUnreconciledTxs
query GetUnreconciledTxs(
  $ledgerAccount: LedgerAccountMatchInput!
  $after: String
  $first: Int
  $before: String
) {
  ledgerAccount(ledgerAccount: $ledgerAccount) {
    path
    unreconciledTxs(
      after: $after
      first: $first
      before: $before
    ) {
      nodes {
        id
        description
        amount
        currency {
          code
        }
        externalId
        link {
          id
        }
        externalAccount {
          id
          externalId
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

You may optionally specify before and after to paginate the results and first to specify the page size.

GetUnreconciledTxs Variables
{
  "ledgerAccount": {
    "path": "assets/banks/user-cash",
    "ledger": {
      "ik": "quickstart-ledger"
    }
  },
  "after": "2023-07-01T00:00:00.000Z",
  "before": "2023-07-30T23:59:59.999Z",
  "first": 20
}

The response is a paginated list of Txs.

j. Schemas

#
Lookup#

Use the schema query to retrieve a Schema by its key:

GetSchema
query GetSchema($schema: SchemaMatchInput!) {
  schema(schema: $schema) {
    key
    name
    latestVersion: version {
      created
      version
    }
    firstVersion: version(version: 1) {
      created
      version
    }
  }
}

When retrieving a Schema, use the version argument to query a specific version of the Schema. By default, the latest version is returned:

GetSchema Variables
{
  "schema": {
    "key": "quickstart-schema"
  }
}

The JSON of a Schema version can be retrieved by querying the json field:

GetLatestSchemaJSON
query GetLatestSchemaJSON(
  $schema: SchemaMatchInput!
) {
  schema(schema: $schema) {
    key
    name
    version {
      created
      version
      json
    }
  }
}
GetLatestSchemaJSON Variables
{
  "schema": {
    "key": "quickstart-schema"
  }
}
List versions#

Use the schema.versions query to query all the versions of your Schema:

ListSchemaVersions
query ListSchemaVersions(
  $schema: SchemaMatchInput!
) {
  schema(schema: $schema) {
    key
    name
    versions {
      nodes {
        created
        version
        json
      }
    }
  }
}

The response is a paginated list of your Schema's versions:

ListSchemaVersions Variables
{
  "schema": {
    "key": "quickstart-schema"
  }
}
List Ledgers#

Use the schema.ledgers query to list the Ledgers created off a Schema:

ListSchemaLedgers
query ListSchemaLedgers(
  $schema: SchemaMatchInput!
) {
  schema(schema: $schema) {
    key
    name
    ledgers {
      nodes {
        ik
        name
        created
        balanceUTCOffset
      }
    }
  }
}
ListSchemaLedgers Variables
{
  "schema": {
    "key": "quickstart-schema"
  }
}
Migration status#

FRAGMENT asynchronously migrates Ledgers when their Schema is updated. The current status of a Ledger's migration can be queried using the API, via version.migrations:

GetLedgerMigrationStatus
query GetLedgerMigrationStatus(
  $schema: SchemaMatchInput!
) {
  schema(schema: $schema) {
    key
    name
    latestVersion: version {
      migrations {
        nodes {
          ledger {
            ik
            name
          }
          status
        }
      }
    }
  }
}
ListSchemaLedgers Variables
{
  "schema": {
    "key": "quickstart-schema"
  }
}