openapi: 3.1.0
info:
  title: Macro Weekly Desk Institutional Research API
  version: 1.0.0
  description: >
    Programmatic REST API for deterministic 5-period SEC EDGAR financials, DCF fair value and
    5x5 sensitivity matrices, peer valuation comps, 3-year dividend-adjusted TSR, and print-ready
    8-page US Letter PDF equity valuation monographs.
  contact:
    name: Macro Weekly Desk
    url: https://macroweeklydesk.com/equity-deep-dive.html
    email: editor@macroweeklydesk.com
servers:
  - url: https://api.macroweeklydesk.com
    description: Production Institutional API Gateway
security:
  - BearerAuth: []
paths:
  /v1/equity/reports:
    post:
      summary: Queue single-ticker or batch equity valuation report(s)
      operationId: createEquityReport
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: Optional client-supplied key to safely deduplicate retries.
          schema:
            type: string
            maxLength: 128
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ticker:
                  type: string
                  example: COST
                tickers:
                  type: array
                  description: Batch array (Platform & Enterprise tiers, up to 25 symbols).
                  items:
                    type: string
                  example: ["COST", "WMT", "TGT"]
                wacc:
                  type: number
                  minimum: 0.03
                  maximum: 0.25
                  example: 0.085
                terminal_g:
                  type: number
                  minimum: 0.0
                  maximum: 0.06
                  example: 0.025
                horizon_months:
                  type: integer
                  minimum: 9
                  maximum: 36
                  example: 18
                peers:
                  type: array
                  maxItems: 5
                  items:
                    type: string
                  example: ["BJ", "WMT", "TGT"]
                webhook_url:
                  type: string
                  format: uri
                  description: HTTPS endpoint to receive HMAC-SHA256 signed completion events.
                  example: https://desk.example.com/webhooks/mwd
      responses:
        "202":
          description: Report job(s) queued for asynchronous execution.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  job_id:
                    type: string
                    example: job_9xK2mQp7Lw4R
                  ticker:
                    type: string
                    example: COST
                  status:
                    type: string
                    enum: [queued]
                  poll_url:
                    type: string
                    format: uri
        "400":
          description: Invalid ticker or parameter value.
        "401":
          description: Missing, invalid, or revoked Bearer API key.
        "403":
          description: Feature not enabled on license tier or client IP not allowlisted.
        "429":
          description: Monthly report quota exceeded.
  /v1/equity/reports/{job_id}:
    get:
      summary: Poll report job status and retrieve signed artifact URLs
      operationId: getEquityReportStatus
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Current job status and signed artifact links when ready.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  job_id:
                    type: string
                  ticker:
                    type: string
                  status:
                    type: string
                    enum: [queued, running, ready, failed]
                  duration_ms:
                    type: integer
                    nullable: true
                  created_at:
                    type: string
                    format: date-time
                  completed_at:
                    type: string
                    format: date-time
                    nullable: true
                  artifacts:
                    type: object
                    properties:
                      pdf_url:
                        type: string
                        format: uri
                      html_url:
                        type: string
                        format: uri
                      json_url:
                        type: string
                        format: uri
                      expires_in_seconds:
                        type: integer
                        example: 900
        "404":
          description: Job not found for this API client.
  /v1/equity/reports/{job_id}/json:
    get:
      summary: Retrieve schema-validated EquityDeepDive JSON payload
      operationId: getEquityReportJson
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Full deterministic valuation, peer comps, 3Y TSR, and narrative JSON.
          content:
            application/json:
              schema:
                type: object
        "409":
          description: Job is not yet ready.
  /v1/macro/issues/latest:
    get:
      summary: Retrieve latest Weekly Macro Desk structured issue JSON
      operationId: getLatestMacroIssue
      responses:
        "200":
          description: Structured cross-asset macro issue JSON.
          content:
            application/json:
              schema:
                type: object
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: mwd_live_...
