Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Updated Mon Feb 6th 2023, 19:36 UTC

Tree

GET /accounts/tree

Accounts have a parent, and thus may be represented as a tree structure. This endpoint will retrieve the subset of that tree for which the requesting user has memberships.

By default, it will include the accounts at which the user has memberships, and their descendants. The accounts in the initial collection will be the accounts the user is a member of, with the children being a collection of that account’s children. If an account has no children, the collection will be empty. If the user is a member of two accounts within a branch, then the child member account will not appear at the top, but only at its appropriate place within the branch.

  • Parameters
    • role (optional, string, “admin”) … Limit only to accounts at which the user has this particular role.

Examples

Getting the accounts and their descendants.

This use useful when displaying the accounts a user has access to.

Request

GET /accounts/tree
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X GET /accounts/tree
    

Response

Status

200

Response Type

hydra:Collection

Example Body

{
  "@type": "hydra:Collection",
  "@context": "/contexts/hydra:Collection.jsonld",
  "id": "/accounts/tree",
  "members": [
    {
      "@type": "AccountTree",
      "@context": "/contexts/AccountTree.jsonld",
      "id": "/accounts/my_account",
      "name": "Example Account",
      "slug": "my_account",
      "analytics": "/accounts/my_account/analytics",
      "children": {
        "@type": "hydra:Collection",
        "@context": "/contexts/hydra:Collection.jsonld",
        "id": "/accounts/my_account/children",
        "members": [
          {
            "@type": "AccountTree",
            "@context": "/contexts/AccountTree.jsonld",
            "id": "/accounts/my_account_child",
            "name": "My Account Child",
            "slug": "my_account_child",
            "analytics": "/accounts/my_account_child/analytics",
            "children": {
              "@type": "hydra:Collection",
              "@context": "/contexts/hydra:Collection.jsonld",
              "id": "/accounts/my_account_child/children",
              "members": [],
              "totalItems": 0
            },
            "users": "/my_account_child/users"
          }
        ],
        "totalItems": 1
      },
      "users": "/my_account/users"
    }
  ],
  "totalItems": 1
}

© 2023 TextUs