JSON API: Manage Ledger Accounts

Refer to the account schema for a formal definition of the request and the account response schema for a definition of the response.

Route: account/add

On creation, a ledger root account is defined. New accounts added without a parent are treated as children of the root.

Example: Add an account to the root.

{
  "code": "1100",
  "name": "Bank Account",
  "debit": true,
  "extra": "{\"bank\": \"TD\", \"account\": \"0045-01234\"}"
}

Sample response:

{
  "time": "2022-01-23 11:43:10.853456Z",
  "account": {
    "uuid": "0c91a8e0-77c9-43c8-86f0-3e737c25633b",
    "code": "1100",
    "names": [
      {
        "name": "Bank Account",
        "language": "en",
        "createdAt": "2022-01-23 11:43:10.853456Z",
        "updatedAt": "2022-01-23 11:43:10.853456Z"
      }
    ],
    "extra": "{\"bank\": \"TD\", \"account\": \"0045-01234\"}",
    "revision": "eb2e12b76963387a41e81bb75bc01ef2992ca3959ec432b7fc1f5e3f8fcb809c",
    "createdAt": "2022-01-23 11:43:10.853456Z",
    "updatedAt": "2022-01-23 11:43:10.853456Z"
  }
}

Route: account/get

Accounts can be retrieved by code or UUID.

{
    "code": "1100"
}

Sample response:

{
  "time": "2022-01-23 11:44:35.756432Z",
  "account": {
    "uuid": "0c91a8e0-77c9-43c8-86f0-3e737c25633b",
    "code": "1100",
    "names": [
      {
        "name": "Bank Account",
        "language": "en",
        "createdAt": "2022-01-23 11:43:10.853456Z",
        "updatedAt": "2022-01-23 11:43:10.853456Z"
      }
    ],
    "extra": "{\"bank\": \"TD\", \"account\": \"0045-01234\"}",
    "revision": "e12b7696eb23387a411ef2e81bb75bc099f5e3f8fcb809c2ca3959ec432b7fc1",
    "createdAt": "2022-01-23 11:43:10.853456Z",
    "updatedAt": "2022-01-23 11:43:10.853456Z"
  }
}

Route: account/delete

Delete requires the account code or UUID and a valid revision hash. No transactions can be posted against the account or any of its sub-accounts.

{
  "uuid": "0c91a8e0-77c9-43c8-86f0-3e737c25633b",
  "revision": "e12b7696eb23387a411ef2e81bb75bc099f5e3f8fcb809c2ca3959ec432b7fc1"
}

Sample response:

{
  "time": "2022-01-23 20:14:30.756432Z",
  "success": true
}

Route: account/update

Most account attributes (other than the UUID) can be updated, subject to the business rules.

{
  "code": "1100",
  "revision": "e12b7696eb23387a411ef2e81bb75bc099f5e3f8fcb809c2ca3959ec432b7fc1",
  "toCode": "1220",
  "parent": {
    "code": "1200"
  },
  "extra": "Account #8764-67800-001"
}

Sample response:

{
  "time": "2022-01-23 11:44:35.756432Z",
  "account": {
    "uuid": "0c91a8e0-77c9-43c8-86f0-3e737c25633b",
    "code": "1220",
    "extra": "Account #8764-67800-001",
    "names": [
      {
        "name": "Bank Account",
        "language": "en",
        "createdAt": "2022-01-23 11:43:10.853456Z",
        "updatedAt": "2022-01-23 11:43:10.853456Z"
      }
    ],
    "parentUuid": "cea92ab7-0a53-4dd1-a713-3a9a197ce8dc",
    "revision": "a9fba78071d86bec43f0792f5b1b686f9c8e0f449d7d5ae9ee104d15ec0fcc01",
    "createdAt": "2022-01-23 11:43:10.853456Z",
    "updatedAt": "2022-01-23 11:52:14.349856Z"
  }
}