> ## 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.

# Create Leave Type

> Create a new leave type for a company

Create a new leave type configuration for a company. Leave types define the different categories of leave available to employees (e.g., Annual Leave, Sick Leave, etc.) along with their policies and allowances.

## Authentication

Requires authentication with Bearer token. Available to:

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

## Path Parameters

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

  **Example:** `"123e4567-e89b-12d3-a456-426614174000"`
</ParamField>

## Request Body

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

  **Example:** `"Annual Leave"`
</ParamField>

<ParamField body="code" type="string" required>
  Short code for the leave type (typically uppercase)

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

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

  **Example:** `"Paid annual vacation time for all employees"`
</ParamField>

<ParamField body="daysAllowed" type="number" required>
  Total number of days allowed per year for this leave type

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

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

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

<ParamField body="requiresDocumentation" type="boolean" required>
  Whether documentation (e.g., medical certificate) is required

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

<ParamField body="carryForwardAllowed" type="boolean" required>
  Whether unused days can be carried forward to the next year

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

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

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

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

  **Example:** `"#3B82F6"`
</ParamField>

<ParamField body="status" type="string" required>
  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 created 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
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.companyflow.com/companies/123e4567-e89b-12d3-a456-426614174000/leave-types \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Annual Leave",
      "code": "AL",
      "description": "Paid annual vacation time for all employees",
      "daysAllowed": 20,
      "isPaid": true,
      "requiresDocumentation": false,
      "carryForwardAllowed": true,
      "maxCarryForwardDays": 5,
      "colorCode": "#3B82F6",
      "status": "active"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.companyflow.com/companies/123e4567-e89b-12d3-a456-426614174000/leave-types',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Annual Leave',
        code: 'AL',
        description: 'Paid annual vacation time for all employees',
        daysAllowed: 20,
        isPaid: true,
        requiresDocumentation: false,
        carryForwardAllowed: true,
        maxCarryForwardDays: 5,
        colorCode: '#3B82F6',
        status: 'active'
      })
    }
  );

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

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

  url = 'https://api.companyflow.com/companies/123e4567-e89b-12d3-a456-426614174000/leave-types'
  headers = {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
  }
  payload = {
      'name': 'Annual Leave',
      'code': 'AL',
      'description': 'Paid annual vacation time for all employees',
      'daysAllowed': 20,
      'isPaid': True,
      'requiresDocumentation': False,
      'carryForwardAllowed': True,
      'maxCarryForwardDays': 5,
      'colorCode': '#3B82F6',
      'status': 'active'
  }

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

<ResponseExample>
  ```json 201 - Created theme={null}
  {
    "success": true,
    "data": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "company_id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Annual Leave",
      "code": "AL",
      "description": "Paid annual vacation time for all employees",
      "days_allowed": 20,
      "is_paid": true,
      "requires_documentation": false,
      "carry_forward_allowed": true,
      "max_carry_forward_days": 5,
      "color_code": "#3B82F6",
      "status": "active",
      "created_at": "2025-03-03T10:30:00Z",
      "updated_at": "2025-03-03T10:30:00Z"
    }
  }
  ```

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

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

<Note>
  After creating a leave type, employees in the company will need to have leave balances initialized for this type before they can request leave.
</Note>
