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

# Create a task



## OpenAPI

````yaml /openapi/assignment.yaml post /api/v1/tasks
openapi: 3.1.0
info:
  title: Assignment Service
  description: Centralised task-assignment hub for workflow-driven organisations.
  version: 1.0.0
servers:
  - url: https://api.capedigital.co.ke/assignment
    description: Production
  - url: http://localhost:8000
    description: Local
security: []
paths:
  /api/v1/tasks:
    post:
      tags:
        - tasks
      summary: Create a task
      operationId: create_task_api_v1_tasks_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_TaskResponse_'
        '409':
          description: Conflict
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    TaskCreate:
      properties:
        priority:
          type: string
          enum:
            - LOW
            - MEDIUM
            - HIGH
            - URGENT
          title: Priority
          default: MEDIUM
        engine_request:
          anyOf:
            - type: string
              maxLength: 50
              minLength: 1
            - type: 'null'
          title: Engine Request
        workflow_node_code:
          anyOf:
            - type: string
              maxLength: 50
              minLength: 2
            - type: 'null'
          title: Workflow Node Code
        node_preview_name:
          anyOf:
            - type: string
              maxLength: 120
            - type: 'null'
          title: Node Preview Name
        required_permissions_snapshot:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          title: Required Permissions Snapshot
        due_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Due At
        source_service:
          type: string
          maxLength: 60
          minLength: 1
          title: Source Service
        entity_type:
          type: string
          maxLength: 60
          minLength: 1
          title: Entity Type
        entity_id:
          type: string
          format: uuid
          title: Entity Id
        entity_reference:
          anyOf:
            - type: string
              maxLength: 30
            - type: 'null'
          title: Entity Reference
      additionalProperties: false
      type: object
      required:
        - source_service
        - entity_type
        - entity_id
      title: TaskCreate
    ApiResponse_TaskResponse_:
      properties:
        success:
          type: boolean
          title: Success
        message:
          type: string
          title: Message
        data:
          $ref: '#/components/schemas/TaskResponse'
      type: object
      required:
        - success
        - message
        - data
      title: ApiResponse[TaskResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        status:
          type: string
          enum:
            - OPEN
            - IN_PROGRESS
            - DONE
            - BLOCKED
            - CANCELLED
          title: Status
        priority:
          type: string
          enum:
            - LOW
            - MEDIUM
            - HIGH
            - URGENT
          title: Priority
        engine_request:
          anyOf:
            - type: string
            - type: 'null'
          title: Engine Request
        workflow_node_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Workflow Node Code
        node_preview_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Node Preview Name
        node_instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Node Instructions
        required_permissions_snapshot:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          title: Required Permissions Snapshot
        assigned_to:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Assigned To
        assigned_to_user:
          anyOf:
            - type: object
            - type: 'null'
          title: Assigned To User
        assigned_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Assigned At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        due_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Due At
        escalation_level:
          type: integer
          title: Escalation Level
          default: 0
        source_service:
          type: string
          title: Source Service
        entity_type:
          type: string
          title: Entity Type
        entity_id:
          type: string
          format: uuid
          title: Entity Id
        entity_reference:
          anyOf:
            - type: string
            - type: 'null'
          title: Entity Reference
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        deleted_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Deleted At
      type: object
      required:
        - id
        - status
        - priority
        - engine_request
        - workflow_node_code
        - node_preview_name
        - node_instructions
        - required_permissions_snapshot
        - assigned_to
        - assigned_at
        - completed_at
        - due_at
        - source_service
        - entity_type
        - entity_id
        - entity_reference
        - created_at
        - updated_at
        - deleted_at
      title: TaskResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````