# Get Departments

<mark style="color:green;">`GET`</mark> `https://api.sonorancms.com/v2/community/departments`

> **Rate limit:** `13 requests per minute`

> Authenticated v2 endpoints are rate limited per credential rather than per IP address.

Retrieve the community departments.

## Example Request

{% tabs %}
{% tab title="Sonoran.lua" %}

```lua
local Sonoran = require("sonoran")

local sonoran = Sonoran.createClient({
  product = Sonoran.productEnums.CMS,
  apiKey = "YOUR_API_KEY",
  communityId = "YOUR_COMMUNITY_ID",
  defaultServerId = 1,
  timeoutMs = 30000,
})

local response = sonoran.cms:getDepartmentsV2()

if response.success then
  print(response.data)
else
  print(response.reason)
end
```

{% endtab %}

{% tab title="Sonoran.js" %}

```javascript
const Sonoran = require("sonoran.js");

const instance = Sonoran.instance({
  apiKey: "YOUR_API_KEY",
  communityId: "YOUR_COMMUNITY_ID",
  product: Sonoran.productEnums.CMS,
  serverId: 1,
});

async function main() {
  const response = await instance.cms.getDepartmentsV2();

  if (response.success) {
    console.log(response.data);
  } else {
    console.error(response.reason);
  }
}

main().catch((error) => {
  console.error(error);
});
```

{% endtab %}

{% tab title="Sonoran.py" %}

```python
from sonoran import Instance, productEnums

instance = Instance(
    apiKey="YOUR_API_KEY",
    communityId="YOUR_COMMUNITY_ID",
    product=productEnums.CMS,
    serverId=1,
)

response = instance.cms.getDepartmentsV2()

if response.success:
    print(response.data)
else:
    print(response.reason)
```

{% endtab %}

{% tab title="Sonoran.Net" %}

```csharp
using Sonoran;
using System.Text.Json;

using var sonoran = new SonoranClient(new SonoranClientOptions
{
    product = SonoranProduct.CMS,
    apiKey = "YOUR_API_KEY",
    communityId = "YOUR_COMMUNITY_ID",
    defaultServerId = 1
});

var response = await sonoran.Cms.getDepartmentsV2();

if (response.success)
{
    Console.WriteLine(JsonSerializer.Serialize(response.data));
}
else
{
    Console.WriteLine(response.reason);
}
```

{% endtab %}

{% tab title="OpenAPI" %}

```yaml
openapi: "3.0.3"

info:

  title: "Sonoran CMS v2 - Get Departments"

  version: "1.0.0"

  description: "Retrieve the community departments."

servers:

  -

    url: "https://api.sonorancms.com"

paths:

  /v2/community/departments:

    get:

      summary: "Get Departments"

      operationId: "getDepartments"

      security:

        -

          bearerAuth: []

      responses:

        "200":

          description: "Successful response"

          content:

            application/json:

              schema:

                type: "object"

              example:

                success: true

                data:

                  -

                    uuid: "11111111-1111-1111-1111-111111111111"

                    label: "Police Department"

                    labelTwo: "Police"

                    ranks:

                      -

                        id: "22222222-2222-2222-2222-222222222222"

                        label: "Cadet"

                        primaryOnly: true

                        secondaryOnly: false

                        power: 10

                meta:

                  timestamp: "2026-04-15T00:00:00.000Z"

                  path: "/v2/community/departments"

components:

  securitySchemes:

    bearerAuth:

      type: "http"

      scheme: "bearer"

      bearerFormat: "JWT"
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \

  --url "https://api.sonorancms.com/v2/community/departments" \

  --header "Authorization: Bearer YOUR_API_KEY" \

  --header "Accept: application/json"
```

{% endtab %}
{% endtabs %}

## Response

The `data` array is the community department list. Each department includes its label pair and the ranks nested beneath it.

```json

{

  "success": true,

  "data": [

    {

      "uuid": "11111111-1111-1111-1111-111111111111",

      "label": "Police Department",

      "labelTwo": "Police",

      "ranks": [

        {

          "id": "22222222-2222-2222-2222-222222222222",

          "label": "Cadet",

          "primaryOnly": true,

          "secondaryOnly": false,

          "power": 10

        }

      ]

    }

  ],

  "meta": {

    "timestamp": "2026-04-15T00:00:00.000Z",

    "path": "/v2/community/departments"

  }

}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonoransoftware.com/cms/developer-api-documentation/api-integration/api-endpoints-v2/general/get-departments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
