openapi: 3.0.0
info:
  title: Agent dispatcher API
  description: Set of endpoints to agent dispatcher api
  contact:
    email: auradev@tid.es
tags:
  - name: agents
    description: Responsible for sending a request to the appropriate agent to process it
servers:
  - url: "http://localhost:8990"
    description: Local server
  - url: "https://svc-ap-current.auracognitive.com"
    description: ap-current
paths:
  /aura-services/v2/agents/{agent_id}/messages:
    post:
      tags:
        - agents
        - messages
      description: Dispatch a message to an agent for processing
      operationId: sendAgentMessage
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: []
      parameters:
        - name: agent_id
          in: path
          description: Agent identifier. Unique string that identifies the agent.
          required: true
          schema:
            $ref: '#/components/schemas/StringWithoutSpaces'
        - name: correlator
          in: header
          description: Unique identifier of a request to be used as correlator in all systems
          required: false
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AgentMessageRequest"
      responses:
        "200":
          $ref: "#/components/responses/AgentMessageResponse"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
components:
  responses:
    AgentMessageResponse:
      description: Incoming HTTP request format is valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AgentMessageResponse"
    InvalidRequest:
      description: Incoming HTTP request format is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    Unauthorized:
      description: Incoming HTTP request authorization is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    NotFound:
      description: Incoming HTTP request is not found
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    InternalError:
      description: Incoming HTTP request produces an internal error
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
  securitySchemes:
    ApiKeyHeaderAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    AuraError:
      type: object
      description: Error response
      properties:
        code:
          type: string
          description: Unique id of the error
        message:
          type: string
          description: Specific and descriptive text of the error
        errors:
          description: With validation error. Swagger error information
          type: array
          items:
            type: object
    AgentMessage:
      type: object
      description: The input message to be processed
      properties:
        actor:
          type: string
          description: Actor that send the message. By default an identifier is generated by the server.
        actor_type:
          type: string
          description: Actor type that send the message. By default is human.
          enum:
          - human
          - ai
          - system
        content:
          $ref: '#/components/schemas/AgentMessageContent'
      required:
        - content
      additionalProperties: false
    AgentMessageWithId:
      allOf:
        - $ref: '#/components/schemas/AgentMessage'
        - type: object
          properties:
            id:
              type: string
              format: uuid
              description: Unique identifier for the message
          required:
            - id
    AgentMessageContent:
      type: object
      description: Message content to be processed by the agent
      properties:
        text:
          type: string
          description: Text content of the message
      required:
        - text
      additionalProperties: false
    AgentMessageRequest:
      type: object
      description: Agent message request
      properties:
        message:
          $ref: '#/components/schemas/AgentMessage'
        parameters:
          type: object
          description: Parameters to modify the agent's behavior
        session:
          $ref: '#/components/schemas/SessionRequest'
      required:
        - message
      additionalProperties: false
    AgentMessageResponse:
      type: object
      description: Agent message response
      properties:
        message:
          $ref: '#/components/schemas/AgentMessageWithId'
        metadata:
          type: object
          description: Response metadata
        parameters:
          type: object
          description: Parameters to modify the agent's behavior
        session:
          $ref: '#/components/schemas/SessionResponse'
      required:
        - message
        - session
    SessionRequest:
      type: object
      description: Contains the session information
      required:
        - id
      properties:
        id:
          description: Unique string that identifies the session.
          allOf:
            - $ref: '#/components/schemas/StringWithoutSpaces'
      additionalProperties: false
    SessionResponse:
      type: object
      description: Contains the session information
      required:
        - id
        - sequence
      properties:
        id:
          description: Unique string that identifies the session.
          allOf:
            - $ref: '#/components/schemas/StringWithoutSpaces'
        sequence:
          type: number
          description: The sequence number message of the session
      additionalProperties: false
    StringWithoutSpaces:
      type: string
      description: Regular expresion of string without spaces
      example: 79e2646a-a8bb-4355-b79f-42722c066155
      pattern: ^\S+$
      minLength: 1