openapi: 3.1.0
info:
  title: Tango Project Attributes Outbound API
  version: "0.3"
  description: |
    Async REST API for retrieving project attribute records updated since the
    last integration run (delta API). Two-call pattern: client GETs the delta
    endpoint to receive a `gu_id`, then GETs `/v1/batch/status` with the gu_id
    to paginate through records. Default page size is 5000; the response header
    indicates total pages and total records.

    A record is marked for export when any field other than internal identifiers
    (`project_id`, `brand_id`, `entity_id`, `template_id`, `budget_template_id`,
    `master_project_id`, `parent_location_id`) is updated.

    NOTE: the source design doc does not include a field-level data-mapping
    table — only `project_id` and `project_name` appear in the sample. The
    complete field set is unknown; this spec captures only the known fields
    and flags the gap in the companion 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: Project Attributes
  - name: Status
paths:
  /v1/projectmgmt/delta/projects:
    get:
      summary: Initiate delta project-attribute export (async)
      operationId: getProjectAttributesDelta
      tags: [Project Attributes]
      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"
              examples:
                ok:
                  value:
                    status: "OK"
                    status_message: ""
                    gu_id: "721c54c4-c7aa-4fa1-8fdfd6-c0cee161694d"
  /v1/batch/status:
    get:
      summary: Retrieve paginated project records by gu_id
      operationId: getProjectAttributesByGuId
      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
          description: 1-based page number; defaults to 1 if omitted.
      responses:
        "200":
          description: Paginated project records.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectAttributesPage"
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
    ProjectAttributesPage:
      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/ProjectRecord"
    ProjectRecord:
      type: object
      description: |
        Project attribute record. The source design doc includes only two fields
        in its sample (`project_id`, `project_name`) and does not provide a
        complete data-mapping table — additional fields are expected in
        production but undocumented. Treat `additionalProperties: true` so
        unknown attributes are not rejected.
      additionalProperties: true
      properties:
        project_id:
          type: integer
          description: Tango unique project identifier (immutable, does not trigger delta).
        project_name:
          type: string
security:
  - xClientHeader: []
    xApiKeyHeader: []
