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

# Reorder Organization Rules

> Set the display order of your organization's rules (admin)

Reorders the organization's rules. Pass **every** rule id in the desired order — the request is rejected if the set of ids doesn't match the org's rules exactly. Returns the rules in their new order.

<Note>
  This endpoint requires admin privileges.
</Note>

<ParamField header="Authorization" type="string" required>
  Bearer token obtained from the [authenticate](/api-reference/authentication/authenticate) endpoint. The authenticated user must be an admin.
</ParamField>

<ParamField body="rule_ids" type="string[]" required>
  All of the organization's rule ids, in the order you want them stored.
</ParamField>

## Response

<ResponseField name="organization_rules" type="array" required>
  The organization's rules in the new order. Each object matches the [List Organization Rules](/api-reference/organization-rules/list-organization-rules) shape.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST https://api.trellis.sh/v1/organization-rules/reorder \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "rule_ids": ["b2c3d4e5-f6a7-8901-bcde-f12345678901", "c3d4e5f6-a7b8-9012-cdef-123456789012"]
    }'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests

  response = requests.post(
      "https://api.trellis.sh/v1/organization-rules/reorder",
      headers={
          "Authorization": "Bearer YOUR_TOKEN",
          "Content-Type": "application/json",
      },
      json={"rule_ids": ["b2c3d4e5-f6a7-8901-bcde-f12345678901", "c3d4e5f6-a7b8-9012-cdef-123456789012"]},
  )
  rules = response.json()["organization_rules"]
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await fetch("https://api.trellis.sh/v1/organization-rules/reorder", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ rule_ids: ["b2c3d4e5-f6a7-8901-bcde-f12345678901", "c3d4e5f6-a7b8-9012-cdef-123456789012"] }),
  });
  const { organization_rules } = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "organization_rules": [
      {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "organization_id": "org_01HX...",
        "content": "Always cite the data source when presenting figures",
        "idx": 0,
        "created_by": "member_01HX...",
        "last_updated_by": "member_01HX...",
        "last_updated_by_name": "Jane Smith",
        "created_at": "2025-02-10T08:00:00+00:00",
        "updated_at": "2025-02-10T08:00:00+00:00"
      }
    ]
  }
  ```

  ```json 400 Incomplete id set theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "detail": "Expected 3 rule IDs, got 2"
  }
  ```

  ```json 403 theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "detail": "Admin privileges required"
  }
  ```
</ResponseExample>
