> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cadanapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Departments & Custom Fields

> Organize workers by department and track custom metadata

export const ApiExample = ({method = "GET", path, params, body, reference, tenantKey}) => {
  const baseUrl = "https://api.cadanapay.com";
  const query = params ? "?" + Object.entries(params).map(([k, v]) => `${k}=${v}`).join("&") : "";
  const url = `${baseUrl}${path}${query}`;
  const isPlatformPath = (/^\/(v1\/)?platform(\/|$)/).test(path || "");
  const includeTenantKey = tenantKey === undefined ? !isPlatformPath : tenantKey;
  let curl = `curl -X ${method} '${url}' \\\n  -H 'Authorization: Bearer YOUR_API_KEY'`;
  if (includeTenantKey) {
    curl += ` \\\n  -H 'X-MultiTenantKey: YOUR_BUSINESS_TENANT_KEY'`;
  }
  if (body) {
    const formatted = JSON.stringify(body, null, 2);
    curl += ` \\\n  -H 'Content-Type: application/json' \\\n  -d '${formatted}'`;
  }
  return <div>
      <CodeBlock language="bash" filename="bash" wrap>
        {curl}
      </CodeBlock>
      {reference && <div style={{
    marginTop: "-0.5rem",
    marginBottom: "1rem"
  }}>
          <a href={reference} style={{
    fontSize: "0.875rem"
  }}>
            Try it in the playground →
          </a>
        </div>}
    </div>;
};

Departments and custom fields let you define organizational structure and track arbitrary metadata for your workforce. Both are **defined at the business level**, then **assigned to individual workers** via their job information.

* **Departments** — organizational units like "Engineering" or "Sales"
* **Custom fields** — arbitrary metadata like "T-shirt Size" or "Employee ID"

Once created on a business, departments and custom fields become available to assign when updating a person's `jobInfo`.

***

## Prerequisites

<Steps>
  <Step title="API key from Dashboard">
    Get your API key from the [Cadana Dashboard](https://app.cadanapay.com). See [Authentication](/authentication) for details.
  </Step>

  <Step title="Your business ID">
    You need a `businessId` for these endpoints. **Platform integrators** receive this from the [`POST /v1/platform/businesses`](/api-reference/workforce/platform/create) response when creating a business. **Direct API users** can find it in the [Dashboard](https://app.cadanapay.com) under **Settings > Business**.
  </Step>
</Steps>

***

## Departments

### Create Departments

Create one or more departments in a single request. Pass an array of department names in the `data` field.

<ApiExample method="POST" path="/v1/businesses/3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a/departments" body={{ data: ["Engineering", "Sales", "Operations"] }} reference="/api-reference/workforce/businesses/create-department" />

**Response:**

```json theme={null}
{
  "data": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Engineering"
    },
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "name": "Sales"
    },
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "name": "Operations"
    }
  ]
}
```

### Update a Department

Rename an existing department by its ID.

<ApiExample method="PUT" path="/v1/businesses/3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a/departments/a1b2c3d4-e5f6-7890-abcd-ef1234567890" body={{ name: "Legal" }} reference="/api-reference/workforce/businesses/update-department" />

Returns `204` on success.

### View Departments

Departments are returned as an array on the business object. Use [`GET /v1/businesses/{businessId}`](/api-reference/workforce/businesses/get) to retrieve them.

<ApiExample method="GET" path="/v1/businesses/3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a" reference="/api-reference/workforce/businesses/get" />

The response includes a `departments` array:

```json theme={null}
{
  "id": "3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a",
  "name": "ACME LLC",
  "departments": [
    { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Legal" },
    { "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901", "name": "Sales" },
    { "id": "c3d4e5f6-a7b8-9012-cdef-123456789012", "name": "Operations" }
  ],
  "customFields": []
}
```

***

## Custom Fields

### Create Custom Fields

Create one or more custom fields in a single request. Pass an array of field names in the `data` field.

<ApiExample method="POST" path="/v1/businesses/3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a/customFields" body={{ data: ["T-shirt Size", "Desk Number"] }} reference="/api-reference/workforce/businesses/create-custom-field" />

**Response:**

```json theme={null}
{
  "data": [
    {
      "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
      "name": "T-shirt Size",
      "value": ""
    },
    {
      "id": "e5f6a7b8-c9d0-1234-ef01-345678901234",
      "name": "Desk Number",
      "value": ""
    }
  ]
}
```

<Note>
  Custom fields are created with an empty `value`. Values are set per-person when you assign the field via `jobInfo`.
</Note>

### Update a Custom Field

Rename an existing custom field by its ID.

<ApiExample method="PUT" path="/v1/businesses/3e8b9a1c-5d4f-4a2e-b7c6-9f0e8d7c6b5a/customFields/d4e5f6a7-b8c9-0123-def0-234567890123" body={{ name: "Employee ID" }} reference="/api-reference/workforce/businesses/update-custom-field" />

Returns `204` on success.

### View Custom Fields

Like departments, custom fields are returned on the business object via [`GET /v1/businesses/{businessId}`](/api-reference/workforce/businesses/get):

```json theme={null}
{
  "customFields": [
    { "id": "d4e5f6a7-b8c9-0123-def0-234567890123", "name": "Employee ID", "value": "" },
    { "id": "e5f6a7b8-c9d0-1234-ef01-345678901234", "name": "Desk Number", "value": "" }
  ]
}
```

***

## Assign to Workers

Once departments and custom fields exist on the business, assign them to individual workers via [`PUT /v1/persons/{personId}/jobInfo`](/api-reference/workforce/persons/update-job-information).

* `department` — pass the department **name** (string), not the ID
* `customFields` — pass an array of objects with `name` and `value`

<ApiExample method="PUT" path="/v1/persons/8ef9a712-cdae-4110-b1ea-9ba95abbee6e/jobInfo" body={{ title: "Software Engineer", department: "Engineering", startDate: "2024-01-15", customFields: [{ name: "Employee ID", value: "ENG-042" }, { name: "Desk Number", value: "3B-12" }] }} reference="/api-reference/workforce/persons/update-job-information" />

Returns `204` on success.

<Tip>
  For full details on creating persons and setting up job information, see [Onboard Workers](/workforce/onboarding-workers).
</Tip>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Onboard Workers" icon="user-plus" href="/workforce/onboarding-workers">
    Create Person records and assign departments during onboarding
  </Card>

  <Card title="Pay Workers via Payroll" icon="money-check-dollar" href="/workforce/pay-workers-via-payroll">
    Run payroll for workers across departments
  </Card>

  <Card title="Business Setup" icon="building" href="/workforce/overview">
    Platform overview and business creation
  </Card>
</CardGroup>
