openapi: 3.1.0
info:
  title: Tango Lease Outbound API
  version: "0.7"
  description: |
    Async **delta** REST API: client retrieves lease records that were created
    or updated since the last successful integration run. Information from
    Basic Info, Options & Terms, Contacts, Recurring Costs, and Obligations
    tabs is included. Two-call pattern with gu_id and pagination.

    NOTE: source design doc does not include a field-level mapping table; only
    a small sample (`lease_num`, `name`, `acct_type_code`) appears in the
    response example. Schema is permissive — runtime consumers should rely on
    the production payload as the source of truth and add Open Questions
    documented in the Markdown.
  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: Leases (Delta)
  - name: Status
paths:
  /v1/leasemgmt/delta/leases:
    get:
      summary: Initiate delta lease export (async)
      operationId: getLeasesDelta
      tags: [Leases (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 lease records by gu_id
      operationId: getLeasesByGuId
      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 lease records.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LeasePage"
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 }
    LeasePage:
      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/LeaseRecord"
    LeaseRecord:
      type: object
      description: |
        Lease record. Source doc shows only sample fields (`lease_num`,
        `name`, `acct_type_code`). `additionalProperties: true` keeps the
        schema permissive until a full mapping is added.
      additionalProperties: true
      properties:
        lease_num: { type: string, description: "Client-defined lease number." }
        name: { type: string }
        acct_type_code: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
