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

# Update Leave Type

> Update an existing leave type configuration

Update the configuration of an existing leave type. Both PUT and PATCH methods are supported. This endpoint allows you to modify leave policies, allowances, and other settings.

## Authentication

Requires authentication with Bearer token. Available to:

* **Super Admin**
* **HR Manager**

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the leave type (UUID format)

  **Example:** `"a1b2c3d4-e5f6-7890-abcd-ef1234567890"`
</ParamField>

## Request Body

All fields are optional. Only include the fields you want to update.

<ParamField body="name" type="string">
  Name of the leave type

  **Example:** `"Annual Leave (Updated)"`
</ParamField>

<ParamField body="code" type="string">
  Short code for the leave type

  **Example:** `"AL"`
</ParamField>

<ParamField body="description" type="string">
  Detailed description of the leave type

  **Example:** `"Updated policy for annual vacation time"`
</ParamField>

<ParamField body="daysAllowed" type="number">
  Total number of days allowed per year

  **Example:** `22`
</ParamField>

<ParamField body="isPaid" type="boolean">
  Whether this leave type is paid or unpaid

  **Example:** `true`
</ParamField>

<ParamField body="requiresDocumentation" type="boolean">
  Whether documentation is required

  **Example:** `true`
</ParamField>

<ParamField body="carryForwardAllowed" type="boolean">
  Whether unused days can be carried forward

  **Example:** `true`
</ParamField>

<ParamField body="maxCarryForwardDays" type="number">
  Maximum number of days that can be carried forward

  **Example:** `10`
</ParamField>

<ParamField body="colorCode" type="string">
  Hex color code for calendar display

  **Example:** `"#10B981"`
</ParamField>

<ParamField body="status" type="string">
  Status of the leave type: `active` or `inactive`

  **Example:** `"active"`
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  The updated leave type object

  <Expandable title="LeaveType properties">
    <ResponseField name="id" type="string">
      Unique identifier for the leave type
    </ResponseField>

    <ResponseField name="company_id" type="string">
      UUID of the company
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the leave type
    </ResponseField>

    <ResponseField name="code" type="string">
      Short code for the leave type
    </ResponseField>

    <ResponseField name="description" type="string">
      Detailed description
    </ResponseField>

    <ResponseField name="days_allowed" type="number">
      Total days allowed per year
    </ResponseField>

    <ResponseField name="is_paid" type="boolean">
      Whether the leave is paid
    </ResponseField>

    <ResponseField name="requires_documentation" type="boolean">
      Whether documentation is required
    </ResponseField>

    <ResponseField name="carry_forward_allowed" type="boolean">
      Whether carry forward is allowed
    </ResponseField>

    <ResponseField name="max_carry_forward_days" type="number">
      Maximum carry forward days
    </ResponseField>

    <ResponseField name="color_code" type="string">
      Hex color code
    </ResponseField>

    <ResponseField name="status" type="string">
      Status: active or inactive
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 timestamp
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      ISO 8601 timestamp (reflects latest update)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT https://api.companyflow.com/leave-types/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "daysAllowed": 22,
      "maxCarryForwardDays": 10,
      "description": "Updated policy with increased allowance"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.companyflow.com/leave-types/a1b2c3d4-e5f6-7890-abcd-ef1234567890',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        daysAllowed: 22,
        maxCarryForwardDays: 10,
        description: 'Updated policy with increased allowance'
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  url = 'https://api.companyflow.com/leave-types/a1b2c3d4-e5f6-7890-abcd-ef1234567890'
  headers = {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
  }
  payload = {
      'daysAllowed': 22,
      'maxCarryForwardDays': 10,
      'description': 'Updated policy with increased allowance'
  }

  response = requests.put(url, json=payload, headers=headers)
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "success": true,
    "data": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "company_id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Annual Leave",
      "code": "AL",
      "description": "Updated policy with increased allowance",
      "days_allowed": 22,
      "is_paid": true,
      "requires_documentation": false,
      "carry_forward_allowed": true,
      "max_carry_forward_days": 10,
      "color_code": "#3B82F6",
      "status": "active",
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": "2025-03-03T15:45:00Z"
    }
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "success": false,
    "message": "invalid request body"
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "success": false,
    "message": "unauthorized"
  }
  ```
</ResponseExample>

<Warning>
  Changes to leave type configuration will affect all future leave requests. Existing approved leave requests will not be modified.
</Warning>

## PATCH vs PUT

This endpoint supports both HTTP methods:

* **PUT**: Update specific fields (partial update)
* **PATCH**: Update specific fields (partial update)

Both methods work identically - you only need to include the fields you want to update.
