openapi: 3.1.0
info:
  title: Tango PO Outbound
  version: "0.5"
  description: |
    SFTP file-based outbound integration. Tango exports approved Purchase Order
    (PO) header + detail rows as a pipe-delimited text file. Source design doc
    does not annotate required fields, so the schema lists none as required.

    `PO_ID` is the Tango unique identifier and is the reconciliation key — the
    client round-trips it in the PO Inbound file.
  x-direction: outbound
  x-source: Tango
  x-destination: Client System
  x-transport: sftp
  x-file-format: pipe-delimited text (.txt)
  x-file-naming-convention: "{ClientName}_poout_MMDDYYYYHHMMSS.txt"
servers:
  - url: sftp://sftp.tangoanalytics.com
    description: Production SFTP host
    x-environment: production
    x-path: /outbound/PO
  - url: sftp://sftpdev.tangoanalytics.com
    description: Test SFTP host (SIT/UAT)
    x-environment: test
    x-path: /outbound/PO
tags:
  - name: PO Outbound
paths:
  /outbound/PO:
    post:
      summary: Drop approved PO file at SFTP path
      description: |
        Virtual operation. Tango selects approved POs (excluding zero-dollar lines)
        and writes them to the file. After writing, the prior file is moved to
        `Processed/<timestamp>` and exported POs are flagged `Exported`.
      operationId: deliverPOOutboundFile
      tags: [PO Outbound]
      requestBody:
        required: true
        content:
          text/plain:
            schema:
              type: string
              format: binary
              x-record-schema:
                $ref: "#/components/schemas/POOutboundRow"
      responses:
        "200":
          description: File delivered.
components:
  securitySchemes:
    sftpUserPassword:
      type: http
      scheme: basic
      description: SFTP user/password — values not specified in the source design doc.
  schemas:
    POOutboundRow:
      type: object
      description: One pipe-delimited row from the PO Outbound file. Required-field annotations are absent in the source.
      properties:
        PO_ID:
          type: number
          description: Tango unique identifier; reconciliation key for PO Inbound.
        PO_NUMBER:
          type: string
        PROJECT_NUMBER:
          type: string
        PO_TYPE:
          type: string
          description: Lookup field.
        SUPPLIER_NUMBER:
          type: string
        SUPPLIER_SITE:
          type: string
        PAYMENT_TERMS:
          type: string
          description: Lookup field.
        PO_AMOUNT:
          type: string
          description: Source labels NUMBER values as VARCHAR data type — preserved as-is.
        RETAINAGE_PCT:
          type: string
        CURRENCY:
          type: string
          description: Lookup field.
        COMMENTS:
          type: string
        DUE_DATE:
          type: string
          description: "MM/DD/YYYY."
        ISSUE_DATE:
          type: string
          description: "MM/DD/YYYY."
        ISSUED_BY:
          type: string
        LEGAL_COMPANY:
          type: string
        BUYER_CODE:
          type: string
        BUYER_NAME:
          type: string
        C_EXT_LOV1:
          type: string
          description: Lookup field.
        ITEM_NO:
          type: string
        QTY:
          type: string
        RATE:
          type: string
        UOM:
          type: string
          description: Lookup field.
        LINE_AMOUNT:
          type: string
        DELIVERY_DATE:
          type: string
          description: "MM/DD/YYYY."
        ACCOUNT_CODE:
          type: string
          example: "0938921"
        SEGMENT1: { type: string }
        SEGMENT2: { type: string }
        SEGMENT3: { type: string }
        SEGMENT4: { type: string }
        SEGMENT5: { type: string }
        SEGMENT6: { type: string }
        LINE_COMMENTS:
          type: string
security:
  - sftpUserPassword: []
