openapi: 3.1.0
info:
  title: Tasks Management API
  description: |
    API for managing tasks

    The API described in the [tasks.yaml](https://developers.hivelight.com/schemas/tasks.yaml) file is designed to manage tasks within a workspace. This typically involves creating, reading, updating, and deleting (CRUD) operations on tasks within a workspace environment. 

    The API provides endpoints to interact with these tasks programmatically, allowing our customers to efficiently manage and organize their workspace contents.
  version: 1.0.0
  contact:
    name: Support
    url: https://docs.hivelight.com
    email: support@hivelight.com
servers:
  - url: https://api.hivelight.com
    description: Global endpoint
  - url: https://au.api.hivelight.com
    description: Australian endpoint
paths:
  /tasks:
    post:
      summary: Create a task
      description: Create a task in the workspace.
      requestBody:
        required: true
        content:
          application/vnd.api+json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      value: tasks
                    attributes:
                      type: object
                      required:
                        - name
                      properties:
                        name:
                          type: string
                          description: Name of the task
                        description:
                          type: string
                          description: Rich-text description of the task
                        status:
                          type: string
                          description: Status of the task
                          enum:
                            - TODO
                            - INPROGRESS
                            - INREVIEW
                            - DONE
                        dueDate:
                          type: integer
                          format: int64
                          description: Due date of the task as an integer representing milliseconds since the Unix epoch
                        targetDate:
                          type: integer
                          format: int64
                          description: Target date of the task as an integer representing milliseconds since the Unix epoch
                        isPriority:
                          type: boolean
                          description: Whether the task is marked as a priority
                        assignees:
                          type: array
                          description: A list of assignees as userIds
                          items:
                            type: string
                        reviewers:
                          type: array
                          description: A list of reviewers as userIds
                          items:
                            type: string
                    relationships:
                      type: object
                      required:
                        - matter
                        - milestone
                      properties:
                        matter:
                          type: object
                          properties:
                            data:
                              type: object
                              properties:
                                type:
                                  type: string
                                  value: matter
                                id:
                                  type: string
                                  description: The matterId the task is associated with
                        milestone:
                          type: object
                          properties:
                            data:
                              type: object
                              properties:
                                type:
                                  type: string
                                  value: milestone
                                id:
                                  type: string
                                  description: The milestoneId the task is associated with
      responses:
        "201":
          description: Task created successfully
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    $ref: "#/components/schemas/Task"
    get:
      summary: Get tasks
      description: Get tasks in the workspace with optional pagination and filtering.
      parameters:
        - name: from
          in: query
          description: Starting index for pagination.
          required: false
          schema:
            type: integer
        - name: size
          in: query
          description: Number of items to return.
          required: false
          schema:
            type: integer
        - name: matterId
          in: query
          description: The matterId to filter tasks by matter.
          required: false
          schema:
            type: string
        - name: milestoneId
          in: query
          description: The milestoneId to filter tasks by milestone.
          required: false
          schema:
            type: string
        - name: dueDateFrom
          in: query
          description: List tasks with a due date that is later than this parameter as an integer representing milliseconds since the Unix epoch
          type: integer
          format: int64
          example: 1672531199000
        - name: dueDateTo
          in: query
          description: List tasks with a due date that is earlier than this parameter as an integer representing milliseconds since the Unix epoch
          type: integer
          format: int64
          example: 1672531199000
        - name: statuses
          in: query
          type: string
          description: Comma separated statuses of the task
          enum:
            - TODO
            - INPROGRESS
            - INREVIEW
            - DONE

      responses:
        "200":
          description: List of tasks
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Task"
                  meta:
                    type: object
                    properties:
                      total:
                        description: Total number of tasks
                        type: integer
                        example: 100
                      showing:
                        description: Total number of tasks returned so far
                        type: integer
                        example: 10
                      from:
                        description: Current starting index for pagination
                        type: integer
                        example: 0
  /tasks/{taskId}:
    get:
      summary: Get task
      description: Get a task
      parameters:
        - name: taskId
          in: path
          description: task Id to retrieve
          required: true
      responses:
        "200":
          description: Task
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    $ref: "#/components/schemas/Task"
  /tasks/{taskId}/status:
    post:
      summary: Update a task status
      description: Updates a task status
      parameters:
        - name: taskId
          in: path
          description: task Id to update
          required: true
      requestBody:
        required: true
        content:
          application/vnd.api+json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      value: tasks
                    attributes:
                      type: object
                      properties:
                        status:
                          type: string
                          description: Status of the task
                          enum:
                            - TODO
                            - INPROGRESS
                            - INREVIEW
                            - DONE

      responses:
        "200":
          description: Task
          content:
            application/vnd.api+json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    $ref: "#/components/schemas/Task"
components:
  schemas:
    Task:
      type: object
      properties:
        type:
          type: string
          value: tasks
        id:
          type: string
        attributes:
          $ref: "#/components/schemas/TaskAttributes"
    TaskAttributes:
      type: object
      properties:
        name:
          type: string
          description: Name of the task
        description:
          type: string
          description: Rich-text description of the task
        status:
          type: string
          description: Status of the task
          enum:
            - TODO
            - INPROGRESS
            - INREVIEW
            - DONE
        dueDate:
          type: integer
          format: int64
          description: Due date of the task as an integer representing milliseconds since the Unix epoch
        isPriority:
          type: boolean
          description: Whether the task is marked as a priority
        createdDate:
          type: integer
          format: int64
          description: Created date of a task as an integer representing milliseconds since the Unix epoch
        tags:
          type: array
          optional: true
          description: A list of label/value tags associated with the matter as an array of object .
          items:
            type: object
            properties:
              label:
                type: string
                description: The label of the tag (e.g., "priority", "status", "type", "value")
              value:
                type: string
                optional: true
                description: An optional value to the label of the tag (e.g., "high", "open", "ACC", "$3,000")
        assignees:
          type: array
          description: A list of assignees as userIds
          items:
            type: string
            description: User ID or email of the user
        reviewers:
          type: array
          description: A list of reviewers as userIds
          items:
            type: string
            description: User ID or email of the user
        matterId:
          type: string
          description: The matterId the task is associated with
        matterName:
          type: string
          description: The matter name the task is associated with
        milestoneId:
          type: string
          description: The milestoneId the task is associated with
        milestoneName:
          type: string
          description: The milestone name the task is associated with
