Fetching Related Resources

The GET operations are equipped with an include query parameter that facilitates the retrieval of multiple related resources in the response. By specifying one or more relationships (in a comma-separated format), the response will comprise a separate included section that houses the corresponding resources.

This feature allows you to consolidate multiple API calls into a single one, resulting in more organized code and avoiding issues with data consistency that can arise from making separate API calls at different times.

curl -X GET 'https://sandbox.getanchor.co/api/v1/event/3525-anc_et?include=customer,account' \
-H "Authorization: 'x-anchor-key ${API KEY}'
{
  "data": {
    "id": "1676133886253525-anc_et",
    "type": "sub_account.created",
    "attributes": {
      "createdAt": "2023-02-11T17:44:46"
    },
    "relationships": {
      "parentAccount": {
        "data": {
          "id": "16676560048020-anc_acc",
          "type": "DepositAccount"
        }
      },
      "subAccount": {
        "data": {
          "id": "1676133886172103-anc_subacc",
          "type": "SubAccount"
        }
      },
      "customer": {
        "data": {
          "id": "16741212559310-anc_ind_cst",
          "type": "IndividualCustomer"
        }
      }
    }
  },
  "included": [
    {
      "id": "16676560048020-anc_acc",
      "type": "DepositAccount",
      "attributes": {
        "createdAt": "2022-11-05T14:46:45",
        "bank": {
          "id": "16528052138160-anc_bk",
          "name": "CORESTEP MICROFINANCE BANK",
          "cbnCode": "",
          "nipCode": "090365"
        },
        "accountName": "ANCHOR SOFTWARE SYSTEMS LTD",
        "frozen": false,
        "currency": "NGN",
        "accountNumber": "******3671",
        "type": "FBO",
        "status": "ACTIVE"
      },
      "relationships": {
        "subAccounts": {
          "data": [
            {
              "id": "16676561673790-anc_subacc",
              "type": "SubAccount"
            },
            {
              "id": "16676561674371-anc_subacc",
              "type": "SubAccount"
            },
            {
              "id": "16741212760730-anc_subacc",
              "type": "SubAccount"
            },
            {
              "id": "1676133886172103-anc_subacc",
              "type": "SubAccount"
            }
          ]
        },
        "virtualNubans": {
          "data": [
            {
              "id": "16741214579460-anc_va",
              "type": "VirtualNuban"
            }
          ]
        },
        "customer": {
          "data": {
            "id": "16534920868750-anc_bus_cst",
            "type": "BusinessCustomer"
          }
        }
      }
    },
    {
      "id": "1676133886172103-anc_subacc",
      "type": "SubAccount",
      "attributes": {
        "createdAt": "2023-02-11T17:44:46",
        "accountType": "REGULAR"
      },
      "relationships": {
        "virtualNubans": {
          "data": []
        },
        "parentAccount": {
          "data": {
            "id": "16676560048020-anc_acc",
            "type": "DepositAccount"
          }
        },
        "customer": {
          "data": {
            "id": "16741212559310-anc_ind_cst",
            "type": "IndividualCustomer"
          }
        }
      }
    },
    {
      "id": "16741212559310-anc_ind_cst",
      "type": "IndividualCustomer",
      "attributes": {
        "createdAt": "2023-01-19T10:40:56",
        "metadata": {
          "my_customerID": "12345"
        },
        "phoneNumber": "07061106987",
        "address": {
          "addressLine_1": "45721 Timmy Mall",
          "addressLine_2": "64220 Greenholt Glen",
          "country": "NG",
          "city": "West Lucio",
          "postalCode": "123456",
          "state": "OGUN"
        },
        "soleProprietor": false,
        "fullName": {
          "firstName": "Riley",
          "lastName": "Fay",
          "middleName": "Rolfson",
          "maidenName": null
        },
        "email": "[email protected]"
      }
    }
  ]
}