openapi: 3.0.3
info:
  title: Mailbox API (TIIX Drop-in app_v2)
  version: "1.0.0"
  description: Rotas via app_v2: /adm/api/Mailbox/{Action}
servers:
  - url: /adm/api
paths:
  /Mailbox/Accounts.list:
    get: { summary: Lista contas do usuário, responses: { '200': { description: ok } } }
  /Mailbox/Folders.list:
    get:
      summary: Lista pastas da conta
      parameters:
        - in: query
          name: account_id
          required: true
          schema: { type: integer }
      responses: { '200': { description: ok } }
  /Mailbox/Threads.list:
    get:
      summary: Lista threads (conversas)
      parameters:
        - in: query { name: account_id, required: true, schema: { type: integer } }
        - in: query { name: folder, schema: { type: string, default: INBOX } }
        - in: query { name: page, schema: { type: integer, default: 1 } }
        - in: query { name: per_page, schema: { type: integer, default: 30 } }
        - in: query { name: q, schema: { type: string } }
        - in: query { name: category, schema: { type: string, enum: [primary,promotions,social,updates] } }
      responses: { '200': { description: ok } }
  /Mailbox/Messages.list:
    get:
      summary: Lista mensagens de uma thread
      parameters:
        - in: query { name: thread_id, required: true, schema: { type: integer } }
        - in: query { name: per_page, schema: { type: integer, default: 100 } }
      responses: { '200': { description: ok } }
  /Mailbox/Thread.markSeen:
    post:
      summary: Marca thread como lida para o usuário
      requestBody:
        required: true
        content: { application/json: { schema: { type: object, properties: { thread_id: {type: integer} }, required: [thread_id] } } }
      responses: { '200': { description: ok } }
  /Mailbox/Threads.bulkAction:
    post:
      summary: Ações em massa sobre threads
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action: { type: string, enum: [read,unread,star,unstar,important,unimportant,snooze,mute,unmute,delete,move,archive,unarchive,undelete] }
                thread_ids: { type: array, items: { type: integer } }
                account_id: { type: integer }
                folder: { type: string }
                dest_folder: { type: string }
                until: { type: string, description: 'YYYY-MM-DD HH:MM' }
              required: [action, thread_ids]
      responses: { '200': { description: ok } }
  /Mailbox/Message.send:
    post:
      summary: Envia e-mail
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                account_id: { type: integer }
                to: { type: string }
                cc: { type: string }
                bcc: { type: string }
                subject: { type: string }
                body_html: { type: string }
                attachments: { type: array, items: { type: string } }
              required: [account_id, to]
      responses: { '200': { description: ok } }
  /Mailbox/Attachments.upload:
    post:
      summary: Upload de anexo e retorno de token
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties: { file: { type: string, format: binary } }
              required: [file]
      responses: { '200': { description: ok } }
  /Mailbox/Sync.run:
    post:
      summary: Dispara sincronização (best-effort)
      requestBody:
        content: { application/json: { schema: { type: object, properties: { account_id: {type: integer}, folder: {type: string} } } } }
      responses: { '200': { description: ok } }
