openapi: 3.1.0
info:
  title: Tango AR Outbound API
  version: "1.0"
  description: |
    Async REST API: client GETs approved receivables (billings) from Tango.
    Two-call pattern (gu_id ack → paginated `/v1/batch/status` GET). Page size
    5000.
  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: AR Receivables
  - name: Status
paths:
  /v1/leasemgmt/receivables:
    get:
      summary: Initiate approved receivable export (async)
      operationId: getARReceivablesBatch
      tags: [AR Receivables]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
        - in: query
          name: calendar_year
          required: false
          schema: { type: integer }
        - in: query
          name: calendar_month
          required: false
          schema: { type: integer, minimum: 1, maximum: 12 }
        - in: query
          name: country
          required: false
          schema: { type: string }
        - in: query
          name: financial_group
          required: false
          schema: { type: string }
      responses:
        "200":
          description: Async ack.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
  /v1/batch/status:
    get:
      summary: Retrieve paginated receivable records by gu_id
      operationId: getARReceivablesByGuId
      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 receivable records.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReceivablePage"
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 }
    ReceivablePage:
      type: object
      required: [status, total_records, total_pages, page_size, page_no, 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/ReceivableRecord"
    ReceivableRecord:
      type: object
      required:
        - rec_id
        - lease_num
        - status
        - term_status
        - loc_num
        - cus_num
        - category
        - type
        - year
        - month
      properties:
        rec_id:
          type: number
          description: Tango unique receivable identifier.
        lease_num: { type: string }
        status: { type: string, description: "Lease status." }
        term_status: { type: string }
        loc_num: { type: string }
        cus_num: { type: string, description: "Customer number (supplier site)." }
        sys_gen_flag: { type: string }
        category: { type: string }
        type: { type: string }
        year:
          type: string
          description: Calendar year (per the data-mapping comment).
        month:
          type: string
          description: Calendar month.
        comments: { type: string }
        effective_date: { type: string, description: "MM/DD/YYYY." }
        applies_from_date: { type: string, description: "MM/DD/YYYY." }
        applies_to_date: { type: string, description: "MM/DD/YYYY." }
        inv_id: { type: string }
        currency: { type: string }
        receivable_currency: { type: string }
        net: { type: number }
        total_tax: { type: number }
        gross: { type: number }
        tax_rate: { type: number }
        tax1: { type: number }
        tax2: { type: number }
        receivable_status: { type: string }
        remit_message: { type: string }
        inv_num: { type: string }
        due_date: { type: string, description: "MM/DD/YYYY." }
        creation_date: { type: string, description: "MM/DD/YYYY." }
        gl_acc: { type: string }
        country: { type: string }
        legal_entity: { type: string }
        seg1: { type: string }
        seg2: { type: string }
        seg3: { type: string }
        seg4: { type: string }
        seg5: { type: string }
        seg6: { type: string }
        seg1_gl: { type: string }
        segt2_gl:
          type: string
          description: "Typo in source: 'segt2_gl' instead of 'seg2_gl' (preserved verbatim)."
        seg3_gl: { type: string }
        seg4_gl: { type: string }
        seg5_gl: { type: string }
        seg6_gl: { type: string }
        extattribute1: { type: string }
        extattribute2: { type: string }
        extattribute3: { type: string }
        extattribute4: { type: string }
        extattribute5: { type: string }
        extattribute6: { type: string }
        extattribute7: { type: string }
        extattribute8: { type: string }
        extattribute9: { type: string }
        extattribute10: { type: string }
        extattribute11: { type: string }
        extattribute12: { type: string }
        extattribute13: { type: string }
        extattribute14: { type: string }
        extattribute15: { type: string }
        supplier_number: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
