# List Departments

List the departments on one level of the department tree. Without `parent_id` (or with `parent_id=-1`), the top-level department is returned. With `parent_id`, the sub-departments of that department are returned.

Departments of a team are listed by passing the team's `org_id`. Without `org_id`, the system-level departments (`org_id` of `-1`) are returned.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Account Operations: System admin",
    "description": "The official SeaTable API Reference (OpenAPI 3.0).",
    "version": "6.2"
  },
  "servers": [
    {
      "url": "https://{server}",
      "variables": {
        "server": {
          "default": "cloud.seatable.io"
        }
      }
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "metrics-enabled": false,
    "proxy-enabled": false
  },
  "tags": [
    {
      "name": "Departments",
      "description": "Manage departments"
    }
  ],
  "components": {
    "securitySchemes": {
      "AccountTokenAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "This is the [Account-Token](/reference/authentication)."
      }
    },
    "parameters": {
      "parent_id_query": {
        "name": "parent_id",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": -1
        },
        "description": "The ID of the parent department. Optional. Without it (or with `-1`), the top-level department is returned.",
        "example": 1
      },
      "department_org_id_query": {
        "name": "org_id",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": -1
        },
        "description": "The ID of the team. Optional. `-1` (system-level departments) by default.",
        "example": -1
      }
    }
  },
  "paths": {
    "/api/v2.1/admin/address-book-v2/departments/": {
      "get": {
        "tags": [
          "Departments"
        ],
        "summary": "List Departments",
        "operationId": "listDepartments",
        "description": "List the departments on one level of the department tree. Without `parent_id` (or with `parent_id=-1`), the top-level department is returned. With `parent_id`, the sub-departments of that department are returned.\n\nDepartments of a team are listed by passing the team's `org_id`. Without `org_id`, the system-level departments (`org_id` of `-1`) are returned.",
        "security": [
          {
            "AccountTokenAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/parent_id_query"
          },
          {
            "$ref": "#/components/parameters/department_org_id_query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "department_list": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "department_list": [
                    {
                      "id": 2,
                      "name": "Developers",
                      "parent_id": 1,
                      "org_id": -1,
                      "id_in_org": 2
                    },
                    {
                      "id": 3,
                      "name": "Test Department",
                      "parent_id": 1,
                      "org_id": -1,
                      "id_in_org": 3
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "_id": {
    "buffer": {
      "0": 105,
      "1": 212,
      "2": 220,
      "3": 12,
      "4": 20,
      "5": 34,
      "6": 131,
      "7": 31,
      "8": 141,
      "9": 111,
      "10": 187,
      "11": 146
    }
  }
}
```