openapi: 3.1.0
info:
  title: Tango MAC Comment Outbound API
  version: "0.9"
  description: |
    Async **delta** REST API: client retrieves MAC comments created/updated
    in Tango since the last integration run. Two-call pattern with gu_id
    and pagination (5000/page).

    Updates to `tango_entity_id` or `tango_comment_id` do NOT trigger export.
  x-direction: outbound
  x-source: Tango
  x-destination: Client System
servers:
  - url: https://api.tangoanalytics.com
    description: Production
  - url: https://testapi.tangoanalytics.com
    description: Test (SIT/UAT)
tags: [{name: MAC Comments (Delta)}, {name: Status}]
paths:
  /v1/common/delta/comments:
    get:
      summary: Initiate delta comment export (async)
      operationId: getMacCommentsDelta
      tags: [MAC Comments (Delta)]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      responses:
        "200":
          description: Async ack.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
  /v1/batch/status:
    get:
      summary: Retrieve paginated comments by gu_id
      operationId: getMacCommentsByGuId
      tags: [Status]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
        - in: query
          name: gu_id
          required: true
          schema: { type: string, format: uuid }
        - in: query
          name: page_no
          required: false
          schema: { type: integer, minimum: 1 }
      responses:
        "200":
          description: Paginated comment records.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CommentPage"
components:
  securitySchemes:
    xClientHeader: { type: apiKey, in: header, name: x-client }
    xApiKeyHeader: { type: apiKey, in: header, name: x-api-key }
  parameters:
    XClient: { name: x-client, in: header, required: true, schema: { type: string } }
    XApiKey: { name: x-api-key, in: header, required: true, schema: { type: string } }
  schemas:
    AcceptedResponse:
      type: object
      required: [status]
      properties:
        status: { type: string, enum: [OK, Error] }
        status_message: { type: string }
        gu_id: { type: string, format: uuid }
    CommentPage:
      type: object
      required: [status, records]
      properties:
        status: { type: string, enum: [PROCESSING, COMPLETED, ERROR] }
        total_records: { type: integer }
        total_pages: { type: integer }
        page_size: { type: integer, default: 5000 }
        page_no: { type: integer }
        records:
          type: array
          items:
            $ref: "#/components/schemas/MacCommentRecord"
    MacCommentRecord:
      type: object
      properties:
        tango_entity_id: { type: string }
        request_number: { type: string, description: "Client Label 'MAC Number'." }
        ext_entity_number: { type: string, description: "Client Integration ID." }
        tango_comment_id: { type: string }
        comments_category: { type: string }
        comment_type: { type: string }
        subject: { type: string }
        comments: { type: string }
        created_by: { type: string }
        entity_type:
          type: string
          enum: [MACINTERNAL, MACEXTERNAL]
        last_update_date: { type: string, description: "MM/DD/YYYY." }
        last_updated_by: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
