openapi: 3.1.0
info:
  title: Tango Customer / Supplier Outbound API
  version: "0.3"
  description: |
    Async **delta** REST API: client GETs customer or supplier records that
    were created/updated in Tango since the last integration run. Two-call
    pattern with `gu_id` and pagination. Null fields are omitted.

    A single record represents either a Customer or a Supplier — distinguished
    by the `record_type` field. The Tango supplier module produces both.

    NOTE on direction: source header lists `Source: CLIENT SYSTEM /
    Destination: TANGO` but the description says "exporting from Tango to the
    client" (outbound). Treated as outbound per the description; header
    discrepancy flagged in Open Questions.
  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: Customers & Suppliers (Delta)
  - name: Status
paths:
  /v1/suppliermgmt/delta/suppliers:
    get:
      summary: Initiate delta customer/supplier export (async)
      operationId: getSuppliersDelta
      tags: [Customers & Suppliers (Delta)]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      responses:
        "200":
          description: Async ack with gu_id.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
  /v1/batch/status:
    get:
      summary: Retrieve paginated customer/supplier records by gu_id
      operationId: getSuppliersByGuId
      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 records.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierPage"
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 }
    SupplierPage:
      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, default: 1 }
        records:
          type: array
          items:
            $ref: "#/components/schemas/SupplierRecord"
    SupplierRecord:
      type: object
      properties:
        supplier_number: { type: string }
        supplier_type:
          type: string
          enum: [LEASE, PROJECT, ALL]
        record_type:
          type: string
          description: Identifier for Customer or Supplier record (e.g., `Customer`, `Supplier`).
        legal_entity_type:
          type: string
          description: e.g., `Company`, `Person`.
        supplier_first_name:
          type: string
          description: Populated for Person records.
        supplier_last_name:
          type: string
          description: Populated for Person records.
        supplier_site_name: { type: string }
        supplier_site_number: { type: string }
        supplier_site_type:
          type: string
          description: Client-defined vendor types (Lessee, Payee, Tenant, etc.).
        primary_site: { type: string, description: "Y/N." }
        is_payee: { type: string, description: "Y/N." }
        payment_term: { type: string }
        supplier_rating: { type: number }
        Partner:
          type: string
          description: |
            Source mapping uses PascalCase `Partner` (and `Prequalified`,
            `City`, `State`, `Zip`, `Country`, `Status`, `Email`, `Fax`)
            while sample JSON uses lowercase. Preserved per mapping —
            confirm wire format.
        Prequalified: { type: string }
        address1: { type: string }
        address2: { type: string }
        address3: { type: string }
        City: { type: string }
        State: { type: string }
        Zip: { type: string }
        Country:
          type: string
          description: 3-letter country code (e.g., `USA`).
        Status:
          type: string
          enum: [Active, Inactive]
        Email: { type: string, format: email }
        contact_person: { type: string }
        business_phone: { type: string }
        Fax: { type: string }
        cell_phone: { type: string }
        payment_method: { type: string }
        tax_id: { type: string }
        bank_routing: { type: string }
        bank_account: { type: string }
        payment_email: { type: string, format: email }
        payment_comments: { type: string }
        effective_date: { type: string, description: "MM/DD/YYYY." }
        creation_date: { type: string, description: "TIMESTAMP." }
        created_by: { type: string }
        last_update_date: { type: string, description: "TIMESTAMP." }
        last_updated_by: { type: string }
        insert_update_flag:
          type: string
          enum: [I, U]
          description: "`I` = new record, `U` = update to existing."
        ein_ssn:
          type: string
          description: |
            **Encrypted string** — Tango shares the decryption key with the
            client separately. Treat as a sensitive PII field on the wire.
        c_ext_attr01: { type: string }
        c_ext_attr02: { type: string }
        c_ext_attr03: { type: string }
        c_ext_attr04: { type: string }
        c_ext_attr05: { type: string }
        c_ext_lov1: { type: string }
        c_ext_lov2: { type: string }
        c_ext_lov3: { type: string }
        c_ext_lov4: { type: string }
        c_ext_lov5: { type: string }
        n_ext_attr01: { type: number }
        n_ext_attr02: { type: number }
        n_ext_attr03: { type: number }
        n_ext_attr04: { type: number }
        n_ext_attr05: { type: number }
security:
  - xClientHeader: []
    xApiKeyHeader: []
