openapi: 3.1.0
info:
  title: Y2 Intelligence Platform API
  version: 1.0.0
  description: |
    Use the Y2 API to read intelligence, manage workspace resources, and run Agent Y2.

    ## Authentication

    Send a scoped key in the `Authorization: Bearer` header.
    [Create a key](https://y2.dev/docs/api/create-key) in the workspace that owns the requested resources.

    Supported read operations also accept [x402 payments](https://y2.dev/docs/api/x402).
    Agent Y2 requires an API key. Receipt lookup is public.
    Each operation declares its authentication methods in `security`, `x-required-scopes`, and `x-x402`.

    ## Limits and responses

    New keys require Pro or Elite. Eligible existing Lite keys retain their historical limits.
    Limits apply per key and to the workspace or legacy user total.
    See [authentication reference](https://y2.dev/docs/api/authentication) for scopes, plans, and rate limits.
    See [response reference](https://y2.dev/docs/api/responses) for errors, pagination, and version headers.

  license:
    name: Proprietary
    url: https://y2.dev/terms
  contact:
    name: Y2 Support
    url: https://y2.dev/docs/community/contributing

servers:
  - url: https://api.y2.dev/api/v1
    description: Y2 Production API (v1)
  - url: https://data.y2.dev/api/v1
    description: Y2 Convex Data API (v1)
  - url: https://api.y2.dev
    description: "Y2 Production API (v2 root: Intel surface)"

security:
  - bearerAuth: []

tags:
  - name: Reports
    description: Report retrieval, text, audio, signals, and ontology graphs
  - name: Profiles
    description: Profile subscriptions, ownership, and configuration
  - name: Projects
    description: Owner-private intelligence workspaces in the API key workspace
  - name: Automations
    description: Durable Agent Y2 Automation definitions and run history
  - name: Webhooks
    description: Webhook configuration for paid workspaces
  - name: Subscriptions
    description: Subscription delivery management
  - name: News
    description: News Terminal items, feeds, and AI recaps
  - name: OSINT
    x-displayName: OSINT
    description: Situation Room events, feeds, country data, and source health
  - name: Intel
    description: |
      Read incidents, entities, markets, financial indicators, disclosures, signals, and cyber graphs.
      The base URL is `https://api.y2.dev/api/v2`.
      Check each operation for accepted scopes and x402 support.
  - name: Ontology Ledger
    description: |
      Read and append workspace ledger records.
      Records contain subjects, designators, observations, and claims with verification states and valid-time intervals.
      Read a subject at a record time and a valid time. Export records as NDJSON or STIX 2.1.
      Use a workspace-bound key with `ledger:read` or `ledger:write`. x402 is not supported.
  - name: Global Knowledge
    description: |
      Search authorized Y2 reports and signal assessments.
      Requires an API key. Does not support x402.
  - name: Payments
    description: x402 receipt lookup
  - name: Agent Y2
    description: API-key streams for the preconfigured Y2 Agent and compatibility endpoint

paths:
  /agent-y2/chat/stream:
    post:
      operationId: streamAgentY2Chat
      summary: Stream a Y2 Agent response
      description: |
        Streams the Y2 Agent used by the app copilot.
        Requests use the workspace tools, permissions, shared Agent Y2 credits, and API-key limits.

        This is not a general multi-model API. v1 callers cannot choose models,
        use onboarding mode, or attach files. Transcript history supplies
        user/assistant context but cannot override the fixed system instructions.

        v1 requires an API key and does not support x402. Both Agent Y2 routes share
        a throttle of 5 requests/minute and 100/day per key, plus 10 requests/minute
        and 250/day per user or workspace. A `402` indicates subscription,
        Agent Y2 credit, or upstream-provider credit exhaustion, not an x402 challenge.
      tags: [Agent Y2]
      security:
        - bearerAuth: []
      x-required-scopes: [agent:y2]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AgentY2StreamRequest"
            example:
              messages:
                - role: user
                  parts:
                    - type: text
                      text: What changed in cyber risk this week?
              metadata:
                source: customer_crm
                externalUserId: analyst-42
      responses:
        "200":
          description: Vercel AI SDK UI message stream
          headers:
            X-Thread-Id:
              description: Y2 chat thread ID for continuing the conversation
              schema:
                type: string
            X-Y2-Agent:
              description: Agent identifier
              schema:
                type: string
                example: y2
            X-Y2-Agent-Mode:
              description: Agent mode
              schema:
                type: string
                example: copilot
            X-Y2-Agent-RateLimit-Limit-Minute:
              description: Agent Y2 requests allowed per minute for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Remaining-Minute:
              description: Agent Y2 requests remaining this minute for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Limit-Day:
              description: Agent Y2 requests allowed per day for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Remaining-Day:
              description: Agent Y2 requests remaining today for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Limit-Minute:
              description: Agent Y2 requests allowed per minute for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Remaining-Minute:
              description: Agent Y2 requests remaining this minute for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Limit-Day:
              description: Agent Y2 requests allowed per day for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Remaining-Day:
              description: Agent Y2 requests remaining today for the user or workspace
              schema:
                type: integer
          content:
            text/event-stream:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/AgentY2PaymentRequired"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /chat/completions:
    post:
      operationId: createY2OpenAIChatCompletion
      summary: OpenAI-compatible Agent Y2 chat stream
      description: |
        Routes OpenAI-style chat completions requests to Agent Y2 and streams text
        or client-side tool-call responses to compatible clients.

        v1 supports `messages`, `stream: true`, optional `model` set to `y2-agent`
        or `agent-y2`, optional `threadId`, optional bounded `metadata`, and bounded
        OpenAI function tools. Arbitrary models are unsupported. Without client
        tools, Agent Y2 keeps its fixed Copilot instructions and Y2 tools. A non-empty
        `tools` array selects harness mode. System and developer messages become client instructions.
        Tool-call history is preserved. The client executes returned tool calls.

        v1 requires an API key and does not support x402. Both Agent Y2 routes share
        a throttle of 5 requests/minute and 100/day per key, plus 10 requests/minute
        and 250/day per user or workspace. A `402` indicates subscription,
        Agent Y2 credit, or upstream-provider credit exhaustion, not an x402 challenge.
      tags: [Agent Y2]
      security:
        - bearerAuth: []
      x-required-scopes: [agent:y2]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OpenAICompatibleChatCompletionRequest"
            example:
              model: y2-agent
              stream: true
              messages:
                - role: user
                  content: Summarize the latest Y2 platform capabilities.
      responses:
        "200":
          description: OpenAI-style streaming chat completion chunks
          headers:
            X-Thread-Id:
              description: Y2 chat thread ID for continuing the conversation
              schema:
                type: string
            X-Y2-Agent-Mode:
              description: "copilot for fixed Agent Y2 tools or harness for client-side function tools"
              schema:
                type: string
                enum: [copilot, harness]
            X-Y2-Agent-RateLimit-Limit-Minute:
              description: Agent Y2 requests allowed per minute for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Remaining-Minute:
              description: Agent Y2 requests remaining this minute for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Limit-Day:
              description: Agent Y2 requests allowed per day for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Remaining-Day:
              description: Agent Y2 requests remaining today for this API key
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Limit-Minute:
              description: Agent Y2 requests allowed per minute for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Remaining-Minute:
              description: Agent Y2 requests remaining this minute for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Limit-Day:
              description: Agent Y2 requests allowed per day for the user or workspace
              schema:
                type: integer
            X-Y2-Agent-RateLimit-Account-Remaining-Day:
              description: Agent Y2 requests remaining today for the user or workspace
              schema:
                type: integer
          content:
            text/event-stream:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/AgentY2PaymentRequired"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports:
    get:
      operationId: listReports
      summary: List intelligence reports
      description: |
        Lists reports for the user's subscribed profiles by generation date,
        newest first.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T4_PREMIUM_LIST
        price: "$0.05"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
        - name: profileId
          in: query
          description: Filter by stable public profile ID (`prf_...`).
          schema:
            type: string
            pattern: "^prf_[a-f0-9]{24}$"
            example: "prf_0123456789abcdef01234567"
        - name: limit
          in: query
          description: Maximum number of reports to return for this page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
      responses:
        "200":
          description: List of reports
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports/{reportId}:
    get:
      operationId: getReport
      summary: Get a report
      description: |
        Returns a compact report by default. Use bounded `include` values or
        `view=agent`. Request `text/markdown` for the canonical Markdown representation.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T4_PREMIUM_SINGLE
        price: "$0.25"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: include
          in: query
          description: Comma-separated `content,sources,signals,graph,audio` expansions.
          schema:
            type: string
        - name: view
          in: query
          description: Compact projection optimized for grounded agent context.
          schema:
            type: string
            enum: [agent]
        - name: format
          in: query
          description: Explicit representation override.
          schema:
            type: string
            enum: [markdown]
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
            example: "rpt_0123456789abcdef01234567"
      responses:
        "200":
          description: Report details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportDetailResponse"
            text/markdown:
              schema:
                type: string
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports/{reportId}/signals:
    get:
      operationId: getReportSignals
      summary: Get report emergent signals
      description: |
        Returns structured emergent SIGINT signals inferred from a report. Reports
        created before signal extraction return an empty `signals` array.
        Requires the `reports:read` scope.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
      responses:
        "200":
          description: Structured report emergent signals
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportSignalsResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports/{reportId}/graph:
    get:
      operationId: getReportGraph
      summary: Get report ontology graph
      description: |
        Returns the report's bounded ontology graph: report-local nodes, edges,
        incident anchors, citations, and counts. Reports created before graph
        extraction return `graph: null` with zero counts.
        Requires the `reports:read` scope.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
      responses:
        "200":
          description: Report ontology graph snapshot
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportGraphResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports/{reportId}/audio:
    get:
      operationId: getReportAudio
      summary: Get report audio
      description: |
        Returns audio file metadata or redirects to the CDN URL.
        Requires the `reports:audio` scope.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:audio]
      x-x402:
        enabled: true
        tier: T4_PREMIUM_AUDIO
        price: "$0.50"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
        - name: redirect
          in: query
          description: When true, redirects with `302` to the audio CDN URL
          schema:
            type: boolean
            default: false
      responses:
        "200":
          description: Audio metadata
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AudioResponse"
        "302":
          description: Redirect to audio CDN URL
          headers:
            Location:
              description: CDN URL for audio file
              schema:
                type: string
                format: uri
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Report not found or no audio available
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /reports/{reportId}/text:
    get:
      operationId: getReportText
      summary: Get report as plain text
      description: |
        Returns the report content stripped of all HTML tags as plain text,
        along with word count and estimated reading time.
        Requires the `reports:read` scope.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T4_PREMIUM_SINGLE
        price: "$0.25"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
      responses:
        "200":
          description: Plain text report content
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportTextResponse"
            text/plain:
              schema:
                type: string
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Report not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /reports/{reportId}/audio-text:
    get:
      operationId: getReportAudioText
      summary: Get TTS-preprocessed report text
      description: |
        Returns the report content preprocessed for text-to-speech synthesis.
        Applies pronunciation normalization for acronyms, currency, and percentages.
        Strips HTML and Markdown. Adds branding intro/outro text. Cartesia TTS
        generation uses this pipeline.
        Requires the `reports:read` scope.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [Reports]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [reports:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: reportId
          in: path
          required: true
          description: Stable Y2 public report ID (`rpt_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
      responses:
        "200":
          description: TTS-preprocessed report text
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReportAudioTextResponse"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Report not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /profiles:
    get:
      operationId: listProfiles
      summary: List subscribed profiles
      description: |
        Lists active subscriptions in the API key's workspace, with profile
        details and delivery preferences. Requires current workspace membership.
        Viewers can read. Private profiles must still belong to that workspace.
        Results are ordered by subscription creation time, newest first. Each
        request examines at most `limit` subscription rows. The optional text
        filter matches name, topic, or tags without regard to case and may return
        a sparse or empty page. Follow `meta.page.nextCursor` while `hasMore` is
        true, including when `data` is empty. Cursors are bound to the filter.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:read]
      parameters:
        - name: limit
          in: query
          description: Maximum subscription rows examined in one page.
          schema: { type: integer, minimum: 1, maximum: 50, default: 20 }
        - $ref: "#/components/parameters/Cursor"
        - name: q
          in: query
          description: Case-insensitive substring in profile name, topic, or tags.
          schema: { type: string, minLength: 1, maxLength: 200 }
      responses:
        "200":
          description: List of subscribed profiles
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    post:
      operationId: createProfile
      summary: Create an intelligence profile
      description: |
        Creates an `active` intelligence profile owned by the authenticated user
        with the supplied configuration.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:write]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileCreateRequest"
      responses:
        "201":
          description: Profile created
          headers:
            Location:
              description: Canonical URL of the new profile.
              schema: { type: string }
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
            Idempotency-Key:
              description: Echo of the supplied retry key.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileCreateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /profiles/{profileId}:
    get:
      operationId: getProfile
      summary: Get a subscribed profile
      description: |
        Returns a profile from an active subscription in the API key's workspace.
        Requires current workspace membership, including the viewer role. Private
        profiles must still belong to the selected workspace. Community and global
        profiles require an active workspace subscription. Missing, unsubscribed,
        and inaccessible profiles all return 404. Only stable public IDs are accepted.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:read]
      parameters:
        - name: profileId
          in: path
          required: true
          description: Stable public profile ID returned by listProfiles.
          schema: { type: string, pattern: "^prf_[a-f0-9]{24}$" }
      responses:
        "200":
          description: Authorized profile details
          headers:
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileDetailResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    put:
      operationId: updateProfile
      summary: Update a profile (full replacement)
      description: |
        Replaces every mutable field on a profile owned by the authenticated user.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:write]
      parameters:
        - name: profileId
          in: path
          required: true
          description: Stable public profile ID. Legacy IDs remain accepted during the migration window.
          schema:
            type: string
            pattern: "^prf_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/IfMatch"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileReplaceRequest"
      responses:
        "200":
          description: Profile updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileUpdateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    patch:
      operationId: patchProfile
      summary: Update a profile (partial)
      description: |
        Updates supplied mutable fields on a profile owned by the authenticated
        user. Omitted fields remain unchanged.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:write]
      parameters:
        - name: profileId
          in: path
          required: true
          description: Stable public profile ID. Legacy IDs remain accepted during the migration window.
          schema:
            type: string
            pattern: "^prf_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/IfMatch"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileUpdateRequest"
      responses:
        "200":
          description: Profile updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileUpdateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    delete:
      operationId: deleteProfile
      summary: Delete a profile
      description: |
        Permanently deletes a profile owned by the authenticated user and all its
        subscriptions. This action cannot be undone.
      tags: [Profiles]
      security:
        - bearerAuth: []
      x-required-scopes: [profiles:write]
      parameters:
        - name: profileId
          in: path
          required: true
          description: Stable public profile ID. Legacy IDs remain accepted during the migration window.
          schema:
            type: string
            pattern: "^prf_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/IfMatch"
      responses:
        "204":
          description: Profile deleted. The response has no body.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  # =========================================================================
  # Projects
  # =========================================================================
  /projects:
    get:
      operationId: listProjects
      summary: List owned Projects
      description: |
        Lists owner-private Projects in the API key workspace. Results are bounded,
        ordered by recent activity, and traversable with an opaque cursor.
      tags: [Projects]
      security:
        - bearerAuth: []
      x-required-scopes: [projects:read]
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - name: status
          in: query
          schema:
            $ref: "#/components/schemas/ProjectStatus"
            default: active
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 20
      responses:
        "200":
          description: Bounded Project list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    post:
      operationId: createProject
      summary: Create a Project
      description: Creates an active owner-private Project in the API key workspace.
      tags: [Projects]
      security:
        - bearerAuth: []
      x-required-scopes: [projects:write]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectCreateRequest"
      responses:
        "201":
          description: Project created
          headers:
            Location:
              description: Canonical URL of the new Project.
              schema: { type: string }
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
            Idempotency-Key:
              description: Echo of the supplied retry key.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectMutationResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /projects/{projectId}:
    get:
      operationId: getProject
      summary: Get a Project
      description: Returns one Project and its current lifecycle state in the API key's workspace.
      tags: [Projects]
      security:
        - bearerAuth: []
      x-required-scopes: [projects:read]
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            pattern: "^prj_[a-f0-9]{24}$"
      responses:
        "200":
          description: Project details
          headers:
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    patch:
      operationId: patchProject
      summary: Update, archive, or restore a Project
      description: |
        Applies a partial Project update. Set `status` to `archived` or `active`
        for the reversible lifecycle transition. Archiving pauses active bound Automations.
      tags: [Projects]
      security:
        - bearerAuth: []
      x-required-scopes: [projects:write]
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            pattern: "^prj_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/IfMatch"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectPatchRequest"
      responses:
        "200":
          description: Project updated
          headers:
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectMutationResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  # =========================================================================
  # Automations
  # =========================================================================
  /automations:
    get:
      operationId: listAutomations
      summary: List Automation definitions
      description: |
        Lists owner-private Automation definitions in the API key workspace.
        Traverse the bounded result set with the returned opaque cursor.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:read]
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - name: projectId
          in: query
          schema:
            type: string
            pattern: "^prj_[a-f0-9]{24}$"
        - name: status
          in: query
          schema:
            $ref: "#/components/schemas/AutomationStatus"
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 30
      responses:
        "200":
          description: Bounded Automation list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    post:
      operationId: createAutomation
      summary: Create an Automation
      description: Creates a draft, active, or paused Agent Y2 Automation.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:write]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationCreateRequest"
      responses:
        "201":
          description: Automation created
          headers:
            Location:
              description: Canonical URL of the new Automation.
              schema: { type: string }
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
            Idempotency-Key:
              description: Echo of the supplied retry key.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationMutationResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /automations/{automationId}:
    get:
      operationId: getAutomation
      summary: Get an Automation definition
      description: Returns one Automation definition and its current lifecycle state in the API key's workspace.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:read]
      parameters:
        - name: automationId
          in: path
          required: true
          schema:
            type: string
            pattern: "^atm_[a-f0-9]{24}$"
      responses:
        "200":
          description: Automation details
          headers:
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    patch:
      operationId: patchAutomation
      summary: Update or archive an Automation
      description: |
        Applies a partial definition update or a status-only lifecycle change.
        Archived Automations cannot be resumed or edited.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:write]
      parameters:
        - name: automationId
          in: path
          required: true
          schema:
            type: string
            pattern: "^atm_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/IfMatch"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationPatchRequest"
      responses:
        "200":
          description: Automation updated
          headers:
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationMutationResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /automations/{automationId}/runs:
    get:
      operationId: listAutomationRuns
      summary: List Automation run history
      description: Traverse bounded Automation run history with the returned opaque cursor.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:read]
      parameters:
        - name: automationId
          in: path
          required: true
          schema:
            type: string
            pattern: "^atm_[a-f0-9]{24}$"
        - $ref: "#/components/parameters/Cursor"
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 30
      responses:
        "200":
          description: Bounded run history
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRunListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    post:
      operationId: runAutomation
      summary: Request a manual Automation run
      description: |
        Queues an idempotent manual run request for an active Automation. The
        `Idempotency-Key` header is required and identifies duplicate requests.
      tags: [Automations]
      security:
        - bearerAuth: []
      x-required-scopes: [automations:write]
      parameters:
        - name: automationId
          in: path
          required: true
          schema:
            type: string
            pattern: "^atm_[a-f0-9]{24}$"
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 8
            maxLength: 200
            pattern: "^[A-Za-z0-9._:-]+$"
      responses:
        "202":
          description: Run request accepted
          headers:
            Idempotency-Key:
              description: Echo of the supplied retry key.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRunRequestResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  # =========================================================================
  # Webhooks
  # =========================================================================
  /webhooks:
    get:
      operationId: listWebhooks
      summary: List webhook configurations
      description: |
        Lists the authenticated user's webhook configurations. Masks secrets.
      tags: [Webhooks]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      responses:
        "200":
          description: Webhook configurations
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookListResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    post:
      operationId: createWebhook
      summary: Create a webhook configuration
      description: |
        Creates a webhook configuration. Requires a paid workspace plan with webhook
        access. The URL must use HTTPS and pass SSRF validation.
      tags: [Webhooks]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookCreateRequest"
      responses:
        "201":
          description: Webhook configuration created
          headers:
            Location:
              description: Canonical URL of the new webhook configuration.
              schema: { type: string }
            ETag:
              description: Strong validator for the returned representation.
              schema: { type: string }
            Idempotency-Key:
              description: Echo of the supplied retry key.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookCreateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /webhooks/{webhookId}:
    put:
      operationId: updateWebhook
      summary: Update a webhook configuration
      description: |
        Replaces mutable webhook configuration fields. `name` and `url` are required.
        Omitted secret and headers are cleared. Omitted isActive preserves the current status.
        Enabling requires a successful test of the same configuration within 15 minutes.
      tags: [Webhooks]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      parameters:
        - name: webhookId
          in: path
          required: true
          schema:
            type: string
            pattern: "^whk_[a-f0-9]{24}$"
          description: Stable public webhook configuration ID.
        - $ref: "#/components/parameters/IfMatch"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookReplaceRequest"
      responses:
        "200":
          description: Webhook configuration updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookUpdateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: "WEBHOOK_TEST_REQUIRED: test the current configuration successfully before enabling."
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

    delete:
      operationId: deleteWebhook
      summary: Delete a webhook configuration
      description: |
        Deletes a webhook configuration. Returns `409` if any subscription uses it.
      tags: [Webhooks]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      parameters:
        - name: webhookId
          in: path
          required: true
          schema:
            type: string
            pattern: "^whk_[a-f0-9]{24}$"
          description: Stable public webhook configuration ID.
        - $ref: "#/components/parameters/IfMatch"
      responses:
        "204":
          description: Webhook configuration deleted. The response has no body.
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /webhooks/{webhookId}/test:
    post:
      operationId: testWebhook
      summary: Test a webhook endpoint
      description: |
        Sends a test payload to the webhook URL, including disabled destinations.
        Returns `422` if the endpoint responds with an error. A successful response
        returns the updated webhook configuration's ETag for a subsequent enabling PUT.
      tags: [Webhooks]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      parameters:
        - name: webhookId
          in: path
          required: true
          schema:
            type: string
            pattern: "^whk_[a-f0-9]{24}$"
          description: Stable public webhook configuration ID.
      responses:
        "200":
          description: Webhook test successful
          headers:
            ETag:
              description: Strong validator for the webhook configuration after verification. Use it in If-Match when enabling delivery.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookTestResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          description: Webhook test failed (endpoint returned error)
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  # =========================================================================
  # Subscriptions
  # =========================================================================
  /subscriptions/{subscriptionId}/delivery:
    patch:
      operationId: updateDelivery
      summary: Update subscription delivery method
      description: |
        Changes a subscription's delivery method. Setting `webhook` requires an
        active `webhookConfigId`. On plans with member seats, set `emailAudience`
        to `workspace` to email active workspace members.
      tags: [Subscriptions]
      security:
        - bearerAuth: []
      x-required-scopes: [webhooks:manage]
      parameters:
        - name: subscriptionId
          in: path
          required: true
          schema:
            type: string
            pattern: "^sub_[a-f0-9]{24}$"
          description: Stable public subscription ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeliveryUpdateRequest"
      responses:
        "200":
          description: Delivery method updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeliveryUpdateResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /news:
    get:
      operationId: listNews
      summary: List news items
      description: |
        Lists cached Y2 News Terminal items with topic filters and pagination.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [News]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [news:read]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: topics
          in: query
          description: |
            Comma-separated list of topics to filter by.
            Use `GET /news/feeds` to discover the current topic catalog.
            Default: crypto, geopolitics, macro, equities, ai, energy
          schema:
            type: string
            example: "crypto,ai_agents,bitcoin"
        - name: limit
          in: query
          description: Maximum number of items to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: countryCode
          in: query
          description: |
            Filter by canonical ISO 3166-1 alpha-2 country code. When supplied without
            `topics`, the query searches every News Terminal topic.
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: ES
        - $ref: "#/components/parameters/Cursor"
        - name: format
          in: query
          description: Use `ndjson` for row-oriented streaming output.
          schema:
            type: string
            enum: [json, ndjson]
      responses:
        "200":
          description: List of news items
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NewsListResponse"
            application/x-ndjson:
              schema:
                type: string
        "400":
          description: Invalid topics
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "503":
          description: News cache is initializing
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /news/recaps:
    get:
      operationId: listRecaps
      summary: List AI-generated recaps
      description: |
        Lists AI-generated recaps for selected topics and timeframe.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [News]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [news:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: topics
          in: query
          description: |
            Comma-separated list of topics.
            Use `GET /news/feeds` to discover the current topic catalog.
          schema:
            type: string
        - name: timeframe
          in: query
          description: Time period for recaps
          schema:
            $ref: "#/components/schemas/TimeframeEnum"
      responses:
        "200":
          description: Topic recaps
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecapResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"

  /news/feeds:
    get:
      operationId: listFeeds
      summary: List available news feeds
      description: |
        Lists news feed topics and descriptions.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [News]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [news:read]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      responses:
        "200":
          description: List of available feeds
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FeedListResponse"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"

  # ===========================================================================
  # OSINT Endpoints
  # ===========================================================================
  /osint/events:
    get:
      operationId: listOsintEvents
      summary: List threat events
      description: |
        Lists Situation Room threat events. Supports category and severity filters.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Temporality"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
        - name: category
          in: query
          description: Filter by event category
          schema:
            $ref: "#/components/schemas/OsintEventCategoryEnum"
        - name: severity
          in: query
          description: Filter by severity level
          schema:
            $ref: "#/components/schemas/OsintSeverityEnum"
        - name: limit
          in: query
          description: Maximum number of events to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
      responses:
        "200":
          description: List of OSINT threat events
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OsintEventListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/map:
    get:
      operationId: listOsintMapEvents
      summary: List map events with coordinates
      description: |
        Lists geolocated OSINT events for map display. Excludes events without
        coordinates.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: region
          in: query
          description: Filter by geographic region
          schema:
            $ref: "#/components/schemas/OsintRegionEnum"
        - name: limit
          in: query
          description: Maximum number of events to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 200
        - $ref: "#/components/parameters/Temporality"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of map events with coordinates
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OsintMapEventListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/cii:
    get:
      operationId: listCII
      summary: Conflict Indicators Index
      description: |
        Lists Conflict Indicators Index (CII) values with 0–100 scores and
        recent-change deltas. Supports region and category filters.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: region
          in: query
          description: Filter by geographic region
          schema:
            $ref: "#/components/schemas/OsintRegionEnum"
        - name: category
          in: query
          description: Filter by event category
          schema:
            $ref: "#/components/schemas/OsintEventCategoryEnum"
        - name: limit
          in: query
          description: Maximum number of items to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
      responses:
        "200":
          description: List of CII items
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CIIListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/countries/{countryCode}/brief:
    get:
      operationId: getCountryBrief
      summary: AI-generated intelligence brief
      description: |
        Returns a periodically generated, cached intelligence brief for a country.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: path
          required: true
          description: ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: "US"
      responses:
        "200":
          description: Intelligence brief for the country
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntelBriefResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Brief not available for this country
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/countries/{countryCode}/markets:
    get:
      operationId: getCountryStockIndex
      summary: Stock market index
      description: |
        Returns a country's primary stock index, weekly change, and currency.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: path
          required: true
          description: ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: "US"
      responses:
        "200":
          description: Stock market index for the country
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockIndexResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Stock-index data is not available for this country
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/countries/{countryCode}/predictions:
    get:
      operationId: getCountryPredictions
      summary: Prediction markets
      description: |
        Returns prediction-market probabilities and trading volumes for a country.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: path
          required: true
          description: ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: "US"
        - name: limit
          in: query
          description: Maximum number of predictions to return
          schema:
            type: integer
            minimum: 1
            maximum: 10
            default: 3
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
      responses:
        "200":
          description: Prediction markets for the country
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CountryPredictionMarketListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/countries/{countryCode}/news:
    get:
      operationId: getCountryNews
      summary: Country-specific news
      description: |
        Returns recent country news from the OSINT event pipeline.
        Uses the observation's indexed ISO country attribution, not countries merely
        mentioned or exposed to a regional event. Includes unexpired RSS, GDELT,
        ACLED, News Terminal, and Y2 report observations, excluding seismic and
        weather categories. Filters apply before pagination. Satellite detections
        do not consume the news result window. Results retain canonical observation IDs.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: path
          required: true
          description: ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: "US"
        - name: limit
          in: query
          description: Maximum number of news items to return
          schema:
            type: integer
            minimum: 1
            maximum: 20
            default: 8
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: Country-specific news items
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CountryNewsListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/countries/{countryCode}/cii:
    get:
      operationId: getCountryCII
      summary: Country instability index
      description: |
        Returns a country's Conflict Indicators Index (CII) score, baseline,
        delta, and components.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: path
          required: true
          description: ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
            example: "UA"
      responses:
        "200":
          description: Country instability index
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CountryCIIResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: Conflict-indicator data is not available for this country
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/military-posture:
    get:
      operationId: listMilitaryPosture
      summary: Military posture by theater
      description: |
        Lists Y2's theater posture assessments computed from adsb.lol military
        aircraft activity. Each includes a `normal`, `elevated`, or `critical`
        posture, aircraft counts by type, a strike assessment, and a `source`
        describing the computation.

        Posture covers the nine conflict theaters with calibrated thresholds
        (`iran`, `blacksea`, `taiwan`, `israelgaza`, `emed`, `redsea`, `scs`,
        `korea`, `baltic`). Assessments refresh every 15 minutes and expire
        after 30.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-y2-empty-policy: feed
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: limit
          in: query
          description: Maximum number of items to return
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 20
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: Military posture assessments by theater
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MilitaryPostureListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/aircraft:
    get:
      operationId: listAircraft
      summary: Tracked military aircraft
      description: |
        Lists military aircraft positions from the adsb.lol community ADS-B
        network (aircraft the ADS-B database flags as military), classified by
        type such as tanker, AWACS, or fighter and assigned to the smallest
        configured theater. Positions refresh every 15 minutes, expire 30
        minutes after `lastSeenAt`, and carry a `source` linking to the aircraft
        on adsb.lol. Data: adsb.lol, ODbL 1.0.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-y2-empty-policy: feed
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: theater
          in: query
          description: Filter by theater ID (e.g. "iran", "taiwan", "blacksea", "scs")
          schema:
            type: string
        - name: limit
          in: query
          description: Maximum number of aircraft to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 100
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of tracked military aircraft
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AircraftListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/vessels:
    get:
      operationId: listVessels
      summary: Naval vessel positions
      description: |
        Lists USNI fleet-tracker positions for carrier strike groups and warships.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-y2-empty-policy: feed
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: region
          in: query
          description: Filter by region name
          schema:
            type: string
        - name: limit
          in: query
          description: Maximum number of vessels to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of naval vessel positions
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VesselListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/gps-jamming:
    get:
      operationId: listGPSJamming
      summary: GPS interference zones
      description: |
        Lists GPS interference zones inferred from ADS-B navigation-accuracy
        degradation and aggregated into H3 cells.

        > **Status:** Paused since October 26, 2026. The Wingbits feed that
        > supplied these zones was retired, so the operation returns an empty
        > collection with `sourceStatus: unavailable` until the feed is
        > re-sourced. `/osint/aircraft` and `/osint/military-posture` are
        > unaffected.

        Records expire 30 minutes after fetch.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-y2-empty-policy: feed
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: severity
          in: query
          description: Filter by interference severity
          schema:
            type: string
            enum: [low, moderate, severe, critical]
        - name: limit
          in: query
          description: Maximum number of zones to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of GPS interference zones
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GPSJammingListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/sources/status:
    get:
      operationId: listSourceStatus
      summary: Data source health
      description: |
        Lists health for every monitored OSINT source that has reported at least
        once: derived freshness status, expected cadence, staleness threshold,
        circuit-breaker state, and failure counts. Retired sources are omitted.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      responses:
        "200":
          description: Data source health statuses
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SourceStatusListResponse"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/cyber-threats:
    get:
      operationId: listCyberThreats
      summary: List cyber threat indicators
      description: |
        Lists URLhaus malware URLs, Feodo Tracker C2 servers, and RSS cyber-feed
        indicators with malware family, tags, and host metadata.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: severity
          in: query
          description: Filter by severity level
          schema:
            $ref: "#/components/schemas/OsintSeverityEnum"
        - name: limit
          in: query
          description: Maximum number of threats to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
      responses:
        "200":
          description: List of cyber threat indicators
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CyberThreatListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/prediction-markets:
    get:
      operationId: listPredictionMarkets
      summary: List prediction markets
      description: |
        Lists Polymarket and Kalshi markets by descending volume with probabilities,
        volume, and outcomes.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: countryCode
          in: query
          description: Filter by ISO alpha-2 country code (e.g., US, CN, RU)
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
        - name: limit
          in: query
          description: Maximum number of markets to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
      responses:
        "200":
          description: List of prediction markets
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PredictionMarketListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/y2-events:
    get:
      operationId: listY2Events
      summary: Y2 report-extracted events
      description: |
        Lists Y2SOURCE events extracted from intelligence reports with classification,
        confidence, entities, and originating-report provenance.

        Returns only `sourceType: "y2_report"` events. Supports category, severity,
        and country-code filters.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: category
          in: query
          description: Filter by event category
          schema:
            $ref: "#/components/schemas/OsintEventCategoryEnum"
        - name: severity
          in: query
          description: Filter by severity level
          schema:
            $ref: "#/components/schemas/OsintSeverityEnum"
        - name: countryCode
          in: query
          description: Filter by ISO alpha-2 country code (e.g., US, CN, RU)
          schema:
            type: string
            pattern: "^[A-Z]{2}$"
        - name: limit
          in: query
          description: Maximum number of events to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - $ref: "#/components/parameters/Temporality"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of Y2 report-extracted events with provenance
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Y2EventListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/regional:
    get:
      operationId: listOsintRegionalEvents
      summary: Search regional OSINT events
      description: |
        Searches OSINT events across RSS, USGS, GDACS, ACLED, direct News Terminal
        items, other threat feeds, and Y2 report extractions. Filters by region,
        country code, bounding box, radius, source, category, severity, time window,
        or title text. Text search falls back to description substrings.

        All filters compose with AND, including coordinate and region filters.
        Events without coordinates remain unless `requireCoordinates=true` or a
        bounding-box or radius filter is supplied.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: q
          in: query
          description: Full-text search on title (also substring-matches description)
          schema:
            type: string
            maxLength: 200
        - name: region
          in: query
          description: Filter by geographic region
          schema:
            $ref: "#/components/schemas/OsintRegionEnum"
        - name: countryCode
          in: query
          description: Filter by ISO 3166-1 alpha-2 country code
          schema:
            type: string
            pattern: "^[A-Za-z]{2}$"
        - name: sourceType
          in: query
          description: "Filter by one data source. Omit to include all"
          schema:
            type: string
            enum:
              - usgs
              - rss
              - acled
              - gdelt
              - gdacs
              - eonet
              - firms
              - opensky
              - wingbits
              - adsblol
              - usni
              - polymarket
              - kalshi
              - urlhaus
              - feodo
              - y2_report
              - manual
              - fred
              - yfinance
              - eia
              - nvd
              - cisa_kev
              - cve_list
              - osv
              - intel_expansion
              - intel_discovery
              - news_terminal
        - name: category
          in: query
          description: Filter by event category
          schema:
            $ref: "#/components/schemas/OsintEventCategoryEnum"
        - name: severity
          in: query
          description: Filter by severity level
          schema:
            $ref: "#/components/schemas/OsintSeverityEnum"
        - name: bbox
          in: query
          description: |
            WGS 84 bounding box as `west,south,east,north` (longitude/latitude order).
            Exactly four values are required and antimeridian-crossing boxes are not accepted.
          schema:
            type: string
            pattern: "^-?[0-9]+(?:\\.[0-9]+)?,-?[0-9]+(?:\\.[0-9]+)?,-?[0-9]+(?:\\.[0-9]+)?,-?[0-9]+(?:\\.[0-9]+)?$"
        - name: nearLat
          in: query
          description: Center latitude for radius filter (requires nearLon + radiusKm)
          schema:
            type: number
            minimum: -90
            maximum: 90
        - name: nearLon
          in: query
          description: Center longitude for radius filter (requires nearLat + radiusKm)
          schema:
            type: number
            minimum: -180
            maximum: 180
        - name: radiusKm
          in: query
          description: Search radius in kilometers (requires nearLat + nearLon)
          schema:
            type: number
            exclusiveMinimum: 0
            maximum: 20000
        - name: requireCoordinates
          in: query
          description: When true, returns only rows with latitude and longitude
          schema:
            type: boolean
        - name: since
          in: query
          description: Inclusive lower bound on eventTime (epoch milliseconds)
          schema:
            type: integer
            minimum: 0
          deprecated: true
        - name: until
          in: query
          description: Inclusive upper bound on eventTime (epoch milliseconds)
          schema:
            type: integer
            minimum: 0
          deprecated: true
        - name: datetime
          in: query
          description: |
            OGC-style RFC 3339 instant or inclusive `start/end` interval. Use `..`
            for an open boundary. Cannot be combined with legacy `since` or `until`.
          schema:
            type: string
            examples:
              - "2026-07-21T00:00:00Z"
              - "2026-07-01T00:00:00Z/2026-07-21T23:59:59Z"
              - "../2026-07-21T23:59:59Z"
        - name: limit
          in: query
          description: Maximum number of events to return
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - $ref: "#/components/parameters/Temporality"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/SpatialFormat"
      responses:
        "200":
          description: List of regional events across all sources
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OsintEventListResponse"
            application/geo+json:
              schema:
                $ref: "#/components/schemas/GeoJSONFeatureCollection"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /osint/finint:
    get:
      operationId: listFinintIndicators
      summary: Financial intelligence indicators
      description: |
        Lists financial intelligence (FININT) indicators from FRED macroeconomic
        series, Yahoo Finance markets, and EIA energy data. Each includes current
        and previous values, percentage change, sparkline data, and active alerts.

        ### Aggregate and dimension rows

        Most indicators are US aggregates: one row per `indicatorId` (for example,
        `EIA:WTI`, `FRED:DGS10`). EIA also publishes per-dimension rows tagged
        with `dimension`, `dimensionType`, `lat`, and `lon`:

        - `dimensionType=facility`: reactor outages, such as `EIA:NUKE_OUTAGE:vogtle`
        - `dimensionType=rto`: hourly US balancing-authority demand, such as `EIA:RTO_LOAD:PJM`
        - `dimensionType=port`: monthly port-level crude imports, such as `EIA:CRUDE_IMPORT:houston`

        Filter by `dimensionType` for dimension rows only. Aggregate rows set
        `dimension`, `dimensionType`, `lat`, and `lon` to null.

        Nuclear-outage rows with `outagePct > 0` publish `economic` map events to
        the OSINT cache. RTO and crude-import rows do not publish map events.

        Accepts a bearer API key or [x402 payment](https://y2.dev/docs/api/x402).
        Without a key, read the `402` challenge in `PAYMENT-REQUIRED`. Retry with `PAYMENT-SIGNATURE`.
      tags: [OSINT]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: category
          in: query
          description: Filter by indicator category
          schema:
            type: string
            enum:
              [
                rates,
                credit,
                inflation,
                labor,
                gdp,
                business,
                consumer,
                housing,
                money_supply,
                volatility,
                commodities,
                fx,
                equities,
                energy,
                crypto,
              ]
        - name: source
          in: query
          description: Filter by data source
          schema:
            type: string
            enum: [fred, yfinance, eia]
        - name: dimensionType
          in: query
          description: |
            Filter to per-dimension rows only (nuclear facilities, RTO balancing
            authorities, ports of entry, or US states). When provided, aggregate
            rows are excluded from the response.
          schema:
            type: string
            enum: [facility, rto, port, state]
        - name: limit
          in: query
          description: Maximum number of indicators to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/RowFormat"
      responses:
        "200":
          description: List of financial intelligence indicators
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FinintIndicatorListResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  # ==========================================================================
  # INTEL API (v2): Ontology-backed intel sections
  #
  # v2 endpoints carry the literal `/api/v2/...` path prefix and are served
  # from `https://api.y2.dev` (no `/api/v1` segment). Each operation declares
  # an operation-level `servers:` override so OpenAPI tooling, SDK codegen,
  # and the in-app Workbench compose `https://api.y2.dev` + `/api/v2/...`
  # = the correct production URL.
  # ==========================================================================

  /api/v2/changes:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listChangesV2
      summary: Read the public intelligence change feed
      description: |
        Returns immutable public-resource lifecycle events in global order. An
        authenticated API key receives globally visible intelligence changes
        plus changes owned by its user or workspace tenant. Anonymous x402
        requests receive globally visible intelligence changes only. Tenant
        records are never exposed across scopes.

        The `watermark` is an opaque exclusive checkpoint: persist the returned
        value and send it on the next request. Replaying a checkpoint never
        skips later events and may safely be retried after a consumer failure.

        Without `watermark` or `since`, the first page starts at the oldest
        retained event, so a new consumer replays the whole log. Pass `since`
        to start at a point in time instead; the response watermark then
        continues from there as usual.

        Deleted resources are represented as tombstones. Events are append-only
        in schema version `1.0`. No retention expiry is currently applied.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [osint:read]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/RowFormat"
        - name: watermark
          in: query
          description: Opaque exclusive checkpoint returned by an earlier response.
          schema:
            type: string
            pattern: "^y2w1_[A-Za-z0-9_-]+$"
        - name: since
          in: query
          description: |
            Start at the first event that changed at or after this instant, as an
            RFC 3339 timestamp or Unix epoch milliseconds. Cannot be combined with
            `watermark`.
          schema:
            type: string
            examples: ["2026-10-25T00:00:00Z"]
        - name: limit
          in: query
          description: Maximum number of change events to return.
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 100
      responses:
        "200":
          description: Ordered public resource changes after the supplied watermark.
          headers:
            X-Y2-Watermark:
              description: Exclusive checkpoint to persist after processing this page.
              schema: { type: string }
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChangeFeedResponse"
            application/x-ndjson:
              schema: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/intel/knowledge/retrieve:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    post:
      operationId: retrieveGlobalKnowledgeV2
      summary: Retrieve Y2 Global Knowledge
      description: |
        Searches shared Y2 knowledge and, when requested, the key's workspace knowledge.
        Y2 determines access from the key. The request cannot supply a user or workspace ID.
        Results include source IDs and citations. They omit provider and access-control attributes.

        This operation requires a workspace-bound API key with `intel:knowledge`. It does not
        support x402. Agent Y2 keys continue to use `agent:y2`. The agent may invoke this
        retrieval tool internally when the workspace is entitled to Chat.
      tags: [Global Knowledge]
      security:
        - bearerAuth: []
      x-required-scopes: [intel:knowledge]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GlobalKnowledgeRetrievalRequest"
            example:
              query: What changed in semiconductor supply-chain risk?
              knowledgeMode: combined
              domains: [supply_chain, geopolitical]
              generatedAfter: 1782864000000
              limit: 8
      responses:
        "200":
          description: Authorized, current-manifest Global Knowledge results.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GlobalKnowledgeRetrievalResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"

  /api/v2/incidents:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listIncidentsV2
      summary: List intel incidents
      description: |
        Lists deduplicated, scored ontology incidents linked from the OSINT cache.
        Filters by category, severity, status, or last-observed lower bound.

        Required scopes vary by `category` filter:
        - `category=cyber` → `intel:cyber` or `intel:explorer`
        - any other category → `intel:finint` or `intel:explorer`
        - no `category` filter → `intel:explorer`

        Supports x402 pay-per-request. Requests without `Authorization` return
        `402 Payment Required` with payment requirements. Retry with a signed
        `PAYMENT-SIGNATURE` header.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer, intel:finint, intel:cyber]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsIncidents"
        - name: category
          in: query
          description: Filter incidents by category
          schema:
            type: string
            enum:
              [
                seismic,
                conflict,
                political,
                economic,
                weather,
                health,
                cyber,
                maritime,
                fire,
                aviation,
                other,
              ]
        - name: severity
          in: query
          description: Filter by severity
          schema:
            type: string
            enum: [low, medium, high, critical]
        - name: status
          in: query
          description: Filter by lifecycle status
          schema:
            type: string
            enum: [active, resolved, forecast]
        - name: sinceMs
          in: query
          description: |
            Lower bound on `lastObservedAt` as Unix milliseconds. Useful for
            polling: pass the largest `lastObservedAt` you've seen.
          schema:
            type: integer
            format: int64
        - name: limit
          in: query
          description: Maximum number of incidents to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: List of intel incidents
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IncidentListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/incidents/{incidentId}:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getIncidentV2
      summary: Get an intel incident
      description: |
        Returns an incident with supporting observations, linked markets and
        entities, primary place, and related incidents.

        The server resolves the category before checking scope: `intel:cyber` for
        cyber, `intel:finint` for other categories, or `intel:explorer` for any.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer, intel:finint, intel:cyber]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/IncidentIncludes"
        - $ref: "#/components/parameters/FieldsIncidents"
        - $ref: "#/components/parameters/FieldsObservations"
        - $ref: "#/components/parameters/FieldsMarkets"
        - $ref: "#/components/parameters/FieldsEntities"
        - name: incidentId
          in: path
          required: true
          description: Stable Y2 public incident ID (`inc_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
      responses:
        "200":
          description: "Incident drill: incident, observations, markets, entities"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IncidentDetailResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/entities:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listEntitiesV2
      summary: List intel entities
      description: |
        Lists ontology entities, including people, organizations, countries, CVEs,
        threat actors, vessels, aircraft, facilities, vendors, software, and protocols.
        `q` searches `canonicalName`. `kind` filters by exact kind.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsEntities"
        - name: kind
          in: query
          description: Filter by entity kind
          schema:
            type: string
            enum:
              - person
              - organization
              - country
              - region
              - vessel
              - aircraft
              - facility
              - asset
              - indicator
              - cve
              - malware_family
              - threat_actor
              - vendor
              - software
              - ai_model
              - api_service
              - protocol
        - name: q
          in: query
          description: Full-text search across `canonicalName` (filtered by `kind` when present)
          schema:
            type: string
        - name: limit
          in: query
          description: Maximum number of entities to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: List of intel entities
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/entities/{entityId}:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getEntityV2
      summary: Get an intel entity
      description: |
        Returns an entity with inbound and outbound relations, related entities,
        participating incidents, subject markets, recent observations, and
        tenant-scoped company financial observations when requested.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/EntityIncludes"
        - $ref: "#/components/parameters/FieldsEntities"
        - $ref: "#/components/parameters/FieldsIncidents"
        - $ref: "#/components/parameters/FieldsMarkets"
        - $ref: "#/components/parameters/FieldsObservations"
        - name: entityId
          in: path
          required: true
          description: Stable Y2 public entity ID (`ent_...`). Legacy IDs are accepted during migration.
          schema:
            type: string
      responses:
        "200":
          description: "Entity drill: entity, relations, incidents, markets"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityDetailResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/entities/{entityId}/financial-observations:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listCompanyFinancialObservationsV2
      summary: List workspace company financial history
      description: |
        Requires a workspace-bound API key with intel:finint. Returns only that
        workspace's recorded observations, newest recorded first. Not available
        with anonymous x402 payment. Metric filtering uses an index. FactType is
        applied to each bounded page, so an empty page can still have a next cursor.
        History reflects retained Y2 observations, not complete filing coverage or
        guaranteed historical availability. SEC imports retain JSON record pointers,
        not page/quote spans, and do not establish original publication timestamps.
        Unsupported or repeated query parameters are rejected with HTTP 400.
      tags: [Intel]
      security:
        - bearerAuth: []
      x-required-scopes: [intel:finint]
      parameters:
        - name: entityId
          in: path
          required: true
          description: Stable public entity ID from the entity API.
          schema:
            type: string
            pattern: "^ent_[a-f0-9]{24}$"
        - name: metricKey
          in: query
          description: Exact normalized metric key, such as eps_diluted.
          schema:
            type: string
            pattern: "^[a-z0-9_]{1,80}$"
        - name: factType
          in: query
          schema:
            type: string
            enum: [actual, estimate, guidance]
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 25
        - name: cursor
          in: query
          description: "Opaque next cursor. Preserve the path and filters between pages."
          schema:
            type: string
      responses:
        "200":
          description: Bounded workspace financial observations.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompanyFinancialHistoryResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/entities/{entityId}/fusion:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getEntityFusionV2
      summary: Get cyber-market fusion for a company
      description: |
        Requires a workspace-bound API key with intel:explorer. Places cyber,
        market, supply-chain, and geopolitical events about an organization or
        vendor, and about the parties on its exposure path, on one timeline.
        Exposure paths come from catalog relations (supplies, subsidiary_of,
        operates) and from evidenced workspace ledger claims (supplies,
        subsidiary-of, operates) on subjects anchored to the entity. Workspace
        topics that track any path entity are listed. Adjacencies pair a cyber
        event with market events that followed it within adjacencyDays. They are
        temporal co-occurrence, not causation. Incidents and prediction markets
        come from a bounded recent scan. Coverage notes say so. The window ends
        at request time. Not available with anonymous x402 payment.
      tags: [Intel]
      security:
        - bearerAuth: []
      x-required-scopes: [intel:explorer]
      parameters:
        - name: entityId
          in: path
          required: true
          description: Stable public ID of an organization or vendor entity.
          schema:
            type: string
            pattern: "^ent_[a-f0-9]{24}$"
        - name: windowDays
          in: query
          description: Days of history ending now.
          schema:
            type: integer
            minimum: 1
            maximum: 365
            default: 90
        - name: adjacencyDays
          in: query
          description: How long after a cyber event a market event counts as adjacent.
          schema:
            type: integer
            minimum: 1
            maximum: 90
            default: 7
      responses:
        "200":
          description: Fused exposure timeline for the entity.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityFusionResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/entities/{entityId}/graph:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getEntityGraphV2
      summary: Traverse an entity relationship graph
      description: |
        Traverses the ontology graph from `entityId` with breadth-first search.
        Returns nodes and edges to the requested depth, capped at 200 nodes.
        `relationKinds` limits traversed edge kinds.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: entityId
          in: path
          required: true
          description: Root entity ID for the traversal
          schema:
            type: string
        - name: depth
          in: query
          description: Maximum BFS depth (0–3)
          schema:
            type: integer
            minimum: 0
            maximum: 3
            default: 2
        - name: relationKinds
          in: query
          description: |
            Comma-separated list of relation kinds to traverse. Defaults to all
            kinds. Allowed values: `part_of`, `operates`, `located_in`,
            `ally_of`, `adversary_of`, `subsidiary_of`, `supplies`,
            `references`, `affects`, `targets`, `uses`.
          schema:
            type: string
            example: "affects,targets,uses"
      responses:
        "200":
          description: Entity graph (nodes + edges)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EntityGraphResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/markets:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listMarketsV2
      summary: List intel markets
      description: |
        Lists Y2-derived, Polymarket, Kalshi, and Manifold ontology markets keyed
        by `marketKey`. Filters by source and lifecycle status. Each market links
        to subject entities and may link to an underlying incident.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:finint]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsMarkets"
        - name: source
          in: query
          description: Filter by market source
          schema:
            type: string
            enum: [y2, polymarket, kalshi, manifold, derived]
        - name: status
          in: query
          description: Filter by lifecycle status
          schema:
            type: string
            enum: [open, resolved, cancelled]
        - name: limit
          in: query
          description: Maximum number of markets to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: List of markets
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MarketListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/finint:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listFinintIntelV2
      summary: List FININT indicators
      description: |
        Lists dimension-filtered FININT indicators from the same data as
        `GET /api/v1/osint/finint`, using the `intel:finint` scope and
        ontology-aware filters.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:finint]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsFinint"
        - name: dimensionType
          in: query
          description: Restrict to per-dimension rows (e.g. `facility`, `rto`, `port`, `state`)
          schema:
            type: string
            enum: [facility, rto, port, state]
        - name: dimension
          in: query
          description: Exact dimension key (e.g. `PJM`, `vogtle`, `houston`)
          schema:
            type: string
        - name: indicatorId
          in: query
          description: Exact indicator key (e.g. `EIA:WTI`, `FRED:DGS10`)
          schema:
            type: string
        - name: category
          in: query
          description: Filter by indicator category
          schema:
            type: string
            enum:
              [
                rates,
                credit,
                inflation,
                labor,
                gdp,
                business,
                consumer,
                housing,
                money_supply,
                volatility,
                commodities,
                fx,
                equities,
                energy,
                crypto,
              ]
        - name: source
          in: query
          description: Filter by data source
          schema:
            type: string
            enum: [fred, yfinance, eia]
        - name: limit
          in: query
          description: Maximum number of indicators to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 100
      responses:
        "200":
          description: List of FinInt indicators
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FinintIntelListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/disclosures:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listDisclosuresV2
      summary: List public disclosures
      description: |
        Screens primary-source disclosures: SEC Form 8-K material events, Forms 3/4/5
        insider transactions, Schedule 13D ownership stakes, and USAspending federal
        contract and grant actions. Y2 syncs SEC EDGAR twice daily and USAspending daily.

        Every party is resolved to a shared ontology entity, by SEC CIK or SAM UEI first and
        by governed entity resolution otherwise. Officer and director filings add
        `part_of` relations; contracts add recipient-`supplies`-agency relations; grants add
        agency-`supplies`-recipient relations. Each relation cites the disclosure's observation.

        Federal awards cover contract actions of $5M or more in the last 14 days and grant
        actions of $10M or more in the last 30 days at each sync. `publishedAt` is the SEC
        filing date or the award action date.

        Requires `intel:disclosures` (Pro and Elite plans) or an x402 payment.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:disclosures]
      x-x402:
        enabled: true
        tier: T2_STANDARD
        price: "$0.002"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsDisclosures"
        - name: kind
          in: query
          description: Disclosure type
          schema:
            $ref: "#/components/schemas/DisclosureKind"
        - name: category
          in: query
          description: |
            Screener facet. 8-K: `bankruptcy`, `cybersecurity`, `accounting`, `control_change`,
            `listing`, `leadership`, `deal`, `financing`, `results`, `governance`, `disclosure`,
            `other`. Insider: `buy`, `sell`, `grant`, `exercise`, `tax`, `gift`, `holdings`,
            `other`. Stake: `initial`, `amendment`. Award: `contract`, `grant`. With `kind`, the
            category must belong to that kind.
          schema:
            type: string
        - name: severity
          in: query
          description: Materiality the screener assigns from the item, amount, or stake
          schema:
            type: string
            enum: [low, medium, high, critical]
        - name: entityId
          in: query
          description: Public entity ID; returns disclosures naming it as subject or counterparty
          schema:
            type: string
            pattern: "^ent_[a-f0-9]{24}$"
        - name: q
          in: query
          description: Title search (company, ticker, insider, agency, or recipient)
          schema:
            type: string
            minLength: 1
            maxLength: 200
        - name: minAmountUsd
          in: query
          description: Minimum insider transaction value or award obligation in USD
          schema:
            type: number
            minimum: 0
        - name: sinceMs
          in: query
          description: Earliest `publishedAt`, in Unix milliseconds
          schema:
            type: integer
            minimum: 0
        - name: sort
          in: query
          description: "`recent` (default) or `amount`, largest first. `amount` requires `kind`."
          schema:
            type: string
            enum: [recent, amount]
        - name: limit
          in: query
          description: Maximum number of disclosures to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        "200":
          description: Page of disclosures
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DisclosureListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/signals:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listSignalsV2
      summary: List tagged emergent signals
      description: |
        Lists cached Y2 emergent SIGINT signals with ontology-aligned subjects,
        normalized subject keys, tags, source-report metadata, timestamps, and
        available geographic, observation, or entity links.

        Required scopes vary by `domain` filter:
        - `domain=cyber` or `domain=technology` -> `intel:cyber` or `intel:explorer`
        - `domain=markets` or `domain=supply_chain` -> `intel:finint` or `intel:explorer`
        - other domain filters -> `intel:explorer`
        - no `domain` filter -> any of `intel:cyber`, `intel:finint`, or `intel:explorer`

        Public x402 callers receive global and community signals. Authenticated
        API-key callers also receive authorized workspace and private rows.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:explorer, intel:finint, intel:cyber]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsSignals"
        - name: domain
          in: query
          description: Filter by SIGINT domain
          schema:
            type: string
            enum:
              [
                cyber,
                markets,
                geopolitical,
                operational,
                supply_chain,
                policy,
                military,
                technology,
                other,
              ]
        - name: actionType
          in: query
          description: Filter by candidate action type
          schema:
            type: string
            enum:
              [
                invest,
                patch,
                upgrade,
                strategy,
                hedge,
                monitor,
                mitigate,
                escalate,
                defer,
                allocate,
              ]
        - name: priority
          in: query
          description: Filter by priority
          schema:
            type: string
            enum: [low, medium, high, critical]
        - name: subjectKey
          in: query
          description: Filter by normalized subject key returned in `subjectKeys`
          schema:
            type: string
            example: "organization:example-ai-vendor"
        - name: subjectKind
          in: query
          description: Filter by ontology subject kind
          schema:
            type: string
            enum:
              - person
              - organization
              - country
              - region
              - vessel
              - aircraft
              - facility
              - asset
              - indicator
              - cve
              - malware_family
              - threat_actor
              - vendor
              - software
              - ai_model
              - api_service
              - protocol
        - name: entityId
          in: query
          description: Filter by linked ontology entity public ID
          schema:
            type: string
            pattern: "^ent_[a-f0-9]{24}$"
        - name: profileId
          in: query
          description: Filter by source profile public ID
          schema:
            type: string
            pattern: "^prf_[a-f0-9]{24}$"
        - name: reportId
          in: query
          description: Filter by source report public ID
          schema:
            type: string
            pattern: "^rpt_[a-f0-9]{24}$"
        - name: countryCode
          in: query
          description: Filter by ISO-like country code when geo-linked
          schema:
            type: string
            example: US
        - name: region
          in: query
          description: Filter by region label when geo-linked
          schema:
            type: string
        - name: visibility
          in: query
          description: Filter by signal visibility
          schema:
            type: string
            enum: [private, workspace, community, global]
        - name: q
          in: query
          description: Text search across title, signal, decision, justification, tags, and subjects
          schema:
            type: string
        - name: sinceMs
          in: query
          description: Lower bound on signal extraction timestamp as Unix milliseconds
          schema:
            type: integer
            format: int64
        - name: untilMs
          in: query
          description: Upper bound on signal extraction timestamp as Unix milliseconds
          schema:
            type: integer
            format: int64
        - name: limit
          in: query
          description: Maximum number of signals to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: List of tagged emergent signals
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SignalListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/cyber/graph:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getCyberGraphV2
      summary: Cyber entity graph
      description: |
        Returns a graph rooted at a CVE, threat actor, or malware family. Requires
        `rootCveId`, `rootActorId`, or `rootMalwareFamilyId`. Breadth-first search
        depth is capped at 2.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:cyber]
      x-y2-required-query-one-of: [rootCveId, rootActorId, rootMalwareFamilyId]
      x-x402:
        enabled: true
        tier: T3_ENRICHED
        price: "$0.01"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: rootCveId
          in: query
          description: Root entity ID (kind=cve) for the traversal
          schema:
            type: string
        - name: rootActorId
          in: query
          description: Root entity ID (kind=threat_actor) for the traversal
          schema:
            type: string
        - name: rootMalwareFamilyId
          in: query
          description: Root entity ID (kind=malware_family) for the traversal
          schema:
            type: string
        - name: depth
          in: query
          description: Maximum BFS depth (1–2)
          schema:
            type: integer
            minimum: 1
            maximum: 2
            default: 2
      responses:
        "200":
          description: Cyber graph (nodes + edges)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CyberGraphResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/cyber/cves:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listCVEsV2
      summary: Search CVEs with disclosure summaries
      description: |
        Lists `kind=cve` ontology entities with compact disclosure summaries and links.
        Preserves public entity IDs, cursor pagination, and `fields[entities]`.
        With no catalog filters, `q` searches CVE identifiers across all ontology entities.
        Set `catalog=true` (or any catalog filter) to search the collected disclosure catalog
        by CVE ID, year, vendor, product, or keywords. This view defaults to Critical and High,
        latest source update first. Text queries are relevance ordered; ID prefixes are ID
        ordered; exact CVE IDs bypass filters. Keep filters unchanged when following cursors.
        Full affected-version arrays and source records
        are available from `GET /api/v2/cyber/cves/{cveId}`. Reading does not trigger collection.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:cyber]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsEntities"
        - name: q
          in: query
          description: CVE identifier search; in catalog mode, also searches vendor, product and disclosure text (up to 160 characters).
          schema:
            type: string
            example: "CVE-2024-3094"
        - name: catalog
          in: query
          description: Use the searchable collected disclosure catalog with priority filters.
          schema: { type: boolean, enum: [true] }
        - name: severity
          in: query
          schema:
            type: string
            enum:
              [all, critical-high, critical, high, medium, low, info, unscored]
            default: critical-high
        - name: remediation
          in: query
          description: Source-reported remediation; unknown does not establish that no fix exists.
          schema:
            {
              type: string,
              enum: [any, fix_published, workaround_published, unknown],
              default: any,
            }
        - name: kev
          in: query
          description: Restrict to known exploited CVEs listed by CISA.
          schema: { type: string, enum: [any, "true"], default: any }
        - name: sort
          in: query
          description: Ordering without a search query. CVSS uses latest source update as its tie-breaker.
          schema: { type: string, enum: [updated, cvss], default: updated }
        - name: limit
          in: query
          description: Maximum number of CVEs to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: CVE entities with compact disclosure summaries
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CVEListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/cyber/cves/{cveId}:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getCVEDisclosureV2
      summary: Read a sourced CVE disclosure
      description: |
        Returns the normalized public disclosure used by Cyber and the public CVE page,
        linked to its stable ontology entity. Includes all retained source assessments,
        affected products and versions, remediation, references, and provenance.
        Private workspace data is excluded. The request reads stored data and does not
        contact providers. Missing assessments are unknown, not evidence of absence.

        Pass `revision` to retrieve a retained immutable disclosure. Unknown CVEs or
        revisions return 404; rejected records remain readable. Disclosure timestamps
        are Unix milliseconds, matching the public JSON representation. Source calendar
        dates such as EPSS `date` remain strings.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:cyber]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - name: cveId
          in: path
          required: true
          description: Canonical CVE identifier. This is not an `ent_...` identifier.
          schema:
            $ref: "#/components/schemas/CVEIdentifier"
        - name: revision
          in: query
          description: SHA-256 revision from a previously returned disclosure. Omit for the current record.
          schema:
            $ref: "#/components/schemas/CVERevision"
      responses:
        "200":
          description: Full retained public disclosure with ontology identity and discovery links
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CVEDisclosureResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/cyber/actors:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listThreatActorsV2
      summary: List threat actor entities
      description: |
        Lists `kind=threat_actor` ontology entities. Equivalent to
        `GET /api/v2/entities?kind=threat_actor&q=...`.
      tags: [Intel]
      security:
        - bearerAuth: []
        - {}
      x-required-scopes: [intel:cyber]
      x-x402:
        enabled: true
        tier: T1_HEALTH
        price: "$0.001"
        network:
          production: eip155:8453
          development: eip155:84532
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/FieldsEntities"
        - name: q
          in: query
          description: Full-text search on `canonicalName`
          schema:
            type: string
            example: "Lazarus"
        - name: limit
          in: query
          description: Maximum number of threat actors to return
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
      responses:
        "200":
          description: List of threat actor entities
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ThreatActorListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/cyber/dns/lookups:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    post:
      operationId: createDnsLookupV2
      summary: Look up a domain's DNS footprint
      description: |
        Returns the DNS footprint of a domain from DNSDumpster. The footprint contains A, MX,
        NS, CNAME, and TXT records. Each address includes its network operator (ASN), netblock,
        country, reverse DNS, and service banners. Send `domain`. Or send `entityId` to use the
        official website that Y2 records for that entity.

        A snapshot younger than 14 days answers every caller with `outcome: reused`. It does not
        use the workspace allowance. Otherwise Y2 takes a new snapshot with `outcome: fetched`.
        A new snapshot uses one monthly DNS lookup. Pro includes 5. Elite includes 1,000.
        `usage` reports the allowance after this request. A failed provider call returns the
        lookup to the allowance.

        Y2 stores each snapshot with the time when it arrived. The snapshot adds the domain,
        hosts, addresses, netblocks, and network operators to the shared ontology. A known
        organization whose official website is the domain `operates` it. Each relation records
        when snapshots first and last evidenced it.

        The free tier returns up to 50 A records for each domain. `truncated` is true when the
        provider has more. The request can wait up to about 40 seconds while Y2 paces provider
        calls.

        Requires a workspace-bound API key with `intel:cyber` on a Pro or Elite plan. Not
        available through x402.
      tags: [Intel]
      security:
        - bearerAuth: []
      x-required-scopes: [intel:cyber]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DnsLookupRequest"
            example:
              domain: y2.dev
      responses:
        "200":
          description: The domain's current DNS snapshot and the workspace allowance
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DnsLookupResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"

  /api/v2/cyber/dns/snapshots:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listDnsSnapshotsV2
      summary: List a domain's DNS snapshot history
      description: |
        Lists the stored DNS snapshots of one domain, newest first. Each snapshot includes the
        time when it arrived and its ontology links. Reading history never calls the provider.
        It does not use the workspace's DNS lookup allowance. Use `createDnsLookupV2` to take a
        new snapshot.

        Requires a workspace-bound API key with `intel:cyber` on a Pro or Elite plan.
      tags: [Intel]
      security:
        - bearerAuth: []
      x-required-scopes: [intel:cyber]
      parameters:
        - $ref: "#/components/parameters/Cursor"
        - name: domain
          in: query
          required: true
          description: Domain name. Y2 reduces a URL or `www.` host to its domain
          schema:
            type: string
            example: y2.dev
        - name: limit
          in: query
          description: Maximum number of snapshots to return
          schema:
            type: integer
            minimum: 1
            maximum: 25
            default: 10
      responses:
        "200":
          description: Page of DNS snapshots, newest first
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DnsSnapshotListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /x402/receipts/{nonce}:
    get:
      operationId: getX402Receipt
      summary: x402 receipt lookup
      description: |
        Returns sanitized x402 payment status by nonce. Public: anyone with the
        nonce can read the receipt status.
      tags: [Payments]
      security: []
      parameters:
        - name: nonce
          in: path
          required: true
          description: Payment authorization nonce.
          schema:
            type: string
      responses:
        "200":
          description: Sanitized x402 payment receipt
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/X402ReceiptResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/ledger/subjects:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listLedgerSubjectsV2
      summary: List ledger subjects
      description: |
        Requires a workspace-bound API key with `ledger:read`.
        Lists workspace ledger subjects, newest first.
        Each subject includes its display label and any linked catalog entity.
        The display label uses the live preferred-label claim when available. With entityId, returns the subjects anchored to that
        entity in one bounded page. An anchor is an index between the workspace
        ledger and the shared catalog. It is neither a claim nor a merge.
        Unsupported or repeated query parameters are rejected with HTTP 400.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:read]
      parameters:
        - name: entityId
          in: query
          description: Only subjects anchored to this public entity ID.
          schema:
            type: string
            pattern: "^ent_[a-f0-9]{24}$"
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 25
        - name: cursor
          in: query
          description: Opaque next cursor from the previous page.
          schema:
            type: string
      responses:
        "200":
          description: A page of ledger subjects.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerSubjectListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    post:
      operationId: openLedgerSubjectV2
      summary: Open a ledger subject
      description: |
        Requires a workspace-bound API key with ledger:write and an owner, admin,
        or member role. Appends a subject line with a class and no attributes:
        opening a row is not a finding. Names and identifiers arrive later as
        designators and claims. With entityId, the subject is anchored to that
        catalog entity. The entity kind must align with the class (for example,
        a vendor anchors an organization. A CVE anchors nothing). Send an
        Idempotency-Key header to make retries safe. A replay returns 200.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:write]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LedgerSubjectCreateRequest"
            example:
              class: organization
              entityId: ent_aaaaaaaaaaaaaaaaaaaaaaaa
      responses:
        "200":
          description: Idempotent replay of an earlier open.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerSubjectCreatedResponse"
        "201":
          description: Subject opened.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerSubjectCreatedResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/ledger/subjects/{subjectId}:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getLedgerSubjectV2
      summary: Fold a ledger subject
      description: |
        Requires a workspace-bound API key with ledger:read. Returns the fold of
        one subject: the head of every claim key that touches it. recordedAt
        selects what the ledger had recorded by then. ValidAt keeps only heads
        whose valid interval contains that time. A designation outside validAt
        moves to unlinkedDesignations instead of disappearing. Retracted heads are
        listed separately. A pair with both a live same-as and a live
        distinct-from is contested. The fold picks no winner and never merges
        rows. Reads are bounded. Truncated is true when a budget was reached.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:read]
      parameters:
        - $ref: "#/components/parameters/LedgerSubjectId"
        - name: recordedAt
          in: query
          description: Record-time cursor (ISO 8601). Omit for the latest record.
          schema:
            type: string
            format: date-time
        - name: validAt
          in: query
          description: Valid-time cursor (ISO 8601). Omit to ignore valid intervals.
          schema:
            type: string
            format: date-time
      responses:
        "200":
          description: The subject's fold at the requested clocks.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerSubjectResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/ledger/subjects/{subjectId}/stix:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: getLedgerSubjectStixV2
      summary: Export a ledger subject as STIX 2.1
      description: |
        Requires a workspace-bound API key with `ledger:read`.
        Exports the subject's fold as a STIX 2.1 bundle.
        Subjects become identity objects. Email, handle, domain, hostname, URL, and ASN designators become cyber-observable objects.
        Claims become relationship objects with confidence, start_time, stop_time, and cited observations as external references. Verification state and the claim key travel in a
        property extension. An unconfirmed same-as exports as related-to.
        Duplicate-of and attributed-to are never emitted. history=true adds
        retracted heads as revoked relationships. STIX ids carry the SHA-256
        digest of a per-workspace key in UUID form, so they are stable and do
        not reveal the workspace. An explicit validAt cursor scopes object
        IDs to that valid-time snapshot. A reassertion after revocation starts
        a new relationship ID. If the bounded subject neighborhood is
        incomplete, returns HTTP 400 VALIDATION_ERROR. Export the paginated
        ledger records and project the complete log offline instead.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:read]
      parameters:
        - $ref: "#/components/parameters/LedgerSubjectId"
        - name: recordedAt
          in: query
          schema:
            type: string
            format: date-time
        - name: validAt
          in: query
          schema:
            type: string
            format: date-time
        - name: history
          in: query
          description: Include retracted heads as revoked relationships.
          schema:
            type: boolean
            default: false
      responses:
        "200":
          description: A STIX 2.1 bundle.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StixBundle"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/ledger/records:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: listLedgerRecordsV2
      summary: Export sealed ledger lines
      description: |
        Requires a workspace-bound API key with ledger:read. Returns ledger
        lines in record order after afterSeq. Each item carries the exact
        canonical line text, so a client can write NDJSON and run the offline
        reference checker (`y2-ledger check`) against it. The log is
        append-only: continuing from meta.nextAfterSeq never skips or repeats a
        line.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:read]
      parameters:
        - $ref: "#/components/parameters/LedgerAfterSeq"
        - $ref: "#/components/parameters/LedgerWindowLimit"
      responses:
        "200":
          description: Sealed lines after afterSeq.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerRecordListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"
    post:
      operationId: appendLedgerRecordV2
      summary: Append a ledger record
      description: |
        Requires a workspace-bound API key with ledger:write and an owner, admin,
        or member role. Appends one designator, observation, or claim. A
        designator with the same kind, namespace, and normalized value is reused
        (200, created false). Every claim cites at least one observation. The
        first line of a claim key supersedes nothing. Every later line,
        including a retraction, must supersede the current head, or the request
        fails with 409. Verification must be one the cited evidence supports:
        cross-linked and corroborated need retrievals of two different pages.
        Analytic means the only support is an analyst note. Other rule failures
        return 400 with the rule codes in detail. Send an Idempotency-Key header
        to make retries safe.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:write]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LedgerRecordAppendRequest"
            example:
              kind: claim
              claim:
                predicate: designated-by
                from: sbj_0123456789abcdef01234567
                to: dsg_0123456789abcdef01234567
                confidence: 80
                verification: self-asserted
                evidenceRefs: [obv_0123456789abcdef01234567]
      responses:
        "200":
          description: Designator reused, or an idempotent replay.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerRecordAppendResponse"
        "201":
          description: Record appended.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerRecordAppendResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v2/ledger/verify:
    servers:
      - url: https://api.y2.dev
        description: Y2 Intel v2 root
    get:
      operationId: verifyLedgerV2
      summary: Verify the ledger seal
      description: |
        Requires a workspace-bound API key with `ledger:read`.
        Recomputes the SHA-256 seal for lines after `afterSeq`.
        Checks canonical JSON, line hashes, consecutive `seq` values, and each `prev` reference to the previous line. Rules that look up earlier records are enforced at append time
        and by the offline checker over a full export.
      tags: [Ontology Ledger]
      security:
        - bearerAuth: []
      x-required-scopes: [ledger:read]
      parameters:
        - $ref: "#/components/parameters/LedgerAfterSeq"
        - $ref: "#/components/parameters/LedgerWindowLimit"
      responses:
        "200":
          description: Seal verification for the window.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LedgerVerifyResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/InternalError"

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Y2 API Key
      description: |
        API keys in format `y2_{64_hex_chars}`.
        Create keys in the Y2 dashboard.

  parameters:
    Temporality:
      name: temporality
      in: query
      description: |
        `current` (default) returns events that have occurred or are under way,
        newest first; event times more than 15 minutes after the request are
        excluded. `forecast` returns scheduled, forecast, and speculative events
        dated after that point, soonest first.
      schema:
        $ref: "#/components/schemas/EventTemporality"
    Cursor:
      name: cursor
      in: query
      description: Opaque continuation token from the previous response. Bound to the original filters and ordering.
      schema:
        type: string
    IfMatch:
      name: If-Match
      in: header
      required: false
      description: Strong ETag from the latest representation. A mismatch returns 412.
      schema:
        type: string
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: |
        Client-generated retry key retained for 24 hours. Repeating the same key
        and canonical JSON body returns the original resource. Changing the body
        returns `409 IDEMPOTENCY_CONFLICT`.
      schema:
        type: string
        minLength: 8
        maxLength: 200
        pattern: "^[A-Za-z0-9._:-]+$"
    LedgerSubjectId:
      name: subjectId
      in: path
      required: true
      description: Ledger subject ID (sbj_ and 24 hex characters, from the public-ID digest strategy).
      schema:
        type: string
        pattern: "^sbj_[a-f0-9]{24}$"
    LedgerAfterSeq:
      name: afterSeq
      in: query
      description: Return lines with seq greater than this. Start at 0.
      schema:
        type: integer
        minimum: 0
        default: 0
    LedgerWindowLimit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 200
        default: 100
    RowFormat:
      name: format
      in: query
      description: "`json` uses the resource envelope. `ndjson` streams one canonical row per line."
      schema:
        type: string
        enum: [json, ndjson]
    SpatialFormat:
      name: format
      in: query
      description: Select the JSON resource envelope, row-oriented NDJSON, or an RFC 7946 FeatureCollection.
      schema:
        type: string
        enum: [json, ndjson, geojson]
    FieldsIncidents:
      name: fields[incidents]
      in: query
      description: Comma-separated allowlist of incident fields. Identity and links remain present.
      schema:
        type: string
    FieldsEntities:
      name: fields[entities]
      in: query
      description: Comma-separated allowlist of entity fields. Identity and links remain present.
      schema:
        type: string
    FieldsMarkets:
      name: fields[markets]
      in: query
      description: Comma-separated allowlist of market fields. Identity remains present.
      schema:
        type: string
    FieldsObservations:
      name: fields[observations]
      in: query
      description: Comma-separated allowlist of observation fields. Identity and source links remain present.
      schema:
        type: string
    FieldsFinint:
      name: fields[finint]
      in: query
      description: Comma-separated allowlist of financial observation fields (indicator, source, dimension, measurement, observedAt, period, provenance, entities, geometry, signals). Identity remains present.
      schema:
        type: string
    FieldsDisclosures:
      name: fields[disclosures]
      in: query
      description: Comma-separated allowlist of disclosure fields (kind, source, form, category, severity, title, occurredAt, publishedAt, amount, subject, counterparty, entities, details, provenance). Identity remains present.
      schema:
        type: string
    FieldsSignals:
      name: fields[signals]
      in: query
      description: Comma-separated allowlist of signal fields. Identity remains present.
      schema:
        type: string
    IncidentIncludes:
      name: include
      in: query
      description: Bounded related resources to embed.
      schema:
        type: string
        example: observations,entities
    EntityIncludes:
      name: include
      in: query
      description: |
        Bounded related resources to embed: `relations`, `relatedEntities`,
        `incidents`, `markets`, `observations`, `companyIdentity`, or
        `financialObservations`. Financial observations require an authenticated
        tenant context and are never returned across tenants.
      schema:
        type: string
        example: relations,companyIdentity,financialObservations

  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            type: "https://api.y2.dev/problems/unauthorized"
            title: "Unauthorized"
            status: 401
            detail: "Missing Authorization header"
            instance: "urn:y2:request:req_019d0f205ea37f248c3f2f65ddce8b61"
            code: "UNAUTHORIZED"
            requestId: "req_019d0f205ea37f248c3f2f65ddce8b61"
            error:
              message: "Missing Authorization header"
              code: "UNAUTHORIZED"
    Forbidden:
      description: Insufficient permissions or access denied
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    NotFound:
      description: Resource not found
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    RateLimited:
      description: Rate limit exceeded (per-key or per-account aggregate)
      headers:
        Retry-After:
          description: Seconds to wait before retrying
          schema:
            type: integer
        X-RateLimit-Limit-Minute:
          description: Per-key requests allowed per minute
          schema:
            type: integer
        X-RateLimit-Remaining-Minute:
          description: Per-key requests remaining this minute
          schema:
            type: integer
        X-RateLimit-Limit-Day:
          description: Per-key requests allowed per day
          schema:
            type: integer
        X-RateLimit-Remaining-Day:
          description: Per-key requests remaining today
          schema:
            type: integer
        X-RateLimit-Limit-User-Minute:
          description: "Per-account aggregate requests allowed per minute (workspace when scoped, otherwise user. Legacy header name retained)"
          schema:
            type: integer
        X-RateLimit-Remaining-User-Minute:
          description: "Per-account aggregate requests remaining this minute (workspace when scoped, otherwise user. Legacy header name retained)"
          schema:
            type: integer
        X-RateLimit-Limit-User-Day:
          description: "Per-account aggregate requests allowed per day (workspace when scoped, otherwise user. Legacy header name retained)"
          schema:
            type: integer
        X-RateLimit-Remaining-User-Day:
          description: "Per-account aggregate requests remaining today (workspace when scoped, otherwise user. Legacy header name retained)"
          schema:
            type: integer
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    PaymentRequired:
      description: x402 payment required
      headers:
        PAYMENT-REQUIRED:
          description: Base64-encoded JSON payment requirements.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/X402PaymentRequiredResponse"
    AgentY2PaymentRequired:
      description: Agent Y2 subscription, workspace Agent Y2 credit, or provider credit exhaustion
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    InternalError:
      description: Internal server error
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    ServiceUnavailable:
      description: Y2 Global Knowledge is disabled or its retrieval provider is unavailable.
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    Conflict:
      description: Resource conflict (e.g., webhook in use)
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    PreconditionFailed:
      description: The supplied If-Match validator does not match the current representation.
      headers:
        ETag:
          description: Strong validator for the current representation.
          schema: { type: string }
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"

  schemas:
    GlobalKnowledgeRetrievalRequest:
      type: object
      required: [query]
      additionalProperties: false
      properties:
        query:
          type: string
          minLength: 1
          maxLength: 1000
        knowledgeMode:
          type: string
          enum: [shared, workspace, combined]
          default: combined
          description: Narrows retrieval to shared, key-workspace, or both authorized corpora.
        documentKinds:
          type: array
          maxItems: 8
          uniqueItems: true
          items:
            type: string
            enum:
              [
                report_chunk,
                signal_assessment,
                report_graph_component,
                source_document_chunk,
              ]
        entityIds:
          type: array
          maxItems: 20
          uniqueItems: true
          items: { type: string, maxLength: 128 }
        incidentIds:
          type: array
          maxItems: 20
          uniqueItems: true
          items: { type: string, maxLength: 128 }
        subjectKeys:
          type: array
          maxItems: 20
          uniqueItems: true
          items: { type: string, maxLength: 128 }
        domains:
          type: array
          maxItems: 8
          uniqueItems: true
          items:
            type: string
            enum:
              [
                cyber,
                markets,
                geopolitical,
                operational,
                supply_chain,
                policy,
                military,
                technology,
                other,
              ]
        priorities:
          type: array
          maxItems: 4
          uniqueItems: true
          items:
            type: string
            enum: [low, medium, high, critical]
        generatedAfter:
          type: integer
          minimum: 0
          description: Inclusive lower bound as Unix milliseconds.
        generatedBefore:
          type: integer
          minimum: 0
          description: Inclusive upper bound as Unix milliseconds.
        limit:
          type: integer
          minimum: 1
          maximum: 20
          default: 10

    GlobalKnowledgeCanonicalReference:
      type: object
      required: [type, id, revision]
      additionalProperties: false
      properties:
        type:
          type: string
          enum: [entity, incident, place, observation, relation]
        id: { type: string }
        revision: { type: integer, minimum: 1 }

    GlobalKnowledgeResult:
      type: object
      required:
        [
          documentId,
          rank,
          documentKind,
          title,
          excerpt,
          source,
          ontology,
          canonicalRefs,
          episode,
          inferenceKind,
          generatedAt,
          citationUrls,
        ]
      additionalProperties: false
      properties:
        documentId: { type: string }
        rank: { type: integer, minimum: 1 }
        documentKind:
          type: string
          enum:
            [
              report_chunk,
              signal_assessment,
              report_graph_component,
              source_document_chunk,
            ]
        title: { type: string, maxLength: 300 }
        excerpt: { type: string, maxLength: 1200 }
        sectionPath: { type: string, maxLength: 300 }
        source:
          type: object
          required: [type, id]
          additionalProperties: false
          properties:
            type:
              { type: string, enum: [report, signal_assessment, source_record] }
            id: { type: string }
            reportId: { type: string }
            profileId: { type: string }
        ontology:
          type: object
          required: [entityIds, incidentIds, placeIds, subjectKeys]
          additionalProperties: false
          properties:
            entityIds: { type: array, items: { type: string } }
            incidentIds: { type: array, items: { type: string } }
            placeIds: { type: array, items: { type: string } }
            subjectKeys: { type: array, items: { type: string } }
        canonicalRefs:
          type: array
          maxItems: 32
          items:
            $ref: "#/components/schemas/GlobalKnowledgeCanonicalReference"
        episode:
          type: object
          required: [id, recordedAt]
          additionalProperties: false
          properties:
            id: { type: string }
            recordedAt: { type: integer, minimum: 0 }
            validFrom: { type: integer, minimum: 0 }
            validTo: { type: integer, minimum: 0 }
        inferenceKind: { type: string }
        generatedAt: { type: integer, minimum: 0 }
        validFrom: { type: integer, minimum: 0 }
        validTo: { type: integer, minimum: 0 }
        citationUrls:
          type: array
          maxItems: 32
          items: { type: string, format: uri }

    GlobalKnowledgeRetrievalResponse:
      type: object
      required: [data, meta]
      additionalProperties: false
      properties:
        data:
          type: array
          maxItems: 20
          items:
            $ref: "#/components/schemas/GlobalKnowledgeResult"
        meta:
          type: object
          required: [count, limit, knowledgeMode, availability]
          additionalProperties: false
          properties:
            count: { type: integer, minimum: 0, maximum: 20 }
            limit: { type: integer, minimum: 1, maximum: 20 }
            knowledgeMode: { type: string, enum: [shared, workspace, combined] }
            availability:
              $ref: "#/components/schemas/GlobalKnowledgeRetrievalAvailability"

    GlobalKnowledgeRetrievalAvailability:
      type: object
      description: |
        Whether every corpus the request covered answered. A `partial` response is
        still `200`: the listed corpora were skipped, so an empty or short `data`
        array does not mean nothing matched.
      required: [status, queriedCorpora, unavailableCorpora]
      additionalProperties: false
      properties:
        status:
          type: string
          enum: [complete, partial]
        queriedCorpora:
          type: array
          items: { type: string, enum: [shared, workspace] }
        unavailableCorpora:
          type: array
          items:
            type: object
            required: [corpus, reason]
            additionalProperties: false
            properties:
              corpus: { type: string, enum: [shared, workspace] }
              reason: { type: string, enum: [disabled, provider_unavailable] }

    AgentY2TextPart:
      type: object
      required: [type, text]
      properties:
        type:
          type: string
          const: text
        text:
          type: string

    AgentY2Message:
      type: object
      required: [role]
      properties:
        role:
          type: string
          enum: [user, assistant]
        content:
          type: [string, "null"]
        parts:
          type: array
          items:
            $ref: "#/components/schemas/AgentY2TextPart"

    AgentY2RequestMetadata:
      type: object
      additionalProperties: false
      properties:
        source:
          type: string
          maxLength: 128
        externalUserId:
          type: string
          maxLength: 256
        externalThreadId:
          type: string
          maxLength: 256

    AgentY2StreamRequest:
      type: object
      required: [messages]
      properties:
        messages:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/AgentY2Message"
        threadId:
          type: string
          description: Existing Y2 chat thread ID returned in `X-Thread-Id`
        metadata:
          $ref: "#/components/schemas/AgentY2RequestMetadata"

    OpenAICompatibleChatMessage:
      type: object
      required: [role, content]
      properties:
        role:
          type: string
          enum: [system, developer, user, assistant, tool]
          description: System, developer, and tool messages are used only when the request supplies a non-empty `tools` array.
        content:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: "#/components/schemas/AgentY2TextPart"
            - type: "null"
        tool_calls:
          type: array
          maxItems: 128
          items:
            type: object
            required: [id, type, function]
            additionalProperties: false
            properties:
              id:
                type: string
                minLength: 1
                maxLength: 1024
              type:
                type: string
                const: function
              function:
                type: object
                required: [name, arguments]
                additionalProperties: false
                properties:
                  name:
                    type: string
                    pattern: "^[A-Za-z0-9_-]+$"
                    maxLength: 128
                  arguments:
                    type: string
                    description: JSON-encoded object arguments
        tool_call_id:
          type: string
          minLength: 1
          maxLength: 1024
        name:
          type: string
          minLength: 1
          maxLength: 128

    OpenAICompatibleFunctionTool:
      type: object
      required: [type, function]
      additionalProperties: false
      properties:
        type:
          type: string
          const: function
        function:
          type: object
          required: [name, parameters]
          additionalProperties: false
          properties:
            name:
              type: string
              pattern: "^[A-Za-z0-9_-]+$"
              maxLength: 128
            description:
              type: string
              maxLength: 16384
            parameters:
              type: object
              description: JSON Schema for client-side tool arguments
              additionalProperties: true

    OpenAICompatibleChatCompletionRequest:
      type: object
      required: [messages, stream]
      properties:
        model:
          type: string
          enum: [y2-agent, agent-y2]
          description: Optional Y2 Agent model alias. Arbitrary model selection is not supported.
        messages:
          type: array
          minItems: 1
          maxItems: 512
          items:
            $ref: "#/components/schemas/OpenAICompatibleChatMessage"
        stream:
          type: boolean
          const: true
        threadId:
          type: string
          description: Optional Y2 thread ID. The `X-Thread-Id` request header is also accepted.
        metadata:
          $ref: "#/components/schemas/AgentY2RequestMetadata"
        tools:
          type: array
          maxItems: 128
          description: A non-empty array selects client harness mode. Y2 never executes these tools server-side.
          items:
            $ref: "#/components/schemas/OpenAICompatibleFunctionTool"
        tool_choice:
          type: string
          enum: [auto, none, required]
        parallel_tool_calls:
          type: boolean
        max_tokens:
          type: integer
          minimum: 1
          maximum: 16384

    # =========================================================================
    # Error Schemas
    # =========================================================================
    ErrorResponse:
      type: object
      description: Canonical RFC 9457 Problem Details response.
      required:
        [type, title, status, detail, instance, code, requestId, resolution]
      properties:
        type:
          type: string
          format: uri
          description: Stable problem type URI.
        title:
          type: string
        status:
          type: integer
          minimum: 400
          maximum: 599
        detail:
          type: string
        instance:
          type: string
          format: uri
          description: URI identifying this request occurrence.
        code:
          type: string
          description: Stable machine-readable Y2 error code.
          enum:
            - UNAUTHORIZED
            - INVALID_API_KEY
            - API_KEY_EXPIRED
            - API_KEY_REVOKED
            - FORBIDDEN
            - INSUFFICIENT_SCOPE
            - IP_NOT_ALLOWED
            - SUBSCRIPTION_REQUIRED
            - FEATURE_REQUIRES_PRO
            - BAD_REQUEST
            - INVALID_ID_FORMAT
            - INVALID_TOPICS
            - INVALID_TIMEFRAME
            - VALIDATION_ERROR
            - QUERY_TOO_BROAD
            - NOT_FOUND
            - NO_AUDIO
            - PROFILE_NOT_FOUND
            - REPORT_NOT_FOUND
            - WEBHOOK_NOT_FOUND
            - SUBSCRIPTION_NOT_FOUND
            - DATA_NOT_AVAILABLE
            - PRO_REQUIRED
            - INVALID_DELIVERY_METHOD
            - WEBHOOK_INACTIVE
            - WEBHOOK_CONFIG_REQUIRED
            - WEBHOOK_TEST_FAILED
            - WEBHOOK_TEST_REQUIRED
            - WEBHOOK_IN_USE
            - IDEMPOTENCY_CONFLICT
            - CONFLICT
            - RESOURCE_IDENTITY_CONFLICT
            - AUTOMATION_NOT_ACTIVE
            - PRECONDITION_FAILED
            - RATE_LIMIT_EXCEEDED
            - MINUTE_LIMIT_EXCEEDED
            - DAILY_LIMIT_EXCEEDED
            - INTERNAL_ERROR
            - SERVICE_UNAVAILABLE
            - CACHE_NOT_READY
            - INSUFFICIENT_CREDITS
            - CREDITS_INSUFFICIENT
            - X402_DISABLED
            - X402_INVALID_SIGNATURE
            - X402_NONCE_REPLAY
            - X402_VERIFY_FAILED
            - X402_SETTLE_FAILED
            - X402_FACILITATOR_UNAVAILABLE
            - X402_WALLET_LIMIT
            - X402_ENDPOINT_CEILING
            - X402_HANDLER_FAILED_AFTER_SETTLE
            - X402_MISSING_CONFIG
        requestId:
          type: string
          pattern: "^req_[a-f0-9]{32}$"
        resolution:
          type: string
          description: A safe next step an automated client or developer can take to resolve the failure.
          example: Check the request against https://y2.dev/openapi.json and retry with valid inputs.
        errors:
          type: array
          description: Optional field-level validation failures using JSON Pointer paths.
          items:
            type: object
            required: [path, code, message]
            properties:
              path:
                type: string
              code:
                type: string
              message:
                type: string

    # =========================================================================
    # x402 Payment Schemas
    # =========================================================================
    X402PaymentOption:
      type: object
      description: |
        One row in the `accepts` array of an x402 v2 PaymentRequired body.
        Mirrors `@x402/core` `PaymentRequirements`.
      required: [scheme, network, asset, amount, payTo, maxTimeoutSeconds]
      properties:
        scheme:
          type: string
          enum: [exact, upto]
        network:
          type: string
          description: CAIP-2 network identifier.
          example: eip155:8453
        asset:
          type: string
          description: ERC-20 token contract (USDC) for the chosen network.
          example: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        amount:
          type: string
          description: |
            Price in atomic token units (USDC has 6 decimals).
            Example: `"2000"` = $0.002.
          example: "2000"
        payTo:
          type: string
          description: Receiver wallet address.
        maxTimeoutSeconds:
          type: integer
          description: Max settlement timeout the seller will wait for.
          example: 60
        extra:
          type: object
          additionalProperties: true
          description: |
            Scheme-specific extras. For `exact` EVM payments against a
            default EIP-3009 stablecoin (e.g. USDC), Y2 emits the EIP-712
            domain values the buyer must sign `TransferWithAuthorization`
            against. Values come from the token contract's `eip712Domain()`
            view and vary by network/contract: Base mainnet USDC is
            `name: "USD Coin"`, Base Sepolia USDC is `name: "USDC"`, both
            `version: "2"`.
          example:
            name: USD Coin
            version: "2"

    X402Resource:
      type: object
      description: Canonical resource the buyer is paying to access.
      required: [url]
      properties:
        url:
          type: string
          description: Full request URL.
          example: https://api.y2.dev/api/v1/osint/events
        description:
          type: string
        mimeType:
          type: string
          example: application/json

    X402PaymentRequiredResponse:
      type: object
      description: |
        Body returned with HTTP 402 responses. Same shape as the
        base64-encoded `PAYMENT-REQUIRED` header, plus an optional `error`
        message. Conforms to x402 v2 (`@x402/core` `PaymentRequired`).
      required: [x402Version, accepts, resource]
      properties:
        x402Version:
          type: integer
          description: x402 protocol version. Y2 advertises v2.
          example: 2
        error:
          type: string
          description: Optional human-readable reason (e.g. "Payment required").
          example: Payment required
        resource:
          $ref: "#/components/schemas/X402Resource"
        accepts:
          type: array
          items:
            $ref: "#/components/schemas/X402PaymentOption"
        extensions:
          type: object
          additionalProperties: true
          description: |
            Facilitator-level extensions. Y2 emits `extensions.bazaar` with
            CDP Bazaar discovery metadata (`category`, `tags`,
            `discoverable`).

    X402PaymentSignaturePayload:
      type: object
      description: |
        Decoded shape of the base64 `PAYMENT-SIGNATURE` request header. Mirrors
        `@x402/core` `PaymentPayload`. The `payload` field is opaque to the
        protocol: for the `exact` EVM scheme it is an EIP-3009
        `TransferWithAuthorization` signature.
      required: [x402Version, accepted, payload]
      properties:
        x402Version:
          type: integer
          example: 2
        resource:
          $ref: "#/components/schemas/X402Resource"
        accepted:
          $ref: "#/components/schemas/X402PaymentOption"
        payload:
          type: object
          description: |
            Scheme-specific payment material. For `exact` EVM:
            `{ signature, authorization: { from, to, value, validAfter, validBefore, nonce } }`.
          additionalProperties: true
        extensions:
          type: object
          additionalProperties: true

    X402ReceiptResponse:
      type: object
      required: [nonce, payerAddress, endpoint, amountUsd, network, status]
      properties:
        nonce:
          type: string
        payerAddress:
          type: string
        endpoint:
          type: string
          example: /api/v1/osint/sources/status
        amountUsd:
          type: number
          format: double
          example: 0.002
        network:
          type: string
          example: eip155:8453
        status:
          type: string
          enum:
            [
              verify_failed,
              rate_limited,
              replay_blocked,
              settle_failed,
              settled,
              handler_failed,
            ]
        txHash:
          type: string
        settledAt:
          type: number
          description: Epoch milliseconds.
        error:
          type: [string, "null"]

    # =========================================================================
    # Report Schemas
    # =========================================================================
    ReportListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/PublicReport"
            unevaluatedProperties: false
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    ReportDetailResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/PublicReportDetail"

    PublicReportIntelligenceSummary:
      type: object
      required: [signalCount, graph]
      additionalProperties: false
      properties:
        signalCount:
          type: integer
          minimum: 0
        graph:
          type: [object, "null"]
          required: [nodeCount, edgeCount, incidentCount]
          additionalProperties: false
          properties:
            nodeCount:
              type: integer
              minimum: 0
            edgeCount:
              type: integer
              minimum: 0
            incidentCount:
              type: integer
              minimum: 0

    PublicReportAudioSummary:
      type: object
      required: [status, durationSeconds, mediaType]
      additionalProperties: false
      properties:
        status:
          type: string
          enum: [available, unavailable]
        durationSeconds:
          type: [number, "null"]
        mediaType:
          type: [string, "null"]

    PublicReport:
      type: object
      required:
        [
          id,
          type,
          profileId,
          topic,
          summary,
          status,
          generatedAt,
          publishedAt,
          language,
          intelligence,
          audio,
          links,
          source,
        ]
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          pattern: "^rpt_[a-f0-9]{24}$"
        type:
          type: string
          const: report
        profileId:
          type: string
          pattern: "^prf_[a-f0-9]{24}$"
        topic:
          type: [string, "null"]
        summary:
          type: [string, "null"]
        status:
          type: string
          const: published
        generatedAt:
          type: string
          format: date-time
        publishedAt:
          type: string
          format: date-time
        language:
          type: string
        intelligence:
          $ref: "#/components/schemas/PublicReportIntelligenceSummary"
        audio:
          $ref: "#/components/schemas/PublicReportAudioSummary"
        links:
          $ref: "#/components/schemas/PublicResourceLinks"

    PublicSource:
      type: object
      required:
        [
          id,
          url,
          title,
          publisher,
          publishedAt,
          retrievedAt,
          sourceType,
          language,
        ]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^src_[a-f0-9]{24}$"
        url:
          type: string
          format: uri
        title:
          type: [string, "null"]
        publisher:
          type: [string, "null"]
        publishedAt:
          type: [string, "null"]
          format: date-time
        retrievedAt:
          type: string
          format: date-time
        sourceType:
          type: string
        language:
          type: [string, "null"]

    PublicSourceLink:
      type: object
      required: [id, url]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^src_[a-f0-9]{24}$"
        url:
          type: string
          format: uri

    PublicReportSignal:
      type: object
      required:
        [
          title,
          signal,
          domain,
          actionType,
          decision,
          justification,
          priority,
          confidence,
          inferenceType,
          timeHorizon,
          subjects,
          tags,
          sources,
        ]
      additionalProperties: false
      properties:
        title:
          type: string
        signal:
          type: string
        domain:
          type: string
        actionType:
          type: string
        decision:
          type: string
        justification:
          type: string
        priority:
          type: string
        confidence:
          type: number
          minimum: 0
          maximum: 1
        inferenceType:
          type: string
        timeHorizon:
          type: string
        subjects:
          type: array
          items:
            type: object
            required: [kind, label, key, entityId]
            additionalProperties: false
            properties:
              kind:
                type: string
              label:
                type: string
              key:
                type: string
              entityId:
                type: [string, "null"]
        tags:
          type: array
          items:
            type: string
        sources:
          type: array
          items:
            type: object
            required: [id, url]
            additionalProperties: false
            properties:
              id:
                type: string
                pattern: "^src_[a-f0-9]{24}$"
              url:
                type: string
                format: uri

    PublicReportGraph:
      type: object
      required: [generatedAt, summary, nodes, edges, incidents, sources]
      additionalProperties: false
      properties:
        generatedAt:
          type: string
          format: date-time
        summary:
          type: string
        nodes:
          type: array
          items:
            type: object
            required: [id, type, kind, label, summary, sources]
            additionalProperties: false
            properties:
              id:
                type: string
              type:
                type: string
                const: entity
              kind:
                type: string
              label:
                type: string
              summary:
                type: [string, "null"]
              sources:
                type: array
                items:
                  $ref: "#/components/schemas/PublicSourceLink"
        edges:
          type: array
          items:
            type: object
            required: [id, type, from, to, confidence, source]
            additionalProperties: false
            properties:
              id:
                type: string
              type:
                type: string
              from:
                type: string
              to:
                type: string
              confidence:
                type: number
              source:
                oneOf:
                  - $ref: "#/components/schemas/PublicSourceLink"
                  - type: "null"
        incidents:
          type: array
          items:
            type: object
            required:
              [
                id,
                type,
                title,
                category,
                severity,
                occurredAt,
                entityIds,
                sources,
              ]
            additionalProperties: false
            properties:
              id:
                type: string
              type:
                type: string
                const: incident
              title:
                type: string
              category:
                type: string
              severity:
                type: string
              occurredAt:
                type: string
                format: date-time
              entityIds:
                type: array
                items:
                  type: string
              sources:
                type: array
                items:
                  $ref: "#/components/schemas/PublicSourceLink"
        sources:
          type: array
          items:
            $ref: "#/components/schemas/PublicSourceLink"

    PublicReportDetail:
      allOf:
        - $ref: "#/components/schemas/PublicReport"
        - type: object
          properties:
            profile:
              type: object
              required: [id, name, topic]
              properties:
                id:
                  type: string
                name:
                  type: [string, "null"]
                topic:
                  type: [string, "null"]
            content:
              type: object
              required: [markdown, mediaType]
              properties:
                markdown:
                  type: string
                mediaType:
                  type: string
                  const: text/markdown
            sources:
              type: array
              items:
                $ref: "#/components/schemas/PublicSource"
            signals:
              type: array
              items:
                $ref: "#/components/schemas/PublicReportSignal"
            graph:
              $ref: "#/components/schemas/PublicReportGraph"
            audioRepresentation:
              $ref: "#/components/schemas/AudioMetadata"
      unevaluatedProperties: false

    ReportSignalsResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required:
            [
              reportId,
              profileId,
              reportGeneratedAt,
              reportGeneratedAtISO,
              signals,
            ]
          properties:
            reportId:
              type: string
              pattern: "^rpt_[a-f0-9]{24}$"
            profileId:
              type: string
              pattern: "^prf_[a-f0-9]{24}$"
            reportGeneratedAt:
              type: integer
              format: int64
              deprecated: true
            reportGeneratedAtISO:
              type: string
              format: date-time
            topic:
              type: [string, "null"]
            summary:
              type: [string, "null"]
            generatedAt:
              type: [integer, "null"]
              format: int64
              deprecated: true
            generatedAtISO:
              type: [string, "null"]
              format: date-time
            signals:
              type: array
              items:
                $ref: "#/components/schemas/PublicReportSignal"
        meta:
          type: object
          required: [count]
          properties:
            count:
              type: integer

    ReportGraphResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required:
            [
              reportId,
              profileId,
              reportGeneratedAt,
              reportGeneratedAtISO,
              graph,
            ]
          properties:
            reportId:
              type: string
              pattern: "^rpt_[a-f0-9]{24}$"
            profileId:
              type: string
              pattern: "^prf_[a-f0-9]{24}$"
            reportGeneratedAt:
              type: integer
              format: int64
              deprecated: true
            reportGeneratedAtISO:
              type: string
              format: date-time
            topic:
              type: [string, "null"]
            graph:
              oneOf:
                - $ref: "#/components/schemas/PublicReportGraph"
                - type: "null"
        meta:
          type: object
          required: [nodeCount, edgeCount, incidentCount]
          properties:
            nodeCount:
              type: integer
            edgeCount:
              type: integer
            incidentCount:
              type: integer

    AudioMetadata:
      type: ["object", "null"]
      properties:
        url:
          type: string
          format: uri
          description: CDN URL for audio file
        duration:
          type: number
          deprecated: true
          description: Duration in seconds
        durationSeconds:
          type: [number, "null"]
          description: Canonical duration in seconds.
        durationFormatted:
          type: string
          description: Duration as HH:MM:SS
          example: "00:05:32"
        format:
          type: string
          enum: [mp3]
        mimeType:
          type: string
          enum: [audio/mpeg]
        fileSizeBytes:
          type: [integer, "null"]
          description: File size in bytes.

    AudioResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/AudioMetadata"

    ReportTextResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          required: [text, wordCount, readingTimeMinutes]
          properties:
            text:
              type: string
              description: Report content as plain text (HTML stripped)
            wordCount:
              type: integer
              description: Total word count
              example: 1250
            readingTimeMinutes:
              type: integer
              description: Estimated reading time in minutes (~200 wpm)
              example: 7

    ReportAudioTextResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          required: [text, charCount, estimatedAudioDuration]
          properties:
            text:
              type: string
              description: TTS-preprocessed text with pronunciation normalization and branding
            charCount:
              type: integer
              description: Character count of the preprocessed text
              example: 8500
            estimatedAudioDuration:
              type: integer
              description: Estimated audio duration in seconds (~750 chars/min)
              example: 420
            profileName:
              type: string
              description: Profile name used in branding intro/outro

    RecursionMetadata:
      type: object
      description: Metadata about recursive research execution
      properties:
        depth:
          type: integer
          description: Recursion depth achieved (0 = standard report)
        strategy:
          type: string
          enum: [breadth-first, depth-first, hybrid]
        layersProcessed:
          type: integer
        subtopicsGenerated:
          type: array
          items:
            type: string
        totalTimeMs:
          type: integer
        totalSourcesCollected:
          type: integer
        uniqueSourcesAggregated:
          type: integer
        fallbackReason:
          type: string
          description: Reason if fallback to standard generation occurred

    FreshnessMetadata:
      type: object
      description: Source freshness validation results
      properties:
        averageAgeMs:
          type: integer
          description: Average source age in milliseconds
        freshnessScore:
          type: number
          minimum: 0
          maximum: 1
          description: Overall freshness score (higher = fresher)
        staleSourcesCount:
          type: integer
        accessibleLinks:
          type: integer
        totalLinks:
          type: integer
        validatedAt:
          type: integer
          format: int64

    # =========================================================================
    # Profile Schemas
    # =========================================================================
    ProfileListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ProfileSubscription"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    ProfileDetailResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/PublicProfile"
        meta:
          type: object
          required: [asOf]
          properties:
            asOf: { type: string, format: date-time }

    ProfileSubscription:
      type: object
      required: [subscription, profile]
      properties:
        subscription:
          $ref: "#/components/schemas/PublicSubscription"
        profile:
          oneOf:
            - $ref: "#/components/schemas/PublicProfile"
            - type: "null"

    PublicSubscription:
      type: object
      required: [id, type, profileId, active, subscribedAt, delivery, links]
      properties:
        id:
          type: string
          pattern: "^sub_[a-f0-9]{24}$"
        type:
          type: string
          const: subscription
        profileId:
          type: string
          pattern: "^prf_[a-f0-9]{24}$"
        active:
          type: boolean
        subscribedAt:
          type: string
          format: date-time
        delivery:
          type: object
          required: [method, emailAudience, webhookId]
          properties:
            method:
              $ref: "#/components/schemas/DeliveryMethodEnum"
            emailAudience:
              $ref: "#/components/schemas/EmailAudienceEnum"
            webhookId:
              type: [string, "null"]
              pattern: "^whk_[a-f0-9]{24}$"
        links:
          type: object
          required: [delivery]
          properties:
            delivery: { type: string }

    PublicProfile:
      type: object
      required:
        [
          id,
          type,
          name,
          topic,
          status,
          frequency,
          schedule,
          visibility,
          tags,
          customInstructions,
          reportStructure,
          configuration,
          lastDeliveredAt,
          createdAt,
          links,
        ]
      properties:
        id:
          type: string
          pattern: "^prf_[a-f0-9]{24}$"
        type:
          type: string
          const: profile
        name: { type: string }
        topic: { type: string }
        status:
          $ref: "#/components/schemas/ProfileStatusEnum"
        frequency:
          oneOf:
            - $ref: "#/components/schemas/FrequencyEnum"
            - type: "null"
        schedule:
          type: object
          required: [cron, timezone]
          properties:
            cron: { type: string }
            timezone: { type: string, const: UTC }
        visibility:
          type: object
          required: [community, global]
          properties:
            community: { type: boolean }
            global: { type: boolean }
        tags:
          type: array
          items: { type: string }
        customInstructions: { type: [string, "null"] }
        reportStructure: { type: [string, "null"] }
        configuration:
          $ref: "#/components/schemas/PublicProfileConfiguration"
        lastDeliveredAt: { type: [string, "null"], format: date-time }
        createdAt: { type: string, format: date-time }
        links:
          type: object
          required: [self, reports]
          properties:
            self: { type: string }
            reports: { type: string }

    PublicProfileConfiguration:
      type: object
      required: [search, model, budget, recursion, freshness, audio, tools]
      properties:
        search: { type: [object, "null"] }
        model: { type: [object, "null"] }
        budget: { type: [object, "null"] }
        recursion: { type: [object, "null"] }
        freshness: { type: [object, "null"] }
        audio:
          type: object
          required: [enabled, speed, instructions]
          properties:
            enabled: { type: boolean }
            speed: { type: [string, "null"], enum: [slow, normal, fast, null] }
            instructions: { type: [string, "null"] }
        tools: { type: [object, "null"] }

    FrequencyEnum:
      type: string
      description: Report generation frequency
      enum:
        - daily
        - weekly
        - biweekly
        - monthly

    ProfileStatusEnum:
      type: string
      description: Profile status
      enum:
        - active
        - paused
        - cancelled

    RecursionConfigInput:
      type: object
      required: [enabled, maxDepth, strategy]
      properties:
        enabled:
          type: boolean
          description: When false, runs root-topic research without child subtopics.
        maxDepth:
          type: integer
          description: |
            Requested child-layer depth. The current runtime defaults an enabled value of
            `0` to `1` and caps values above `1` at one child layer. This field is ignored
            when `enabled` is false.
        strategy:
          type: string
          enum: [breadth-first, depth-first, hybrid]
          description: |
            Stored strategy preference. The current report engine executes its implemented
            breadth-first child-search path for every value.

    ProfileCreateRequest:
      type: object
      required: [name, topic, frequency, scheduleTimeOfDay]
      properties:
        name:
          type: string
          description: Profile display name
          example: "Cybersecurity Weekly"
        topic:
          type: string
          description: Topic description for research
          example: "Cybersecurity threats, vulnerabilities, and defense strategies"
        frequency:
          $ref: "#/components/schemas/FrequencyEnum"
        scheduleTimeOfDay:
          type: string
          pattern: '^\d{2}:\d{2}$'
          description: Time of day for report generation (HH:mm, UTC)
          example: "09:00"
        scheduleDayOfWeek:
          type: string
          description: Weekday name (case-insensitive) or 0-6 (Sunday-Saturday), required for weekly profiles
          example: "monday"
        scheduleDayOfMonth:
          type: string
          description: Day of month for monthly profiles
          example: "1"
        customPrompt:
          type: string
          description: Custom system prompt for the AI analyst
        tags:
          type: array
          items:
            type: string
          description: Tags for categorization
        isCommunity:
          type: boolean
          description: Whether this is a community (public) profile
          default: false
        blufStructure:
          type: string
          description: Custom BLUF report structure template
        recursionConfig:
          $ref: "#/components/schemas/RecursionConfigInput"
        searchConfig:
          type: object
          description: Web search configuration
          properties:
            searchDepth:
              type: string
              enum: [basic, advanced]
            maxResults:
              type: integer
            timeRange:
              type: string
            topic:
              type: string
            includeDomains:
              type: array
              items:
                type: string
            excludeDomains:
              type: array
              items:
                type: string
        modelConfig:
          type: object
          description: AI model configuration
          properties:
            modelId:
              type: string
            temperature:
              type: number
            maxOutputTokens:
              type: integer
        budgetConfig:
          type: object
          description: Cost budget configuration
          properties:
            maxCostPerReport:
              type: number
            alertThreshold:
              type: number
        freshnessConfig:
          type: object
          description: Source freshness configuration
          properties:
            enabled:
              type: boolean
            maxAgeMs:
              type: integer
            preferRecentSources:
              type: boolean
            recencyWeight:
              type: number
            validateLinks:
              type: boolean
        audioConfig:
          type: object
          description: Audio generation configuration
          properties:
            enabled:
              type: boolean
            voiceId:
              type: string
            speed:
              type: number
        toolConfig:
          type: object
          description: Tool configuration for report generation
        brandingTemplateId:
          type: string
          description: Branding template ID (paid workspace feature)

    ProfileUpdateRequest:
      type: object
      description: "All fields are optional. Only supplied fields change."
      properties:
        name:
          type: string
        topic:
          type: string
        status:
          $ref: "#/components/schemas/ProfileStatusEnum"
        frequency:
          $ref: "#/components/schemas/FrequencyEnum"
        scheduleTimeOfDay:
          type: string
          pattern: '^\d{2}:\d{2}$'
        scheduleDayOfWeek:
          type: string
          description: Weekday name (case-insensitive) or 0-6 (Sunday-Saturday)
        scheduleDayOfMonth:
          type: string
        customPrompt:
          type: string
        tags:
          type: array
          items:
            type: string
        isCommunity:
          type: boolean
        blufStructure:
          type: string
        searchConfig:
          type: object
          properties:
            searchDepth:
              type: string
              enum: [basic, advanced]
            maxResults:
              type: integer
            timeRange:
              type: string
            topic:
              type: string
            includeDomains:
              type: array
              items:
                type: string
            excludeDomains:
              type: array
              items:
                type: string
        modelConfig:
          type: object
          properties:
            modelId:
              type: string
            temperature:
              type: number
            maxOutputTokens:
              type: integer
        budgetConfig:
          type: object
          properties:
            maxCostPerReport:
              type: number
            alertThreshold:
              type: number
        recursionConfig:
          $ref: "#/components/schemas/RecursionConfigInput"
        freshnessConfig:
          type: object
          properties:
            enabled:
              type: boolean
            maxAgeMs:
              type: integer
            preferRecentSources:
              type: boolean
            recencyWeight:
              type: number
            validateLinks:
              type: boolean
        audioConfig:
          type: object
          properties:
            enabled:
              type: boolean
            voiceId:
              type: string
            speed:
              type: number
        brandingTemplateId:
          type: string
          description: Branding template ID (paid workspace feature)

    ProfileReplaceRequest:
      allOf:
        - $ref: "#/components/schemas/ProfileCreateRequest"
        - $ref: "#/components/schemas/ProfileUpdateRequest"
      description: Full mutable profile state. Omitted optional fields reset to defaults.

    ProfileCreateResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/PublicProfile"
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Profile created"

    ProfileUpdateResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/PublicProfile"
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Profile updated"

    ProfileDeleteResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required: [profileId, deleted]
          properties:
            profileId:
              type: string
            deleted:
              type: boolean
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Profile deleted"

    # =========================================================================
    # Projects and Automations Schemas
    # =========================================================================
    ProjectStatus:
      type: string
      enum: [active, archived]

    Project:
      type: object
      required:
        - id
        - type
        - name
        - objective
        - instructions
        - status
        - contextPolicy
        - icon
        - color
        - revision
        - defaultView
        - defaultTimeWindow
        - pinned
        - lastActivityAt
        - createdAt
        - updatedAt
        - links
      properties:
        id:
          type: string
          pattern: "^prj_[a-f0-9]{24}$"
        type:
          type: string
          const: project
        name:
          type: string
          maxLength: 80
        objective:
          type: [string, "null"]
          maxLength: 1000
        instructions:
          type: [string, "null"]
          maxLength: 8000
        status:
          $ref: "#/components/schemas/ProjectStatus"
        contextPolicy:
          type: string
          const: project_only
        icon:
          type: [string, "null"]
          maxLength: 64
        color:
          type: [string, "null"]
          maxLength: 32
        revision:
          type: integer
          minimum: 1
        defaultView:
          type: string
          enum: [graph, timeline, situation, reports, evidence, knowledge]
        defaultTimeWindow:
          type: string
          enum: [24h, 7d, 30d, custom]
        pinned:
          type: boolean
        lastActivityAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        links:
          type: object
          required: [self, automations]
          properties:
            self: { type: string }
            automations: { type: string }

    ProjectCreateRequest:
      type: object
      required: [name]
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
        objective:
          type: string
          maxLength: 1000
        instructions:
          type: string
          maxLength: 8000
        icon:
          type: string
          maxLength: 64
        color:
          type: string
          maxLength: 32

    ProjectPatchRequest:
      type: object
      minProperties: 1
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
        objective:
          type: [string, "null"]
          maxLength: 1000
        instructions:
          type: [string, "null"]
          maxLength: 8000
        icon:
          type: [string, "null"]
          maxLength: 64
        color:
          type: [string, "null"]
          maxLength: 32
        defaultView:
          type: string
          enum: [graph, timeline, situation, reports, evidence, knowledge]
        defaultTimeWindow:
          type: string
          enum: [24h, 7d, 30d, custom]
        status:
          $ref: "#/components/schemas/ProjectStatus"
        pinned:
          type: boolean

    ProjectResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/Project"

    ProjectMutationResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/Project"
        meta:
          type: object
          required: [message]
          properties:
            message: { type: string }

    ProjectListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Project"
        meta:
          allOf:
            - $ref: "#/components/schemas/PublicListMeta"
            - type: object
              required: [status]
              properties:
                status:
                  $ref: "#/components/schemas/ProjectStatus"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    AutomationStatus:
      type: string
      enum: [draft, active, paused, archived]

    AutomationScheduleTrigger:
      type: object
      required: [kind, frequency, timeOfDay, timezone, dayOfWeek, dayOfMonth]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: schedule
        frequency:
          type: string
          enum: [daily, weekly, monthly]
        timeOfDay:
          type: string
          pattern: '^\d{2}:\d{2}$'
        timezone:
          type: string
        dayOfWeek:
          type: [integer, "null"]
          minimum: 0
          maximum: 6
        dayOfMonth:
          type: [integer, "null"]
          minimum: 1
          maximum: 31

    AutomationProfileTrigger:
      type: object
      required: [kind, profileId]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: profile_report_completed
        profileId:
          type: string
          pattern: "^prf_[a-f0-9]{24}$"

    AutomationTrigger:
      oneOf:
        - $ref: "#/components/schemas/AutomationScheduleTrigger"
        - $ref: "#/components/schemas/AutomationProfileTrigger"

    AutomationSchedule:
      type: object
      required: [status, nextRunAt, lastScheduledAt, lastFiredAt]
      properties:
        status:
          type: string
          enum: [scheduled, paused, stale]
        nextRunAt:
          type: string
          format: date-time
        lastScheduledAt:
          type: string
          format: date-time
        lastFiredAt:
          type: [string, "null"]
          format: date-time

    AutomationRun:
      type: object
      required:
        - id
        - type
        - automationId
        - projectId
        - reportId
        - triggerKind
        - status
        - definitionRevision
        - resultSummary
        - model
        - usage
        - skipReason
        - error
        - scheduledFor
        - createdAt
        - startedAt
        - completedAt
        - links
      properties:
        id:
          type: string
          pattern: "^arn_[a-f0-9]{24}$"
        type:
          type: string
          const: automation_run
        automationId:
          type: string
          pattern: "^atm_[a-f0-9]{24}$"
        projectId:
          type: [string, "null"]
          pattern: "^prj_[a-f0-9]{24}$"
        reportId:
          type: [string, "null"]
          pattern: "^rpt_[a-f0-9]{24}$"
        triggerKind:
          type: string
          enum: [manual, schedule, profile_report_completed]
        status:
          type: string
          enum: [queued, running, succeeded, failed, skipped, canceled]
        definitionRevision:
          type: integer
          minimum: 1
        resultSummary:
          type: [string, "null"]
        model:
          type: [string, "null"]
        usage:
          type: object
          required:
            [inputTokens, outputTokens, toolCounts, actualCostUsd, billingState]
          properties:
            inputTokens: { type: [integer, "null"] }
            outputTokens: { type: [integer, "null"] }
            toolCounts:
              type: object
              additionalProperties: { type: number }
            actualCostUsd: { type: [number, "null"] }
            billingState:
              type: string
              enum: [reserved, settled, released, none]
        skipReason:
          type: [string, "null"]
        error:
          oneOf:
            - type: "null"
            - type: object
              required: [code, message]
              properties:
                code: { type: [string, "null"] }
                message: { type: [string, "null"] }
        scheduledFor:
          type: [string, "null"]
          format: date-time
        createdAt:
          type: string
          format: date-time
        startedAt:
          type: [string, "null"]
          format: date-time
        completedAt:
          type: [string, "null"]
          format: date-time
        links:
          type: object
          required: [automation]
          properties:
            automation: { type: string }

    Automation:
      type: object
      required:
        - id
        - type
        - name
        - instructions
        - operation
        - projectId
        - trigger
        - notificationPolicy
        - overlapPolicy
        - status
        - definitionRevision
        - schedule
        - lastRun
        - createdAt
        - updatedAt
        - links
      properties:
        id:
          type: string
          pattern: "^atm_[a-f0-9]{24}$"
        type:
          type: string
          const: automation
        name:
          type: string
          maxLength: 100
        instructions:
          type: string
          maxLength: 8000
        operation:
          type: string
          const: agent_y2
        projectId:
          type: [string, "null"]
          pattern: "^prj_[a-f0-9]{24}$"
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        notificationPolicy:
          type: string
          enum: [all_runs, failures_only, none]
        overlapPolicy:
          type: string
          const: skip_if_running
        status:
          $ref: "#/components/schemas/AutomationStatus"
        definitionRevision:
          type: integer
          minimum: 1
        schedule:
          oneOf:
            - type: "null"
            - $ref: "#/components/schemas/AutomationSchedule"
        lastRun:
          oneOf:
            - type: "null"
            - $ref: "#/components/schemas/AutomationRun"
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        links:
          type: object
          required: [self, runs]
          properties:
            self: { type: string }
            runs: { type: string }

    AutomationCreateRequest:
      type: object
      required: [name, instructions, trigger, notificationPolicy]
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        instructions:
          type: string
          minLength: 1
          maxLength: 8000
        projectId:
          type: [string, "null"]
          pattern: "^prj_[a-f0-9]{24}$"
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        notificationPolicy:
          type: string
          enum: [all_runs, failures_only, none]
        status:
          type: string
          enum: [draft, active, paused]
          default: draft

    AutomationPatchRequest:
      type: object
      minProperties: 1
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        instructions:
          type: string
          minLength: 1
          maxLength: 8000
        projectId:
          type: [string, "null"]
          pattern: "^prj_[a-f0-9]{24}$"
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        notificationPolicy:
          type: string
          enum: [all_runs, failures_only, none]
        status:
          $ref: "#/components/schemas/AutomationStatus"

    AutomationResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/Automation"

    AutomationMutationResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/Automation"
        meta:
          type: object
          required: [message]
          properties:
            message: { type: string }

    AutomationListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Automation"
        meta:
          allOf:
            - $ref: "#/components/schemas/PublicListMeta"
            - type: object
              required: [status]
              properties:
                status:
                  oneOf:
                    - type: "null"
                    - $ref: "#/components/schemas/AutomationStatus"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    AutomationRunListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AutomationRun"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    AutomationRunRequestResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required: [type, status, automationId]
          properties:
            type:
              type: string
              const: automation_run_request
            status:
              type: string
              const: accepted
            automationId:
              type: string
              pattern: "^atm_[a-f0-9]{24}$"
        meta:
          type: object
          required: [message]
          properties:
            message: { type: string }

    # =========================================================================
    # News Schemas
    # =========================================================================
    NewsListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/NewsItem"
        meta:
          allOf:
            - $ref: "#/components/schemas/PublicListMeta"
            - type: object
              required: [topics]
              properties:
                topics:
                  type: array
                  items:
                    $ref: "#/components/schemas/TopicEnum"
                countryCode:
                  type: [string, "null"]
                  pattern: "^[A-Z]{2}$"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    NewsItem:
      type: object
      required:
        [
          id,
          type,
          title,
          summary,
          content,
          publishedAt,
          topics,
          sentiment,
          author,
          sources,
          links,
          geography,
        ]
      properties:
        id:
          type: string
          pattern: "^obs_[a-f0-9]{24}$"
        type:
          type: string
          const: news
        title:
          type: string
        summary:
          type: string
        content:
          type: string
        publishedAt:
          type: string
          format: date-time
        topics:
          type: array
          items: { type: string }
        sentiment:
          type: object
          required: [label, value]
          properties:
            label:
              $ref: "#/components/schemas/SentimentEnum"
            value: { type: number }
        sources:
          type: array
          items:
            $ref: "#/components/schemas/NewsSource"
        author:
          type: [string, "null"]
        links:
          type: object
          required: [canonical]
          properties:
            canonical: { type: [string, "null"], format: uri }
        geography:
          type: ["object", "null"]
          description: Normalized country, region, location, coordinates, and resolver provenance.
          properties:
            countryCode:
              type: string
              pattern: "^[A-Z]{2}$"
            region:
              type: string
            locationName:
              type: string
            lat:
              type: number
            lon:
              type: number
            provenance:
              type: object
              additionalProperties: true

    NewsSource:
      type: object
      required:
        [
          id,
          url,
          title,
          publisher,
          publishedAt,
          retrievedAt,
          sourceType,
          language,
        ]
      properties:
        id: { type: string, pattern: "^src_[a-f0-9]{24}$" }
        url: { type: [string, "null"], format: uri }
        title: { type: [string, "null"] }
        publisher: { type: [string, "null"] }
        publishedAt: { type: string, format: date-time }
        retrievedAt: { type: [string, "null"], format: date-time }
        sourceType: { type: string }
        language: { type: [string, "null"] }

    RecapResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          additionalProperties:
            type: object
            description: Topic recap data
        meta:
          type: object
          properties:
            timeframe:
              $ref: "#/components/schemas/TimeframeEnum"
            topics:
              type: array
              items:
                $ref: "#/components/schemas/TopicEnum"

    FeedListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Feed"
        meta:
          type: object
          properties:
            count:
              type: integer
            defaultTopics:
              type: array
              items:
                $ref: "#/components/schemas/TopicEnum"

    Feed:
      type: object
      required:
        - id
        - name
        - shortLabel
        - description
        - group
        - groupLabel
        - color
        - ingestOntology
        - source
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          $ref: "#/components/schemas/TopicEnum"
        name:
          type: string
          description: Human-readable name
          example: "Crypto"
        shortLabel:
          type: string
          description: Compact display name
        description:
          type: string
          description: Feed description
        group:
          type: string
          description: Machine-readable topic group ID
        groupLabel:
          type: string
          description: Human-readable topic group name
        color:
          type: string
          description: UI gradient classes associated with the feed
        ingestOntology:
          type: boolean
          description: Whether eligible signals can enter the OSINT ontology pipeline

    TopicEnum:
      type: string
      description: Available Y2 News Terminal feed topics
      enum:
        - ai
        - ai_agents
        - base
        - bitcoin
        - crypto
        - dats
        - defi
        - ethereum
        - hyperliquid
        - machine_learning
        - macro
        - on_chain_whale
        - perps
        - ripple
        - rwa
        - solana
        - tech
        - token_listings
        - virtuals
        - geopolitics
        - politics_us
        - defense
        - sanctions_trade
        - equities
        - rates_fx
        - commodities
        - banking_reg
        - energy
        - cyber
        - semiconductors
        - biotech
        - logistics
        - critical_minerals
        - telecom
        - region_mena
        - region_europe
        - region_asiapac
        - region_latam
        - region_africa
        - region_namerica

    SentimentEnum:
      type: ["string", "null"]
      description: Sentiment classification for news items
      enum:
        - bullish
        - bearish
        - neutral
        - null

    TimeframeEnum:
      type: string
      description: Time period for recap data
      default: 12h
      enum:
        - 12h
        - 24h
        - 3d
        - 7d

    # =========================================================================
    # OSINT Schemas
    # =========================================================================
    OsintEventCategoryEnum:
      type: string
      description: OSINT event category classification
      enum:
        - seismic
        - conflict
        - political
        - economic
        - weather
        - health
        - cyber
        - maritime
        - fire
        - aviation
        - other

    OsintSeverityEnum:
      type: string
      description: Event severity level
      enum:
        - low
        - medium
        - high
        - critical

    OsintRegionEnum:
      type: string
      description: Geographic region identifier
      enum:
        - mena
        - africa
        - latam
        - asiapac
        - europe
        - namerica

    EventTemporality:
      type: string
      enum: [current, forecast]
      default: current
      description: |
        Whether the event time is at or before the request time (plus 15 minutes of
        clock skew) — `current` — or after it — `forecast`.

    RecordSource:
      type: object
      required: [type, recordId, url, retrievedAt, method, tier]
      description: Where a record came from, how Y2 obtained it, and when.
      properties:
        type:
          type: string
          description: |
            Upstream source identifier, for example `usgs`, `nvd`, or `wingbits`.
            Records Y2 computes use a `y2_*` identifier such as `y2_report`,
            `y2_cii`, `y2_incident_resolution`, or `y2_entity_resolution`.
        recordId:
          type: ["string", "null"]
          description: The upstream record identifier, when the source provides one.
        url:
          type: ["string", "null"]
          format: uri
          description: Link to the upstream record or originating report.
        retrievedAt:
          type: ["string", "null"]
          format: date-time
          description: When Y2 retrieved or last refreshed the record.
        method:
          type: string
          enum: [ingested, extracted, computed]
          description: |
            `ingested` from an upstream feed, `extracted` from a Y2 report, or
            `computed` by Y2 from other records.
        tier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
          description: Provenance tier used for corroboration scoring.

    OsintEvent:
      type: object
      required:
        [
          id,
          sourceType,
          sourceId,
          title,
          category,
          severity,
          eventTime,
          temporality,
          source,
        ]
      properties:
        observedAt:
          type: ["string", "null"]
          format: date-time
          description: When Y2 retrieved or last refreshed this observation, independent of event time.
        temporality:
          $ref: "#/components/schemas/EventTemporality"
        confidence:
          type: ["number", "null"]
          minimum: 0
          maximum: 1
          description: Extraction confidence for report-derived rows; null for directly ingested rows.
        provenanceTier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: Event ID
        sourceType:
          type: string
          description: Data source type
        sourceId:
          type: string
          description: Source-specific event identifier
        title:
          type: string
          description: Event title/headline
        description:
          type: string
          description: Detailed event description
        category:
          $ref: "#/components/schemas/OsintEventCategoryEnum"
        severity:
          $ref: "#/components/schemas/OsintSeverityEnum"
        coordinates:
          type: ["object", "null"]
          description: Geographic coordinates (null if unavailable)
          properties:
            lat:
              type: number
              format: double
              description: Latitude
            lon:
              type: number
              format: double
              description: Longitude
        locationName:
          type: string
          description: Human-readable location name
        region:
          $ref: "#/components/schemas/OsintRegionEnum"
        countryCode:
          type: string
          description: ISO alpha-2 country code
          pattern: "^[A-Z]{2}$"
        eventTime:
          type: integer
          format: int64
          description: Event time as Unix timestamp (milliseconds)
        eventTimeISO:
          type: string
          format: date-time
          description: Event time as ISO 8601 string
        fetchedAt:
          type: ["integer", "null"]
          format: int64
          description: Data fetch time as Unix timestamp (milliseconds), null if unavailable
        fetchedAtISO:
          type: ["string", "null"]
          format: date-time
          description: Data fetch time as ISO 8601 string, null if unavailable
        url:
          type: string
          format: uri
          description: Source URL for the event
        provenance:
          description: |
            Extraction provenance metadata. Populated only when
            `sourceType === "y2_report"`. Null for all other sources.
            Returned by `/osint/regional`.
          oneOf:
            - $ref: "#/components/schemas/Y2EventProvenance"
            - type: "null"

    OsintMapEvent:
      type: object
      required:
        [
          id,
          category,
          severity,
          coordinates,
          title,
          eventTime,
          temporality,
          source,
        ]
      properties:
        observedAt:
          type: ["string", "null"]
          format: date-time
          description: When Y2 retrieved or last refreshed this observation, independent of event time.
        temporality:
          $ref: "#/components/schemas/EventTemporality"
        confidence:
          type: ["number", "null"]
          minimum: 0
          maximum: 1
          description: Extraction confidence for report-derived rows; null for directly ingested rows.
        provenanceTier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: Event ID
        category:
          $ref: "#/components/schemas/OsintEventCategoryEnum"
        severity:
          $ref: "#/components/schemas/OsintSeverityEnum"
        coordinates:
          type: object
          required: [lat, lon]
          description: "Geographic coordinates (always present: events without coordinates are excluded)"
          properties:
            lat:
              type: number
              format: double
              description: Latitude
            lon:
              type: number
              format: double
              description: Longitude
        title:
          type: string
          description: Event title/headline
        eventTime:
          type: integer
          format: int64
          description: Event time as Unix timestamp (milliseconds)
        eventTimeISO:
          type: string
          format: date-time
          description: Event time as ISO 8601 string
        sourceType:
          type: string
          description: Data source type
        description:
          type: string
          description: Detailed event description
        url:
          type: string
          format: uri
          description: Source URL for the event
        locationName:
          type: string
          description: Human-readable location name
        region:
          $ref: "#/components/schemas/OsintRegionEnum"
        countryCode:
          type: string
          description: ISO alpha-2 country code
          pattern: "^[A-Z]{2}$"

    CIIItem:
      type: object
      required: [id, category, value, delta, computedAt, source]
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: CII item ID
        category:
          type: string
          description: Conflict indicator category
        region:
          $ref: "#/components/schemas/OsintRegionEnum"
        value:
          type: number
          minimum: 0
          maximum: 100
          description: Conflict indicator value (0-100)
        delta:
          type: number
          description: Recent change in value
        components:
          type: object
          additionalProperties: true
          description: Breakdown of indicator components
        computedAt:
          type: integer
          format: int64
          description: Computation time as Unix timestamp (milliseconds)
        computedAtISO:
          type: string
          format: date-time
          description: Computation time as ISO 8601 string

    IntelBrief:
      type: object
      required: [briefText, generatedAt, generatedAtISO, publishedAt]
      properties:
        briefText:
          type: string
          description: AI-generated intelligence brief text
        generatedAt:
          type: integer
          format: int64
          description: Generation time as Unix timestamp (milliseconds)
        generatedAtISO:
          type: string
          format: date-time
        publishedAt:
          type: string
          format: date-time

    StockIndex:
      type: object
      required: [ticker, indexName, weeklyChange, currency, fetchedAt]
      properties:
        ticker:
          type: string
          description: Stock index ticker symbol
          example: "^GSPC"
        indexName:
          type: string
          description: Human-readable index name
          example: "S&P 500"
        currentPrice:
          type: number
          format: float
          description: Current index price/value
        weeklyChange:
          type: number
          format: float
          description: Weekly change percentage
        currency:
          type: string
          description: Currency code
          example: "USD"
        fetchedAt:
          type: integer
          format: int64
          description: Data fetch time as Unix timestamp (milliseconds)
        fetchedAtISO:
          type: string
          format: date-time
          description: Data fetch time as ISO 8601 string

    CountryPredictionMarket:
      type: object
      required:
        [
          id,
          type,
          marketId,
          title,
          probability,
          outcomes,
          probabilityBasis,
          source,
        ]
      description: |
        Polymarket-only prediction market shape returned by
        `/osint/countries/{countryCode}/predictions`. The unified
        Polymarket+Kalshi shape returned by `/osint/prediction-markets`
        is documented separately as `PredictionMarket`.
      properties:
        source:
          type: string
          const: polymarket
          description: Prediction market platform
        id:
          type: string
          pattern: "^mkt_[a-f0-9]{24}$"
        type:
          type: string
          const: prediction_market
        marketId:
          type: string
          description: Prediction market identifier
        title:
          type: string
          description: Market question/title
        probability:
          type: number
          minimum: 0
          maximum: 1
          description: Current probability (0-1)
        volume:
          type: number
          description: Trading volume
        liquidity:
          type: ["number", "null"]
          description: Market liquidity (null if unavailable)
        outcomes:
          type: array
          items:
            $ref: "#/components/schemas/PredictionOutcome"
          description: Typed outcome labels with normalized fractional probabilities.
        probabilityBasis:
          type: string
          const: fraction_0_to_1
        volumeMeasurement:
          $ref: "#/components/schemas/ProviderReportedMeasurement"
        liquidityMeasurement:
          $ref: "#/components/schemas/ProviderReportedMeasurement"
        slug:
          type: ["string", "null"]
          description: URL-friendly market slug (null if unavailable)
        polymarketUrl:
          type: string
          format: uri
          description: Polymarket URL for this market
        endDate:
          type: string
          format: date-time
          description: Market resolution date

    CountryNewsItem:
      type: object
      required:
        [
          id,
          title,
          severity,
          category,
          eventTime,
          sourceType,
          countryCode,
          temporality,
          source,
        ]
      properties:
        temporality:
          $ref: "#/components/schemas/EventTemporality"
        confidence:
          type: ["number", "null"]
          minimum: 0
          maximum: 1
          description: Extraction confidence for report-derived rows; null for directly ingested rows.
        provenanceTier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: News item ID
        title:
          type: string
          description: News headline
        description:
          type: string
          description: News description/summary
        severity:
          $ref: "#/components/schemas/OsintSeverityEnum"
        category:
          $ref: "#/components/schemas/OsintEventCategoryEnum"
        eventTime:
          type: integer
          format: int64
          description: Event time as Unix timestamp (milliseconds)
        eventTimeISO:
          type: string
          format: date-time
        occurredAt:
          type: string
          format: date-time
        observedAt:
          type: ["string", "null"]
          format: date-time
        fetchedAt:
          type: ["integer", "null"]
          format: int64
        fetchedAtISO:
          type: ["string", "null"]
          format: date-time
        url:
          type: string
          format: uri
          description: Source URL
        sourceType:
          type: string
          description: Data source type
        countryCode:
          type: string
          pattern: "^[A-Z]{2}$"
          description: Canonical ISO 3166-1 alpha-2 country code used by the indexed query.
        region:
          type: ["string", "null"]
          description: Normalized OSINT region, when known.
        locationName:
          type: ["string", "null"]
          description: Most specific resolved sovereign location, when known.
        coordinates:
          type: ["object", "null"]
          properties:
            lat:
              type: number
              format: double
            lon:
              type: number
              format: double
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        provenance:
          type: object
          required: [countryCodeBasis, geoResolution]
          properties:
            countryCodeBasis:
              type: string
              enum: [resolved_geography, indexed_observation]
            geoResolution:
              type: ["object", "null"]
              additionalProperties: true
              description: Resolver method, confidence, version, and chokepoint context when available.

    SourceStatus:
      type: object
      required:
        [
          sourceType,
          status,
          lastSuccessfulIngestAt,
          expectedCadenceSeconds,
          staleAfterSeconds,
          state,
          failureCount,
          source,
        ]
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        sourceType:
          type: string
          description: Data source identifier
        status:
          type: string
          enum: [healthy, degraded, stale, unavailable, unknown]
          description: |
            Source health. `healthy` means the source succeeded within
            `staleAfterSeconds`; an untripped circuit breaker whose last success is
            older reports `stale`. Use this field, not `state`, to judge freshness.
        lastSuccessfulIngestAt:
          type: ["string", "null"]
          format: date-time
          description: Last successful ingest time, or null if the source has never succeeded
        expectedCadenceSeconds:
          type: integer
          minimum: 1
          description: How often the source is expected to refresh
        staleAfterSeconds:
          type: integer
          minimum: 1
          description: Age of the last success after which the source reports `stale`
        state:
          type: string
          enum: [closed, open, half_open]
          description: |
            Circuit breaker state. `closed` means requests are not being blocked;
            it does not mean the source is fresh.
        failureCount:
          type: integer
          description: Number of consecutive failures
        lastSuccessAt:
          type: integer
          format: int64
          description: Last successful fetch time (milliseconds)
        lastSuccessAtISO:
          type: ["string", "null"]
          format: date-time
          description: Last successful fetch time as ISO 8601 string
        lastFailureAt:
          type: integer
          format: int64
          description: Last failure time (milliseconds)
        lastFailureAtISO:
          type: ["string", "null"]
          format: date-time
          description: Last failure time as ISO 8601 string
        lastError:
          type: string
          description: Most recent error message

    CountryCIIItem:
      type: object
      required:
        [countryCode, countryName, value, baseline, delta, computedAt, source]
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        countryCode:
          type: string
          description: ISO alpha-2 country code
          pattern: "^[A-Z]{2}$"
        countryName:
          type: string
          description: Country display name
        value:
          type: number
          minimum: 0
          maximum: 100
          description: Current instability index (0-100)
        baseline:
          type: number
          description: Baseline instability score for this country
        delta:
          type: number
          description: Change from baseline
        components:
          type: object
          description: Breakdown of instability components
          properties:
            unrest:
              type: number
            security:
              type: number
            info:
              type: number
            eventCounts:
              type: object
            multiplier:
              type: number
        computedAt:
          type: integer
          format: int64
          description: Computation time as Unix timestamp (milliseconds)
        computedAtISO:
          type: string
          format: date-time
          description: Computation time as ISO 8601 string

    MilitaryPostureItem:
      type: object
      required:
        [
          id,
          type,
          theater,
          posture,
          aircraftCount,
          computedAt,
          observedAt,
          source,
        ]
      description: |
        Y2's posture assessment for one theater, computed every 15 minutes from
        the adsb.lol military aircraft inside the theater's bounds.
      properties:
        id:
          type: string
          description: Public observation identifier for this assessment.
        type:
          type: string
          const: posture_observation
        theater:
          type: string
          description: Theater identifier such as `iran`, `taiwan`, `blacksea`, or `scs`.
        posture:
          type: string
          enum: [normal, elevated, critical]
          description: Current military posture assessment
        aircraftCount:
          type: integer
          description: Military aircraft inside the theater at `computedAt`.
        breakdown:
          type: object
          description: Aircraft counts by type, the strike assessment, and up to 50 positions.
          properties:
            tanker:
              type: integer
            awacs:
              type: integer
            fighter:
              type: integer
            recon:
              type: integer
            transport:
              type: integer
            bomber:
              type: integer
            drone:
              type: integer
            military_generic:
              type: integer
            unknown:
              type: integer
            theaterName:
              type: string
            strikeCapable:
              type: boolean
            activeOperations:
              type: array
              items:
                type: string
            flights:
              type: array
              items:
                type: object
                properties:
                  callsign:
                    type: string
                  type:
                    type: string
                  lat:
                    type: number
                  lon:
                    type: number
                  altitude:
                    type: number
                    description: Barometric altitude in feet.
        computedAt:
          type: integer
          format: int64
          description: Assessment time as Unix timestamp (milliseconds)
        observedAt:
          type: string
          format: date-time
          description: Assessment time as ISO 8601.
        source:
          $ref: "#/components/schemas/RecordSource"

    AircraftTrack:
      type: object
      required:
        [
          id,
          type,
          icao24,
          callsign,
          aircraftType,
          operator,
          confidence,
          coordinates,
          geometry,
          altitude,
          heading,
          speed,
          theater,
          isInteresting,
          lastSeenAt,
          lastSeenAtISO,
          observedAt,
          source,
        ]
      description: |
        A military aircraft position from the adsb.lol community ADS-B network,
        refreshed every 15 minutes and expiring 30 minutes after `lastSeenAt`.
      properties:
        id:
          type: string
          description: Public observation identifier for this position.
        type:
          type: string
          const: aircraft_observation
        icao24:
          type: string
          description: ICAO 24-bit transponder address, lowercase hex.
        callsign:
          type: string
          description: Aircraft callsign, or `UNKNOWN`.
        registration:
          type: ["string", "null"]
          description: Registration as reported by ADS-B, when known.
        typeCode:
          type: ["string", "null"]
          description: ICAO type designator such as `KC135`, when known.
        squawk:
          type: ["string", "null"]
          description: Transponder squawk, when known.
        aircraftType:
          type: string
          enum:
            [
              fighter,
              tanker,
              awacs,
              recon,
              transport,
              bomber,
              drone,
              military_generic,
              unknown,
            ]
          description: |
            Y2's type classification. `military_generic` means only the ADS-B
            database military flag is known.
        operator:
          type: string
          description: Operating entity, or `unknown`.
        confidence:
          type: string
          enum: [high, medium, low]
          description: Classification confidence.
        coordinates:
          type: object
          required: [lat, lon]
          properties:
            lat:
              type: number
              format: double
            lon:
              type: number
              format: double
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        altitude:
          type: number
          description: Barometric altitude in meters; 0 on the ground.
        heading:
          type: number
          description: Track over ground in degrees true.
        speed:
          type: number
          description: Ground speed in meters per second.
        position:
          type: object
          required: [altitude]
          properties:
            altitude:
              type: object
              required: [value, unit, reference]
              properties:
                value:
                  type: number
                unit:
                  type: string
                  const: meter
                reference:
                  type: string
                  const: barometric
        motion:
          type: object
          required: [speed, heading]
          properties:
            speed:
              type: object
              required: [value, unit]
              properties:
                value:
                  type: number
                unit:
                  type: string
                  const: meter_per_second
            heading:
              type: object
              required: [value, unit]
              properties:
                value:
                  type: number
                unit:
                  type: string
                  const: degree_true
        theater:
          type: string
          description: Smallest configured theater containing the position.
        isInteresting:
          type: boolean
          description: Bomber, AWACS, reconnaissance aircraft, or an emergency squawk.
        lastSeenAt:
          type: integer
          format: int64
          description: Last seen time as Unix timestamp (milliseconds)
        lastSeenAtISO:
          type: string
          format: date-time
          description: Last seen time as ISO 8601 string
        observedAt:
          type: string
          format: date-time
          description: The `lastSeenAt` value as ISO 8601.
        source:
          $ref: "#/components/schemas/RecordSource"

    NavalVessel:
      type: object
      required: [id, name, vesselType, coordinates]
      properties:
        id:
          type: string
          description: Vessel ID
        name:
          type: string
          description: Vessel name
        hullNumber:
          type: string
          description: Hull number designation
        vesselType:
          type: string
          description: Vessel type classification
        operator:
          type: string
          description: Operating navy
        region:
          type: string
          description: Deployment region
        strikeGroup:
          type: string
          description: Strike group assignment
        status:
          type: string
          description: Current operational status
        coordinates:
          type: object
          required: [lat, lon]
          properties:
            lat:
              type: number
              format: double
            lon:
              type: number
              format: double
        confidence:
          type: string
          enum: [low, medium, high]
          description: Categorical position confidence from the source model.
        source:
          type: string
          description: Data source
        fetchedAt:
          type: integer
          format: int64
          description: Fetch time as Unix timestamp (milliseconds)
        fetchedAtISO:
          type: string
          format: date-time
          description: Fetch time as ISO 8601 string

    GPSJammingZone:
      type: object
      required: [id, h3Index, coordinates, severity, fetchedAt, source]
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: Zone ID
        h3Index:
          type: string
          description: H3 hexagonal cell index
        coordinates:
          type: object
          required: [lat, lon]
          properties:
            lat:
              type: number
              format: double
            lon:
              type: number
              format: double
        sampleCount:
          type: integer
          description: Number of ADS-B samples in this cell
        aircraftCount:
          type: integer
          description: Number of distinct aircraft reporting
        navAccuracyAvg:
          type: number
          description: Average navigation accuracy category
        severity:
          type: string
          description: Severity classification of interference
        fetchedAt:
          type: integer
          format: int64
          description: Fetch time as Unix timestamp (milliseconds)
        fetchedAtISO:
          type: string
          format: date-time
          description: Fetch time as ISO 8601 string

    OsintEventListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OsintEvent"
        meta:
          type: object
          properties:
            page:
              $ref: "#/components/schemas/PublicPageMeta"
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit
            filters:
              type: object
              properties:
                category:
                  type: ["string", "null"]
                severity:
                  type: ["string", "null"]
                temporality:
                  $ref: "#/components/schemas/EventTemporality"

    OsintMapEventListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OsintMapEvent"
        meta:
          type: object
          properties:
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit
            filters:
              type: object
              properties:
                region:
                  type: ["string", "null"]
                temporality:
                  $ref: "#/components/schemas/EventTemporality"

    CIIListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CIIItem"
        meta:
          type: object
          properties:
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit
            filters:
              type: object
              properties:
                region:
                  type: ["string", "null"]
                category:
                  type: ["string", "null"]

    IntelBriefResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          allOf:
            - $ref: "#/components/schemas/IntelBrief"

    StockIndexResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          allOf:
            - $ref: "#/components/schemas/StockIndex"

    CountryPredictionMarketListResponse:
      type: object
      required: [data, meta]
      description: |
        Response wrapper for `/osint/countries/{countryCode}/predictions`.
        See `PredictionMarketListResponse` for the unified
        Polymarket+Kalshi response wrapper used by `/osint/prediction-markets`.
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CountryPredictionMarket"
        meta:
          type: object
          properties:
            page:
              $ref: "#/components/schemas/PublicPageMeta"
            countryCode:
              type: string
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit

    CountryNewsListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CountryNewsItem"
        meta:
          type: object
          properties:
            countryCode:
              type: string
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit

    CountryCIIResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          allOf:
            - $ref: "#/components/schemas/CountryCIIItem"
        meta:
          type: object
          properties:
            countryCode:
              type: string

    MilitaryPostureListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MilitaryPostureItem"
        meta:
          allOf:
            - $ref: "#/components/schemas/FeedAvailabilityMeta"
            - type: object
              properties:
                count:
                  type: integer
                limit:
                  type: integer
                hasMore:
                  type: boolean
                  description: Whether more results are available beyond the current limit

    AircraftListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AircraftTrack"
        meta:
          allOf:
            - $ref: "#/components/schemas/FeedAvailabilityMeta"
            - type: object
              properties:
                count:
                  type: integer
                limit:
                  type: integer
                hasMore:
                  type: boolean
                  description: Whether more results are available beyond the current limit
                filters:
                  type: object
                  properties:
                    theater:
                      type: ["string", "null"]

    VesselListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/NavalVessel"
        meta:
          allOf:
            - $ref: "#/components/schemas/FeedAvailabilityMeta"
            - type: object
              properties:
                count:
                  type: integer
                limit:
                  type: integer
                hasMore:
                  type: boolean
                  description: Whether more results are available beyond the current limit
                filters:
                  type: object
                  properties:
                    region:
                      type: ["string", "null"]

    GPSJammingListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/GPSJammingZone"
        meta:
          allOf:
            - $ref: "#/components/schemas/FeedAvailabilityMeta"
            - type: object
              properties:
                count:
                  type: integer
                limit:
                  type: integer
                hasMore:
                  type: boolean
                  description: Whether more results are available beyond the current limit
                filters:
                  type: object
                  properties:
                    severity:
                      type: ["string", "null"]

    FeedAvailabilityMeta:
      type: object
      required: [emptyReason, sourceStatus, lastSuccessfulIngestAt]
      properties:
        emptyReason:
          type: [string, "null"]
          enum:
            [
              no_matching_activity,
              source_degraded,
              source_stale,
              source_unavailable,
              source_unknown,
              null,
            ]
        sourceStatus:
          type: string
          enum: [healthy, degraded, stale, unavailable, unknown]
        lastSuccessfulIngestAt:
          type: [string, "null"]
          format: date-time

    SourceStatusListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SourceStatus"
        meta:
          type: object
          properties:
            count:
              type: integer

    # =========================================================================
    # Y2 Event Provenance Schemas
    # =========================================================================

    EntityKind:
      type: string
      enum:
        [
          person,
          organization,
          country,
          region,
          vessel,
          aircraft,
          facility,
          asset,
          indicator,
          cve,
          malware_family,
          threat_actor,
          vendor,
          software,
          ai_model,
          api_service,
          protocol,
        ]

    Y2EventProvenance:
      type: object
      required: [source]
      properties:
        source:
          type: string
          description: Source identifier (always "y2_report")
          enum: [y2_report]
        classification:
          type: string
          description: Event temporal classification from GroundSource methodology
          enum: [ongoing, past, forecast, analysis]
        confidence:
          type: number
          format: double
          minimum: 0
          maximum: 1
          description: Extraction confidence score (0.5-1.0)
        entities:
          type: array
          description: Named entities extracted from the report
          items:
            type: object
            required: [name, kind]
            properties:
              name:
                type: string
                description: Entity name
              kind:
                $ref: "#/components/schemas/EntityKind"
                description: Entity type

    Y2Event:
      type: object
      required:
        [
          id,
          sourceType,
          title,
          category,
          severity,
          eventTime,
          temporality,
          source,
        ]
      properties:
        observedAt:
          type: ["string", "null"]
          format: date-time
          description: When Y2 retrieved or last refreshed this observation, independent of event time.
        temporality:
          $ref: "#/components/schemas/EventTemporality"
        confidence:
          type: ["number", "null"]
          minimum: 0
          maximum: 1
          description: Extraction confidence for report-derived rows; null for directly ingested rows.
        provenanceTier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          description: Event ID
        sourceType:
          type: string
          description: Data source type (always "y2_report")
          enum: [y2_report]
        title:
          type: string
          description: Event title/headline
        description:
          type: string
          description: Detailed event description
        category:
          $ref: "#/components/schemas/OsintEventCategoryEnum"
        severity:
          $ref: "#/components/schemas/OsintSeverityEnum"
        coordinates:
          type: ["object", "null"]
          description: Geographic coordinates (null if unavailable)
          properties:
            lat:
              type: number
              format: double
              description: Latitude
            lon:
              type: number
              format: double
              description: Longitude
        locationName:
          type: string
          description: Human-readable location name
        countryCode:
          type: string
          description: ISO alpha-2 country code
          pattern: "^[A-Z]{2}$"
        region:
          $ref: "#/components/schemas/OsintRegionEnum"
        eventTime:
          type: integer
          format: int64
          description: Event time as Unix timestamp (milliseconds)
        url:
          type: string
          description: Link to the originating report
        provenance:
          description: Extraction provenance metadata linking to the Y2 report
          oneOf:
            - $ref: "#/components/schemas/Y2EventProvenance"
            - type: "null"

    Y2EventListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Y2Event"
        meta:
          type: object
          properties:
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit

    # =========================================================================
    # FININT (Financial Intelligence) Schemas
    # =========================================================================

    FinintIndicator:
      type: object
      required:
        [indicatorId, source, sourceUrl, label, category, value, fetchedAt]
      properties:
        period:
          $ref: "#/components/schemas/FinintPeriod"
        provenance:
          $ref: "#/components/schemas/FinintProvenance"
        indicatorId:
          type: string
          description: |
            Unique indicator key. Aggregate rows use `<SOURCE>:<METRIC>`
            (e.g., `FRED:DGS10`, `YF:^GSPC`, `EIA:WTI`). Per-dimension
            rows use `<SOURCE>:<METRIC>:<DIMENSION>`
            (e.g., `EIA:NUKE_OUTAGE:vogtle`, `EIA:RTO_LOAD:PJM`,
            `EIA:CRUDE_IMPORT:houston`).
        source:
          type: string
          enum: [fred, yfinance, eia]
          description: Data source
        sourceUrl:
          type: [string, "null"]
          format: uri
          description: Canonical provider page for this indicator
        label:
          type: string
          description: Human-readable indicator name
        category:
          type: string
          enum:
            [
              rates,
              credit,
              inflation,
              labor,
              gdp,
              business,
              consumer,
              housing,
              money_supply,
              volatility,
              commodities,
              fx,
              equities,
              energy,
              crypto,
            ]
          description: Indicator category
        value:
          type: number
          description: Current indicator value
        previousValue:
          type: [number, "null"]
          description: Previous value (for change calculation)
        change:
          type: [number, "null"]
          description: Absolute change from previous value
        changePct:
          type: [number, "null"]
          description: Percentage change from previous value
        unit:
          type: [string, "null"]
          description: Value unit (e.g., "%", "$", "index", "$/bbl")
        recent:
          type: array
          description: Recent data points for sparkline rendering
          items:
            type: object
            properties:
              value:
                type: number
              date:
                type: string
        signals:
          type: array
          description: Active signal descriptions (threshold crossings)
          items:
            type: string
        fetchedAt:
          type: integer
          format: int64
          description: Unix timestamp of last data fetch
        dimension:
          type: [string, "null"]
          description: |
            Dimension key (e.g., `vogtle`, `PJM`, `houston`). Null on
            US-aggregate rows.
        dimensionType:
          type: [string, "null"]
          enum: [facility, rto, port, state, null]
          description: |
            Dimension classifier. Null on US-aggregate rows. Currently only
            EIA emits per-dimension rows.
        lat:
          type: [number, "null"]
          format: double
          description: Latitude of the dimension (facility/RTO HQ/port). Null on aggregate rows.
        lon:
          type: [number, "null"]
          format: double
          description: Longitude of the dimension. Null on aggregate rows.

    FinintIndicatorListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/FinintIndicator"
        meta:
          type: object
          properties:
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
              description: Whether more results are available beyond the current limit
            filters:
              type: object
              description: Applied filter values
              properties:
                category:
                  type: [string, "null"]
                source:
                  type: [string, "null"]
                dimensionType:
                  type: [string, "null"]

    # =========================================================================
    # Cyber Threat Schemas
    # =========================================================================

    CyberThreat:
      type: object
      required:
        [
          id,
          type,
          sourceType,
          sourceId,
          title,
          severity,
          eventTime,
          eventTimeISO,
          occurredAt,
          observedAt,
          temporality,
          source,
        ]
      properties:
        id:
          type: string
          description: Stable public observation ID
        type:
          type: string
          const: observation
        sourceType:
          type: string
          enum: [urlhaus, feodo, rss]
          description: Threat intelligence source
        sourceId:
          type: string
          description: Source-specific identifier
        title:
          type: string
          description: Threat description
        description:
          type: [string, "null"]
        category:
          $ref: "#/components/schemas/OsintEventCategoryEnum"
        severity:
          $ref: "#/components/schemas/OsintSeverityEnum"
        coordinates:
          type: ["object", "null"]
          description: Country-centroid coordinates for geolocated infrastructure, null otherwise
          properties:
            lat:
              type: number
              format: double
            lon:
              type: number
              format: double
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        locationName:
          type: [string, "null"]
        region:
          $ref: "#/components/schemas/OsintRegionEnum"
        countryCode:
          type: [string, "null"]
          description: ISO alpha-2 country code of threat origin
        eventTime:
          type: integer
          format: int64
          description: |
            Provider occurrence time in Unix milliseconds: when URLhaus first saw the
            URL, or when Y2 observed a Feodo C2 server online.
        eventTimeISO:
          type: string
          format: date-time
        occurredAt:
          type: string
          format: date-time
          description: The `eventTime` value as ISO 8601.
        observedAt:
          type: ["string", "null"]
          format: date-time
          description: When Y2 retrieved or last refreshed this indicator, independent of event time.
        temporality:
          $ref: "#/components/schemas/EventTemporality"
        confidence:
          type: ["number", "null"]
          minimum: 0
          maximum: 1
          description: Always null for directly ingested indicators.
        provenanceTier:
          type: ["string", "null"]
          enum: [primary, derived, synthesized, null]
        source:
          $ref: "#/components/schemas/RecordSource"
        url:
          type: [string, "null"]
          format: uri
          description: |
            Provider report page for URLhaus and Feodo rows (never the malicious URL
            itself), or the article link for RSS rows.
        threat:
          type: [object, "null"]
          description: Threat-specific metadata; null for RSS cyber-feed rows
          properties:
            type:
              type: [string, "null"]
              description: Threat type (malware_distribution, phishing, c2, etc.)
            tags:
              type: [array, "null"]
              items:
                type: string
              description: Threat tags (ransomware, botnet, etc.)
            host:
              type: [string, "null"]
              description: Host IP or domain
            source:
              type: [string, "null"]
              description: Intelligence source (urlhaus, feodo)

    CyberThreatListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CyberThreat"
        meta:
          type: object
          properties:
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
            filters:
              type: object
              properties:
                severity:
                  type: [string, "null"]

    # =========================================================================
    # Prediction Market Schemas
    # =========================================================================

    PredictionMarket:
      type: object
      required:
        [
          id,
          type,
          marketId,
          title,
          probability,
          volume,
          outcomes,
          probabilityBasis,
          volumeMeasurement,
          source,
        ]
      properties:
        id:
          type: string
          pattern: "^mkt_[a-f0-9]{24}$"
        type:
          type: string
          const: prediction_market
        marketId:
          type: string
          description: Market identifier (Polymarket event ID or Kalshi ticker)
        title:
          type: string
          description: Market question
        eventTitle:
          type: [string, "null"]
          description: Parent event title
        probability:
          type: number
          minimum: 0
          maximum: 1
          description: Current normalized probability from 0 to 1.
        volume:
          type: number
          description: Total trading volume
        liquidity:
          type: number
          description: Current liquidity
        outcomes:
          type: array
          items:
            $ref: "#/components/schemas/PredictionOutcome"
          description: Typed outcome labels with normalized fractional probabilities.
        probabilityBasis:
          type: string
          const: fraction_0_to_1
        volumeMeasurement:
          $ref: "#/components/schemas/ProviderReportedMeasurement"
        url:
          type: [string, "null"]
          description: Market URL (Polymarket or Kalshi)
        endDate:
          type: [string, "null"]
          description: Market close date
        source:
          type: string
          enum: [polymarket, kalshi]
          description: Prediction market platform

    PredictionOutcome:
      type: object
      required: [label, probability]
      additionalProperties: false
      properties:
        label:
          type: string
        probability:
          type: number
          minimum: 0
          maximum: 1

    ProviderReportedMeasurement:
      type: object
      required: [value, currency, basis]
      additionalProperties: false
      properties:
        value:
          type: [number, "null"]
        currency:
          type: [string, "null"]
          description: "ISO 4217 code when the source identifies one. Otherwise null."
        basis:
          type: string
          const: provider_reported

    PredictionMarketListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PredictionMarket"
        meta:
          type: object
          properties:
            page:
              $ref: "#/components/schemas/PublicPageMeta"
            count:
              type: integer
            limit:
              type: integer
            hasMore:
              type: boolean
            filters:
              type: object
              properties:
                countryCode:
                  type: [string, "null"]

    # =========================================================================
    # Webhook Management Schemas
    # =========================================================================

    WebhookConfig:
      type: object
      required:
        [
          id,
          type,
          name,
          url,
          status,
          signing,
          customHeaders,
          deliveryHealth,
          createdAt,
          updatedAt,
          links,
        ]
      properties:
        id:
          type: string
          pattern: "^whk_[a-f0-9]{24}$"
          description: Stable public webhook configuration ID
        type:
          type: string
          const: webhook
        name:
          type: string
          description: Webhook display name
        url:
          type: string
          format: uri
          description: Webhook endpoint URL
        status:
          type: string
          enum: [active, disabled]
        signing:
          type: object
          required: [configured, algorithm]
          properties:
            configured: { type: boolean }
            algorithm: { type: [string, "null"], enum: [hmac-sha256, null] }
        customHeaders:
          type: array
          description: "Configured header names. Values are never returned."
          items: { type: string }
        deliveryHealth:
          type: object
          required:
            [
              consecutiveFailures,
              lastUsedAt,
              lastSuccessAt,
              lastFailureAt,
              lastFailureReason,
              lastFailureStatus,
              disabledAt,
              disabledReason,
              verifiedAt,
            ]
          properties:
            consecutiveFailures: { type: integer, minimum: 0 }
            lastUsedAt: { type: [string, "null"], format: date-time }
            lastSuccessAt: { type: [string, "null"], format: date-time }
            lastFailureAt: { type: [string, "null"], format: date-time }
            lastFailureReason: { type: [string, "null"] }
            lastFailureStatus: { type: [integer, "null"] }
            disabledAt: { type: [string, "null"], format: date-time }
            disabledReason:
              {
                type: [string, "null"],
                enum: [consecutive_failures, endpoint_rejected, null],
              }
            verifiedAt:
              type: [string, "null"]
              format: date-time
              description: "Successful test of the current configuration. Valid for enabling within 15 minutes."
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        links:
          type: object
          required: [self, test]
          properties:
            self: { type: string }
            test: { type: string }

    WebhookListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WebhookConfig"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    WebhookCreateRequest:
      type: object
      required: [name, url]
      properties:
        name:
          type: string
          description: Webhook display name
          example: "My Webhook"
        url:
          type: string
          format: uri
          description: Webhook endpoint URL (must be HTTPS)
          example: "https://example.com/webhook"
        secret:
          type: string
          description: Shared secret for signature verification
        headers:
          type: object
          additionalProperties:
            type: string
          description: Custom headers to include in webhook deliveries

    WebhookCreateResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/WebhookConfig"
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Webhook configuration created"

    WebhookUpdateRequest:
      type: object
      description: "All fields are optional. Only supplied fields change."
      properties:
        name:
          type: string
        url:
          type: string
          format: uri
        secret:
          type: string
        headers:
          type: object
          additionalProperties:
            type: string
        isActive:
          type: boolean

    WebhookReplaceRequest:
      allOf:
        - $ref: "#/components/schemas/WebhookCreateRequest"
        - type: object
          properties:
            isActive:
              type: boolean
      description: "Full mutable webhook state. Omitted secret and headers are cleared. Omitted isActive preserves the current status. Enabling a disabled webhook requires a successful test of the same configuration within 15 minutes. Otherwise returns 409 WEBHOOK_TEST_REQUIRED."

    WebhookUpdateResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/WebhookConfig"
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Webhook configuration updated"

    WebhookDeleteResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required: [webhookId, deleted]
          properties:
            webhookId:
              type: string
            deleted:
              type: boolean
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Webhook configuration deleted"

    WebhookTestResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required: [success]
          properties:
            success:
              type: boolean
            statusCode:
              type: integer
              description: HTTP status code from the webhook endpoint
            error:
              type: string
              description: Error message if the test failed
            responseTime:
              type: integer
              description: Response time in milliseconds
        meta:
          type: object
          properties:
            message:
              type: string

    DeliveryMethodEnum:
      type: string
      description: Subscription delivery method
      enum:
        - email
        - sms
        - webhook
        - both_email_sms

    EmailAudienceEnum:
      type: string
      description: Email recipients for email-capable subscription delivery
      enum:
        - individual
        - workspace

    DeliveryUpdateRequest:
      type: object
      required: [deliveryMethod]
      properties:
        deliveryMethod:
          $ref: "#/components/schemas/DeliveryMethodEnum"
        emailAudience:
          $ref: "#/components/schemas/EmailAudienceEnum"
        webhookConfigId:
          type: string
          pattern: "^whk_[a-f0-9]{24}$"
          description: Required when deliveryMethod is "webhook"

    DeliveryUpdateResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          required: [id, type, delivery, links]
          properties:
            id:
              type: string
              pattern: "^sub_[a-f0-9]{24}$"
            type:
              type: string
              const: subscription
            delivery:
              type: object
              required: [method, emailAudience, webhookId]
              properties:
                method:
                  $ref: "#/components/schemas/DeliveryMethodEnum"
                emailAudience:
                  $ref: "#/components/schemas/EmailAudienceEnum"
                webhookId:
                  type: [string, "null"]
                  pattern: "^whk_[a-f0-9]{24}$"
            links:
              type: object
              required: [delivery]
              properties:
                delivery: { type: string }
        meta:
          type: object
          properties:
            message:
              type: string
              example: "Delivery method updated"

    # =========================================================================
    # Webhook Payload Schemas (for documentation)
    # =========================================================================

    # Webhook Headers:
    # Headers sent with every webhook delivery:
    # - Content-Type: application/cloudevents+json
    # - User-Agent: Y2-Webhook-Delivery/3.0
    # - X-Y2-Timestamp: <unix_timestamp_seconds>
    # - X-Y2-Event-Id: <stable_logical_event_id>
    # - X-Y2-Attempt-Id: <unique_transport_attempt_id>
    # - X-Y2-Attempt: <one_based_attempt_number>
    # - Idempotency-Key: <stable_logical_event_id>
    # - X-Y2-Signature: sha256=<hmac_sha256_hex> (only if secret configured)
    # - Plus any custom headers you configured in the webhook settings
    #
    # To verify the webhook:
    # 1. Compute HMAC-SHA256 over the raw JSON body with the configured secret
    # 2. Prefix the hex digest with "sha256=" and compare in constant time
    # 3. Optionally reject X-Y2-Timestamp values older than 5 minutes

    Y2WebhookPayload:
      type: object
      description: |
        Compact CloudEvents 1.0 payload sent after intelligence report generation.
        The body is immutable across retries. Transport attempts are identified by headers.

        **Headers:**
        - `X-Y2-Timestamp`: Send time as Unix seconds
        - `X-Y2-Event-Id`: Stable logical event ID. Matches the body `id`
        - `X-Y2-Attempt-Id`: Unique identifier for this transport attempt
        - `X-Y2-Attempt`: One-based attempt number
        - `Idempotency-Key`: Stable logical event ID
        - `X-Y2-Signature`: `sha256=<hex>` HMAC-SHA256 of the raw body, present when a secret is configured
      required:
        - specversion
        - id
        - source
        - type
        - subject
        - time
        - datacontenttype
        - dataschema
        - data
      properties:
        specversion:
          type: string
          const: "1.0"
        id:
          type: string
          description: Stable logical event ID reused by every retry.
        source:
          type: string
          format: uri
        type:
          type: string
          const: dev.y2.report.generated.v1
        subject:
          type: string
          pattern: "^reports/rpt_[a-f0-9]{24}$"
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        dataschema:
          type: string
          const: https://api.y2.dev/schemas/events/report-generated-v1.json
        data:
          $ref: "#/components/schemas/WebhookReportGeneratedData"

    WebhookReportGeneratedData:
      type: object
      required: [report, subscription, links]
      properties:
        report:
          type: object
          required:
            [
              id,
              profileId,
              summary,
              status,
              generatedAt,
              language,
              intelligence,
              audio,
            ]
          properties:
            id: { type: string, pattern: "^rpt_[a-f0-9]{24}$" }
            profileId: { type: string, pattern: "^prf_[a-f0-9]{24}$" }
            summary: { type: [string, "null"] }
            status: { type: string, const: published }
            generatedAt: { type: string, format: date-time }
            language: { type: string, const: en }
            intelligence:
              type: object
              required: [signalCount, graphNodeCount]
              properties:
                signalCount: { type: integer, minimum: 0 }
                graphNodeCount: { type: integer, minimum: 0 }
            audio:
              type: object
              required: [status, durationSeconds]
              properties:
                status: { type: string, enum: [available, unavailable] }
                durationSeconds: { type: [number, "null"] }
        subscription:
          type: object
          required: [id]
          properties:
            id: { type: string, pattern: "^sub_[a-f0-9]{24}$" }
        links:
          type: object
          additionalProperties:
            type: string
            format: uri

    # =========================================================================
    # Intel v2 Schemas: Ontology-backed entities, incidents, markets, graphs
    # =========================================================================

    IncidentListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicIncident"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    IncidentDetail:
      type: object
      required: [incident]
      properties:
        incident:
          $ref: "#/components/schemas/PublicIncident"
        observations:
          type: array
          items:
            $ref: "#/components/schemas/PublicObservation"
        markets:
          type: array
          items:
            $ref: "#/components/schemas/PublicMarket"
        entities:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
        primaryPlace:
          oneOf:
            - $ref: "#/components/schemas/PublicPlace"
            - type: "null"
          description: Primary place for the incident (or null)
        relatedIncidents:
          type: array
          items:
            $ref: "#/components/schemas/PublicIncident"

    IncidentDetailResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/IncidentDetail"

    EntityListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    EntityDetail:
      type: object
      required: [entity]
      properties:
        entity:
          $ref: "#/components/schemas/PublicEntity"
        fromRelations:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntityRelation"
        toRelations:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntityRelation"
        relatedEntities:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
        incidents:
          type: array
          items:
            $ref: "#/components/schemas/PublicIncident"
        markets:
          type: array
          items:
            $ref: "#/components/schemas/PublicMarket"
        observations:
          type: array
          items:
            $ref: "#/components/schemas/PublicObservation"
        companyIdentity:
          $ref: "#/components/schemas/CompanyIdentityVerification"
        financialObservations:
          type: array
          items:
            $ref: "#/components/schemas/CompanyFinancialObservation"

    CompanyIdentityVerification:
      type: object
      required:
        - status
        - confidence
        - canonicalName
        - identifiers
        - matchBasis
        - ambiguities
        - alternativeCandidates
        - evidenceUrls
        - checkedAt
      properties:
        status:
          type: string
          enum: [verified, ambiguous, unresolved]
        confidence:
          type: string
          enum: [high, medium, low, unresolved]
        canonicalName:
          type: string
        canonicalDomain:
          type: string
        jurisdiction:
          type: string
        businessDescription:
          type: string
        identifiers:
          type: array
          items:
            type: object
            required: [kind, value]
            properties:
              kind:
                type: string
                enum: [cik, ticker, lei, cik_or_ticker]
                description: Legacy cik_or_ticker values are unclassified and must not be used as SEC CIKs.
              value:
                type: string
              exchange:
                type: string
        matchBasis:
          type: array
          items:
            type: string
        ambiguities:
          type: array
          items:
            type: string
        alternativeCandidates:
          type: array
          items:
            type: object
            required: [name, rationale, evidenceUrls]
            properties:
              name:
                type: string
              domain:
                type: string
              jurisdiction:
                type: string
              rationale:
                type: string
              evidenceUrls:
                type: array
                items:
                  type: string
                  format: uri
        evidenceUrls:
          type: array
          items:
            type: string
            format: uri
        checkedAt:
          type: string
          format: date-time
        verifiedAt:
          type: string
          format: date-time

    CompanyFinancialHistoryResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          maxItems: 50
          items:
            allOf:
              - $ref: "#/components/schemas/CompanyFinancialObservation"
              - type: object
                required: [id, type]
                properties:
                  id:
                    type: string
                    pattern: "^cfo_[a-f0-9]{24}$"
                  type:
                    type: string
                    const: company_financial_observation
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    LedgerSubjectClass:
      type: string
      enum: [person, organization, system]
      description: "Subjects never change class. An assessment would be another claim."

    LedgerVerification:
      type: string
      description: |
        Verification hangs on the claim, not the subject. unverified: written
        down, not checked. mentioned: the string appeared. located: one
        retrieved page ties them. self-asserted: the subject's own page says so.
        cross-linked: two independent pages identify the link. corroborated: a
        further independent source agrees. contradicted: a source disputes it.
        stale: the page is gone or no longer shows it. analytic: the only
        support is an analyst note.
      enum:
        [
          unverified,
          mentioned,
          located,
          self-asserted,
          cross-linked,
          corroborated,
          contradicted,
          stale,
          analytic,
        ]

    LedgerPredicate:
      type: string
      description: |
        Base framework predicates plus the Y2 cyber-market profile (supplies,
        subsidiary-of). same-as and distinct-from are hypotheses and never merge rows.
      enum:
        [
          designated-by,
          preferred-label,
          same-as,
          distinct-from,
          member-of,
          affiliated-with,
          controls,
          operates,
          resolves-to,
          follows,
          supplies,
          subsidiary-of,
        ]

    LedgerDesignatorKind:
      type: string
      enum:
        [
          published-name,
          pseudonym,
          handle,
          email,
          url,
          domain,
          hostname,
          asn,
          public-key,
          external-id,
          ticker,
        ]

    LedgerObservationMethod:
      type: string
      description: The closed set of passive methods. Interaction and authenticated access have no name.
      enum:
        [
          public-web-page,
          public-profile,
          public-dns,
          certificate-transparency,
          public-archive,
          public-registry,
          public-code-host,
          analyst-note,
        ]

    LedgerEntityAnchor:
      type: object
      additionalProperties: false
      required: [entityId, kind, canonicalName]
      properties:
        entityId:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
        kind:
          type: string
        canonicalName:
          type: string

    LedgerSubjectSummary:
      type: object
      required: [id, type, class, label, openedAt, anchor]
      properties:
        id:
          type: string
          pattern: "^sbj_[a-f0-9]{24}$"
        type:
          type: string
          const: ledger_subject
        class:
          $ref: "#/components/schemas/LedgerSubjectClass"
        label:
          type: [string, "null"]
          description: Value of the live preferred-label designator, or null.
        openedAt:
          type: string
          format: date-time
        anchor:
          oneOf:
            - $ref: "#/components/schemas/LedgerEntityAnchor"
            - type: "null"

    LedgerDesignator:
      type: object
      additionalProperties: false
      required: [designatorId, kind, value, namespace, normalized, recordedAt]
      properties:
        designatorId:
          type: string
          pattern: "^dsg_[a-f0-9]{24}$"
        kind:
          $ref: "#/components/schemas/LedgerDesignatorKind"
        value:
          type: string
        namespace:
          type: string
          description: "Platform for a handle, algorithm for a key, registry for an external id, exchange MIC for a ticker. Otherwise empty."
        normalized:
          type: string
        recordedAt:
          type: string
          format: date-time

    LedgerClaim:
      type: object
      additionalProperties: false
      required:
        [
          claimId,
          claimKey,
          op,
          predicate,
          from,
          to,
          qualifier,
          supersedes,
          confidence,
          verification,
          validFrom,
          validTo,
          evidenceRefs,
          note,
          recordedAt,
        ]
      properties:
        claimId:
          type: string
          pattern: "^clm_[a-f0-9]{24}$"
        claimKey:
          type: string
          description: predicate|from|to|qualifier. One chain of lines per key.
        op:
          type: string
          enum: [assert, retract]
        predicate:
          $ref: "#/components/schemas/LedgerPredicate"
        from:
          type: string
        to:
          type: string
        qualifier:
          type: string
          description: "The public role on member-of. Empty otherwise."
        supersedes:
          type: [string, "null"]
        confidence:
          type: [integer, "null"]
          minimum: 0
          maximum: 100
        verification:
          oneOf:
            - $ref: "#/components/schemas/LedgerVerification"
            - type: "null"
        validFrom:
          type: [string, "null"]
          format: date-time
          description: Null means unknown, not a guessed date.
        validTo:
          type: [string, "null"]
          format: date-time
          description: Exclusive end. Null means unknown.
        evidenceRefs:
          type: array
          items:
            type: string
        note:
          type: string
        recordedAt:
          type: string
          format: date-time

    LedgerObservation:
      type: object
      additionalProperties: false
      required:
        [
          observationId,
          method,
          sourceGrade,
          sourceUrl,
          archiveUrl,
          retrievedAt,
          contentHash,
          excerpt,
          collector,
          cites,
          recordedAt,
        ]
      properties:
        observationId:
          type: string
          pattern: "^obv_[a-f0-9]{24}$"
        method:
          $ref: "#/components/schemas/LedgerObservationMethod"
        sourceGrade:
          type: string
          enum: [primary, secondary, analytic]
        sourceUrl:
          type: [string, "null"]
        archiveUrl:
          type: [string, "null"]
        retrievedAt:
          type: [string, "null"]
          format: date-time
        contentHash:
          type: string
          pattern: "^[0-9a-f]{64}$"
          example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
        excerpt:
          type: [string, "null"]
          maxLength: 500
        collector:
          type: string
        cites:
          type: array
          items:
            type: string
        recordedAt:
          type: string
          format: date-time

    LedgerDesignation:
      type: object
      additionalProperties: false
      required: [designator, claim]
      properties:
        designator:
          $ref: "#/components/schemas/LedgerDesignator"
        claim:
          $ref: "#/components/schemas/LedgerClaim"

    LedgerSubject:
      unevaluatedProperties: false
      allOf:
        - $ref: "#/components/schemas/LedgerSubjectSummary"
        - type: object
          required:
            [
              cursor,
              designations,
              unlinkedDesignations,
              claims,
              retracted,
              contested,
              counterparts,
              designators,
              evidence,
              truncated,
            ]
          properties:
            cursor:
              type: object
              additionalProperties: false
              required: [recordedAt, validAt]
              properties:
                recordedAt:
                  type: [string, "null"]
                  format: date-time
                validAt:
                  type: [string, "null"]
                  format: date-time
            designations:
              type: array
              items:
                $ref: "#/components/schemas/LedgerDesignation"
            unlinkedDesignations:
              type: array
              description: Designations whose valid interval excludes validAt. The string is not forgotten.
              items:
                $ref: "#/components/schemas/LedgerDesignation"
            claims:
              type: array
              description: Live heads that touch the subject or its designators.
              items:
                $ref: "#/components/schemas/LedgerClaim"
            retracted:
              type: array
              items:
                $ref: "#/components/schemas/LedgerClaim"
            contested:
              type: array
              items:
                type: object
                additionalProperties: false
                required: [subjectIds, sameAsClaimIds, distinctFromClaimIds]
                properties:
                  subjectIds:
                    type: array
                    items:
                      type: string
                  sameAsClaimIds:
                    type: array
                    items:
                      type: string
                  distinctFromClaimIds:
                    type: array
                    items:
                      type: string
            counterparts:
              type: array
              items:
                $ref: "#/components/schemas/LedgerSubjectSummary"
            designators:
              type: array
              items:
                $ref: "#/components/schemas/LedgerDesignator"
            evidence:
              type: array
              items:
                $ref: "#/components/schemas/LedgerObservation"
            truncated:
              type: boolean

    LedgerSubjectListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          maxItems: 50
          items:
            $ref: "#/components/schemas/LedgerSubjectSummary"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    LedgerSubjectCreateRequest:
      type: object
      additionalProperties: false
      required: [class]
      properties:
        class:
          $ref: "#/components/schemas/LedgerSubjectClass"
        entityId:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
          description: Catalog entity to anchor the subject to.

    LedgerSubjectCreatedResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/LedgerSubjectSummary"

    LedgerSubjectResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/LedgerSubject"

    LedgerRecord:
      type: object
      required: [id, type, kind, seq, hash, line, record]
      properties:
        id:
          type: string
          pattern: "^(sbj|dsg|obv|clm)_[a-f0-9]{24}$"
          example: sbj_0123456789abcdef01234567
        type:
          type: string
          const: ledger_record
        kind:
          type: string
          enum: [subject, designator, observation, assertion]
        seq:
          type: integer
          minimum: 1
        hash:
          type: string
          pattern: "^[0-9a-f]{64}$"
          example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
        line:
          type: string
          description: "The exact canonical JSON line. Its SHA-256 without the hash field is hash."
        record:
          type: object
          description: The parsed line, in the framework's snake_case field names.
          additionalProperties: true

    LedgerRecordListResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: array
          maxItems: 200
          items:
            $ref: "#/components/schemas/LedgerRecord"
        meta:
          $ref: "#/components/schemas/LedgerSeqWindowMeta"

    LedgerSeqWindowMeta:
      type: object
      additionalProperties: false
      required: [afterSeq, nextAfterSeq, hasMore]
      properties:
        afterSeq:
          type: integer
          minimum: 0
        nextAfterSeq:
          type: integer
          minimum: 0
        hasMore:
          type: boolean

    LedgerDesignatorInput:
      type: object
      additionalProperties: false
      required: [kind, value]
      properties:
        kind:
          $ref: "#/components/schemas/LedgerDesignatorKind"
        value:
          type: string
          description: Canonicalized on write (for example, lowercase email, CIK padded to ten digits).
        namespace:
          type: string

    LedgerObservationInput:
      type: object
      additionalProperties: false
      required: [method, sourceGrade, collector]
      properties:
        method:
          $ref: "#/components/schemas/LedgerObservationMethod"
        sourceGrade:
          type: string
          enum: [primary, secondary, analytic]
        sourceUrl:
          type: string
        archiveUrl:
          type: string
        retrievedAt:
          type: string
          format: date-time
          description: "When the page was fetched. Defaults to the time recorded for a retrieval. Omit on an analyst note."
        excerpt:
          type: string
          maxLength: 500
        contentHash:
          type: string
          pattern: "^[0-9a-f]{64}$"
          description: Only when the excerpt is absent and archiveUrl holds the hashed content.
        collector:
          type: string
          maxLength: 80
        cites:
          type: array
          description: Observations an analyst note connects. Empty on a retrieval.
          items:
            type: string

    LedgerClaimInput:
      type: object
      additionalProperties: false
      required: [predicate, from, to, evidenceRefs]
      properties:
        op:
          type: string
          enum: [assert, retract]
          default: assert
        predicate:
          $ref: "#/components/schemas/LedgerPredicate"
        from:
          type: string
        to:
          type: string
        qualifier:
          type: string
        supersedes:
          type: string
          description: "The current head of the claim key. Required after the first line."
        confidence:
          type: integer
          minimum: 0
          maximum: 100
        verification:
          $ref: "#/components/schemas/LedgerVerification"
        validFrom:
          type: string
          format: date-time
        validTo:
          type: string
          format: date-time
        evidenceRefs:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: string
        note:
          type: string
          maxLength: 1000

    LedgerRecordAppendRequest:
      oneOf:
        - type: object
          additionalProperties: false
          required: [kind, designator]
          properties:
            kind:
              type: string
              const: designator
            designator:
              $ref: "#/components/schemas/LedgerDesignatorInput"
        - type: object
          additionalProperties: false
          required: [kind, observation]
          properties:
            kind:
              type: string
              const: observation
            observation:
              $ref: "#/components/schemas/LedgerObservationInput"
        - type: object
          additionalProperties: false
          required: [kind, claim]
          properties:
            kind:
              type: string
              const: claim
            claim:
              $ref: "#/components/schemas/LedgerClaimInput"

    LedgerRecordAppendResponse:
      type: object
      required: [data]
      properties:
        data:
          allOf:
            - $ref: "#/components/schemas/LedgerRecord"
            - type: object
              required: [created]
              properties:
                created:
                  type: boolean

    LedgerVerifyResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          type: object
          additionalProperties: false
          required: [ok, checked, problems]
          properties:
            ok:
              type: boolean
            checked:
              type: integer
              minimum: 0
            problems:
              type: array
              items:
                type: object
                additionalProperties: false
                required: [code, message, seq]
                properties:
                  code:
                    type: string
                  message:
                    type: string
                  seq:
                    type: integer
                  id:
                    type: string
        meta:
          $ref: "#/components/schemas/LedgerSeqWindowMeta"

    StixBundle:
      type: object
      description: A STIX 2.1 bundle (OASIS STIX 2.1, section 8).
      required: [type, id, objects]
      properties:
        type:
          type: string
          const: bundle
        id:
          type: string
          pattern: "^bundle--[0-9a-f-]{36}$"
          example: bundle--6ba1f0c2-3d4e-8f5a-9b6c-7d8e9f0a1b2c
        objects:
          type: array
          items:
            type: object
            required: [type, id]
            additionalProperties: true
            properties:
              type:
                type: string
              id:
                type: string
              spec_version:
                type: string
                const: "2.1"

    FusionDomain:
      type: string
      enum: [cyber, market, supply_chain, geopolitical]

    FusionPathRelation:
      type: string
      description: How an event reaches the company. direct, or through a party on the exposure path.
      enum: [direct, supplier, customer, parent, subsidiary, operated-system]

    FusionEvent:
      type: object
      additionalProperties: false
      required: [id, domain, kind, at, title, path, provenance, source]
      properties:
        id:
          type: string
          pattern: "^fev_[a-f0-9]{24}$"
        domain:
          $ref: "#/components/schemas/FusionDomain"
        kind:
          type: string
        at:
          type: [string, "null"]
          format: date-time
          description: "Event time. Null when the source gives none. Never guessed."
        title:
          type: string
        severity:
          type: string
          enum: [critical, high, medium, low, info]
        path:
          type: object
          additionalProperties: false
          required: [relation]
          properties:
            relation:
              $ref: "#/components/schemas/FusionPathRelation"
            viaEntityId:
              type: string
              pattern: "^ent_[a-f0-9]{24}$"
            viaLabel:
              type: string
        provenance:
          type: string
          enum: [catalog, ledger, workspace]
          description: Shared catalog, workspace ledger, or workspace research.
        sourceUrl:
          type: string
        source:
          type: object
          additionalProperties: false
          required: [type, id]
          properties:
            type:
              type: string
              enum:
                [
                  entity,
                  incident,
                  signal,
                  market,
                  company_financial_observation,
                  ledger_claim,
                ]
            id:
              type: string

    EntityFusion:
      type: object
      additionalProperties: false
      required:
        [
          entity,
          window,
          counterparties,
          identifiers,
          topics,
          timeline,
          undated,
          summaries,
          adjacencies,
          coverage,
        ]
      properties:
        entity:
          type: object
          additionalProperties: false
          required: [id, kind, canonicalName]
          properties:
            id:
              type: string
              pattern: "^ent_[a-f0-9]{24}$"
            kind:
              type: string
            canonicalName:
              type: string
        window:
          type: object
          additionalProperties: false
          required: [start, end, adjacencyDays]
          properties:
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
            adjacencyDays:
              type: integer
        counterparties:
          type: array
          maxItems: 12
          items:
            type: object
            additionalProperties: false
            required: [entityId, kind, canonicalName, relation, provenance]
            properties:
              entityId:
                type: string
                pattern: "^ent_[a-f0-9]{24}$"
              kind:
                type: string
              canonicalName:
                type: string
              relation:
                $ref: "#/components/schemas/FusionPathRelation"
              provenance:
                type: string
                enum: [catalog, ledger]
              confidence:
                type: number
              verification:
                $ref: "#/components/schemas/LedgerVerification"
        identifiers:
          type: array
          description: Live designations of ledger subjects anchored to the entity.
          items:
            type: object
            additionalProperties: false
            required:
              [subjectId, kind, value, namespace, verification, confidence]
            properties:
              subjectId:
                type: string
              kind:
                type: string
              value:
                type: string
              namespace:
                type: string
              verification:
                type: [string, "null"]
              confidence:
                type: [integer, "null"]
        topics:
          type: array
          description: Workspace topics whose subject is on the exposure path.
          items:
            type: object
            additionalProperties: false
            required: [profileId, name, topic, relation]
            properties:
              profileId:
                type: string
                pattern: "^prf_[a-f0-9]{24}$"
              name:
                type: string
              topic:
                type: string
              relation:
                $ref: "#/components/schemas/FusionPathRelation"
        timeline:
          type: array
          maxItems: 200
          items:
            $ref: "#/components/schemas/FusionEvent"
        undated:
          type: array
          maxItems: 200
          items:
            $ref: "#/components/schemas/FusionEvent"
        summaries:
          type: array
          items:
            type: object
            additionalProperties: false
            required: [domain, events, highestSeverity, latestAt]
            properties:
              domain:
                $ref: "#/components/schemas/FusionDomain"
              events:
                type: integer
                minimum: 0
              highestSeverity:
                type: [string, "null"]
                enum: [critical, high, medium, low, info, null]
              latestAt:
                type: [string, "null"]
                format: date-time
        adjacencies:
          type: array
          maxItems: 50
          description: A market event that followed a cyber event within adjacencyDays. Not causation.
          items:
            type: object
            additionalProperties: false
            required: [cyberEventId, marketEventId, lagHours, samePath]
            properties:
              cyberEventId:
                type: string
                pattern: "^fev_[a-f0-9]{24}$"
              marketEventId:
                type: string
                pattern: "^fev_[a-f0-9]{24}$"
              lagHours:
                type: integer
                minimum: 0
              samePath:
                type: boolean
        coverage:
          type: object
          additionalProperties: false
          required: [truncated, sections, notes]
          properties:
            truncated:
              type: boolean
              description: True when any section reached its read budget.
            sections:
              type: array
              description: |
                Read-budget status for each part of the view. A section with
                `truncated: false` and no rows genuinely has nothing in the window;
                a truncated section may omit rows.
              items:
                type: object
                additionalProperties: false
                required: [name, truncated]
                properties:
                  name:
                    type: string
                    enum:
                      [
                        catalog_relations,
                        ledger_subjects,
                        counterparties,
                        cyber_exposure,
                        signals,
                        incidents_and_markets,
                        financial_observations,
                        topics,
                        timeline,
                      ]
                  truncated:
                    type: boolean
            notes:
              type: array
              items:
                type: string

    EntityFusionResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/EntityFusion"

    CompanyFilingFact:
      type: object
      additionalProperties: false
      required:
        [
          cik,
          accession,
          form,
          filedDate,
          taxonomy,
          concept,
          recordPointer,
          periodType,
        ]
      properties:
        cik:
          type: string
          example: "0000320193"
        accession:
          type: string
        form:
          type: string
        filedDate:
          type: string
          format: date
        taxonomy:
          type: string
          const: us-gaap
        concept:
          type: string
        recordPointer:
          type: string
          description: JSON Pointer in the retained SEC companyfacts response, not a document page span.
        periodType:
          type: string
          enum: [instant, duration]

    CompanyFinancialObservation:
      type: object
      required:
        [metric, factType, value, period, confidence, sources, recordedAt]
      properties:
        metric:
          type: object
          required: [key, label]
          properties:
            key:
              type: string
            label:
              type: string
        factType:
          type: string
          enum: [actual, estimate, guidance]
        filing:
          $ref: "#/components/schemas/CompanyFilingFact"
        value:
          type: object
          required: [display]
          properties:
            display:
              type: string
            numeric:
              type: number
            currency:
              type: string
            unit:
              type: string
            scale:
              type: string
        period:
          type: object
          required: [asOfDate]
          properties:
            fiscalPeriod:
              type: string
            periodStart:
              type: string
              description: Source-supported reporting period start, preserving date precision.
            periodEnd:
              type: string
            asOfDate:
              type: string
              description: Stated date of the financial fact, not source publication, capture, or recording time.
        confidence:
          type: number
          minimum: 0
          maximum: 1
        comparison:
          type: object
          required: [kind]
          properties:
            kind:
              type: string
              enum: [period_over_period, restatement]
            absolute:
              type: number
            percent:
              type: number
        sources:
          type: array
          items:
            type: string
            format: uri
        availableAt:
          type: string
          format: date-time
          description: "Conservative evidence-availability bound, using the latest retained source capture across all cited sources. Only present when every cited source has a verified archived span. Not the original publication date or a historical retrieval guarantee."
        availabilityBasis:
          type: string
          enum: [first_capture, unknown]
          description: first_capture requires revision-validated spans for all cited sources. Legacy, incomplete, or source-only evidence remains unknown.
        provenance:
          type: array
          maxItems: 4
          items:
            $ref: "#/components/schemas/CompanyFinancialSourceProvenance"
        recordedAt:
          type: string
          format: date-time
          description: Time the financial observation was recorded by Y2, independently of its reporting period and source times.

    CompanyFinancialSourceProvenance:
      type: object
      additionalProperties: false
      required: [url, coverage]
      properties:
        url:
          type: string
          format: uri
        canonicalUrl:
          type: string
          format: uri
          description: Retained source URL, which may differ after a public-document redirect.
        coverage:
          type: string
          enum: [source_only, archived_source, archived_span]
          description: "source_only has no validated retained content. Archived_source retains hashed content but no verified fact location. Archived_span additionally matches the supporting quote uniquely within an authorized normalized revision."
        publishedAt:
          type: string
          format: date-time
          description: Reported source publication time, not proof of availability of this exact version.
        retrievedAt:
          type: string
          format: date-time
          description: Retrieval time of the accepted research evidence, or source retrieval time when no research timestamp was retained.
        capturedAt:
          type: string
          format: date-time
          description: Capture time of the linked source record.
        sourceVersion:
          type: integer
          minimum: 1
        contentHash:
          type: string
        integrityStatus:
          type: string
          enum: [metadata_only, content_hashed, signed]
        citation:
          type: object
          additionalProperties: false
          required: [revision, pageNumber, startChar, endChar, quote]
          properties:
            revision:
              type: integer
              minimum: 1
              description: "Normalized revision number for this source content hash. Not a raw storage or database ID."
            pageNumber:
              type: integer
              minimum: 1
            startChar:
              type: integer
              minimum: 0
              description: Inclusive zero-based UTF-16 offset within the normalized page text.
            endChar:
              type: integer
              minimum: 1
              description: Exclusive UTF-16 offset within the same normalized page text.
            quote:
              type: string
              minLength: 16
              example: "Revenue was USD 120 million."
              maxLength: 1000

    EntityDetailResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/EntityDetail"

    IntelGraph:
      type: object
      required: [nodes, edges]
      properties:
        nodes:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
        edges:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntityRelation"
        capped:
          type: boolean
          description: True when traversal stopped early (200-node cap or depth cap)
        depth:
          type: integer
          description: BFS depth traversed

    EntityGraphResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/IntelGraph"
        meta:
          $ref: "#/components/schemas/PublicGraphMeta"

    CyberGraphResponse:
      type: object
      required: [data, meta]
      properties:
        data:
          $ref: "#/components/schemas/IntelGraph"
        meta:
          $ref: "#/components/schemas/PublicGraphMeta"

    MarketListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicMarket"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    CVEListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
          description: Entities filtered to `kind=cve`
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    CVEIdentifier:
      type: string
      pattern: "^CVE-[0-9]{4}-[0-9]{4,31}$"
      example: CVE-2021-27460

    CVERevision:
      type: string
      pattern: "^[a-f0-9]{64}$"
      example: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    CVETime:
      type: [integer, "null"]
      description: Unix milliseconds, or null when the source does not provide a time.
      example: 1617282000000

    CVEMetric:
      type: object
      additionalProperties: false
      required: [version, score, severity, vector, source]
      properties:
        version: { type: string, example: "3.1" }
        score: { type: number, minimum: 0, maximum: 10, example: 9.8 }
        severity: { type: string, example: critical }
        vector:
          {
            type: string,
            example: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
          }
        source:
          {
            type: string,
            description: Authority that supplied this assessment.,
          }

    CVEVersion:
      type: object
      additionalProperties: false
      required: [version, status]
      description: Source version rules. Interpret boundaries with their versionType and ecosystem; do not compare all versions lexically.
      properties:
        version: { type: string }
        status: { type: string }
        lessThan: { type: string }
        lessThanOrEqual: { type: string }
        greaterThan: { type: string }
        greaterThanOrEqual: { type: string }
        versionType: { type: string }
        changes:
          type: array
          items:
            type: object
            additionalProperties: false
            required: [at, status]
            properties:
              at: { type: string }
              status: { type: string }
        events:
          type: array
          description: Ordered OSV range events retained from the source.
          items:
            type: object
            additionalProperties: false
            properties:
              introduced: { type: string }
              fixed: { type: string }
              last_affected: { type: string }
              limit: { type: string }

    CVEAffected:
      type: object
      additionalProperties: false
      required: [vendor, product, versions, source]
      properties:
        vendor: { type: string }
        product: { type: string }
        packageName: { type: string }
        ecosystem: { type: string }
        defaultStatus: { type: string }
        conditional:
          type: boolean
          description: Applicability depends on a source configuration; an isolated version match is insufficient.
        platforms:
          type: array
          items: { type: string }
        versions:
          type: array
          items:
            $ref: "#/components/schemas/CVEVersion"
        source: { type: string }

    CVECpeConfiguration:
      type: object
      additionalProperties: false
      required: [operator, negate, nodes]
      properties:
        operator: { type: string }
        negate: { type: boolean }
        nodes:
          type: array
          items:
            type: object
            additionalProperties: false
            required: [operator, negate, cpeMatch]
            properties:
              operator: { type: string }
              negate: { type: boolean }
              cpeMatch:
                type: array
                items:
                  type: object
                  additionalProperties: false
                  required: [criteria, vulnerable]
                  properties:
                    criteria: { type: string }
                    vulnerable: { type: boolean }
                    versionStartIncluding: { type: string }
                    versionStartExcluding: { type: string }
                    versionEndIncluding: { type: string }
                    versionEndExcluding: { type: string }

    CVERemediation:
      type: object
      additionalProperties: false
      required: [kind, text, source]
      properties:
        kind: { type: string, enum: [fix, workaround] }
        text: { type: string }
        url: { type: string, format: uri }
        source: { type: string }

    CVEReference:
      type: object
      additionalProperties: false
      required: [url, tags, source]
      properties:
        url: { type: string, format: uri }
        tags:
          type: array
          items: { type: string }
        source: { type: string }

    CVEKEV:
      type: object
      additionalProperties: false
      required:
        [
          addedAt,
          dueDateAt,
          knownRansomwareUse,
          requiredAction,
          vendor,
          product,
          vulnerabilityName,
          shortDescription,
        ]
      properties:
        addedAt:
          $ref: "#/components/schemas/CVETime"
        dueDateAt:
          $ref: "#/components/schemas/CVETime"
        knownRansomwareUse: { type: boolean }
        requiredAction: { type: string }
        vendor: { type: string }
        product: { type: string }
        vulnerabilityName: { type: string }
        shortDescription: { type: string }

    CVEEPSS:
      type: object
      additionalProperties: false
      required: [score, percentile, date]
      properties:
        score: { type: number, minimum: 0, maximum: 1 }
        percentile: { type: number, minimum: 0, maximum: 1 }
        date: { type: string, description: Assessment date supplied by FIRST. }

    CVESSVC:
      type: object
      additionalProperties: false
      required: [source]
      properties:
        exploitation: { type: string }
        automatable: { type: string }
        technicalImpact: { type: string }
        assessedAt: { type: integer, description: Unix milliseconds. }
        source: { type: string }

    CVEExploit:
      type: object
      additionalProperties: false
      required: [url, source, kind]
      properties:
        url: { type: string, format: uri }
        source: { type: string }
        kind: { type: string, enum: [proof_of_concept, exploit] }

    CVESource:
      type: object
      additionalProperties: false
      required: [name, url, modifiedAt, retrievedAt]
      properties:
        name: { type: string }
        url: { type: string, format: uri }
        modifiedAt:
          $ref: "#/components/schemas/CVETime"
        retrievedAt:
          {
            type: integer,
            description: Unix milliseconds when Y2 received this source.,
          }

    CVEDisclosure:
      type: object
      description: |
        Explicit public disclosure projection, shared with the Cyber UI and public JSON.
        Arrays retain source statements; empty arrays and null assessments mean unavailable
        in the collected sources. They do not prove no affected products, fixes, or exploits exist.
        Revision hashes identify retained disclosure snapshots. All numeric dates are Unix milliseconds.
      required:
        [
          cveId,
          title,
          description,
          status,
          publishedAt,
          modifiedAt,
          metrics,
          affected,
          remediation,
          references,
          cwes,
          kev,
          epss,
          ssvc,
          exploits,
          sources,
          revision,
          updatedAt,
        ]
      properties:
        cveId:
          $ref: "#/components/schemas/CVEIdentifier"
        title: { type: string }
        description: { type: string }
        status: { type: string, enum: [published, rejected, reserved] }
        publishedAt:
          $ref: "#/components/schemas/CVETime"
        modifiedAt:
          $ref: "#/components/schemas/CVETime"
        metrics:
          type: array
          description: Source-specific assessments; the primary authority leads when available.
          items:
            $ref: "#/components/schemas/CVEMetric"
        affected:
          type: array
          items:
            $ref: "#/components/schemas/CVEAffected"
        cpeConfigurations:
          type: array
          items:
            $ref: "#/components/schemas/CVECpeConfiguration"
        remediation:
          type: array
          items:
            $ref: "#/components/schemas/CVERemediation"
        references:
          type: array
          items:
            $ref: "#/components/schemas/CVEReference"
        cwes:
          type: array
          items: { type: string }
        kev:
          oneOf:
            - $ref: "#/components/schemas/CVEKEV"
            - type: "null"
        epss:
          oneOf:
            - $ref: "#/components/schemas/CVEEPSS"
            - type: "null"
        ssvc:
          oneOf:
            - $ref: "#/components/schemas/CVESSVC"
            - type: "null"
        exploits:
          type: array
          items:
            $ref: "#/components/schemas/CVEExploit"
        sources:
          type: array
          items:
            $ref: "#/components/schemas/CVESource"
        revision:
          $ref: "#/components/schemas/CVERevision"
        updatedAt:
          {
            type: integer,
            description: Unix milliseconds when this disclosure snapshot was recorded.,
          }

    CVESummary:
      type: object
      additionalProperties: false
      required:
        [
          cveId,
          summaryAvailable,
          title,
          description,
          status,
          revision,
          publishedAt,
          modifiedAt,
          primaryMetric,
          knownExploited,
          epss,
          remediationStatus,
          affectedProductCount,
          referenceCount,
          sources,
        ]
      properties:
        cveId:
          $ref: "#/components/schemas/CVEIdentifier"
        summaryAvailable:
          type: boolean
          description: Whether a compact source-owned summary has been projected. False does not establish that full disclosure detail is absent.
        title: { type: [string, "null"] }
        description:
          {
            type: [string, "null"],
            maxLength: 1000,
            description: Bounded excerpt; read the detail for the full description.,
          }
        status:
          {
            type: [string, "null"],
            enum: [published, rejected, reserved, null],
          }
        revision:
          oneOf:
            - $ref: "#/components/schemas/CVERevision"
            - type: "null"
        publishedAt: { type: [string, "null"], format: date-time }
        modifiedAt: { type: [string, "null"], format: date-time }
        primaryMetric:
          oneOf:
            - $ref: "#/components/schemas/CVEMetric"
            - type: "null"
        knownExploited:
          type: [boolean, "null"]
          description: Retained CISA KEV membership; null when unknown. Independent of technical CVSS severity.
        epss:
          oneOf:
            - $ref: "#/components/schemas/CVEEPSS"
            - type: "null"
        remediationStatus:
          type: string
          enum: [fix_published, workaround_published, unknown]
        remediationEvidence:
          type: array
          maxItems: 5
          description: Bounded source assertions supporting the remediation status; does not mean the user's installation is patched.
          items:
            $ref: "#/components/schemas/CVERemediation"
        affectedProductCount: { type: [integer, "null"], minimum: 0 }
        referenceCount: { type: [integer, "null"], minimum: 0 }
        sources:
          type: array
          items:
            $ref: "#/components/schemas/RecordSource"

    CVEDisclosureResource:
      allOf:
        - $ref: "#/components/schemas/CVEDisclosure"
        - type: object
          required: [id, type, links]
          properties:
            id: { type: string, pattern: "^ent_[a-f0-9]{24}$" }
            type: { type: string, const: cve_disclosure }
            links:
              type: object
              additionalProperties: false
              required: [self, entity, publicPage, json, markdown, image]
              properties:
                self:
                  {
                    type: string,
                    description: Versioned API detail; retains the requested revision.,
                  }
                entity:
                  { type: string, description: General ontology entity detail. }
                publicPage: { type: string, format: uri }
                json: { type: string, format: uri }
                markdown: { type: string, format: uri }
                image:
                  {
                    type: string,
                    format: uri,
                    description: PNG card pinned to disclosure revision and image template.,
                  }
      unevaluatedProperties: false

    CVEDisclosureResponse:
      type: object
      additionalProperties: false
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/CVEDisclosureResource"

    ThreatActorListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicEntity"
          description: Entities filtered to `kind=threat_actor`
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    FinintIntelListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicFinintObservation"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    DisclosureListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicDisclosure"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    DnsLookupRequest:
      type: object
      additionalProperties: false
      description: Provide `domain`, `entityId`, or both
      properties:
        domain:
          type: string
          maxLength: 300
          description: Domain name. Y2 reduces a URL or `www.` host to its domain
          example: y2.dev
        entityId:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
          description: Entity whose known official website to look up

    DnsLookupResponse:
      type: object
      required: [data, usage]
      additionalProperties: false
      properties:
        data:
          type: object
          required: [outcome, snapshot]
          additionalProperties: false
          properties:
            outcome:
              type: string
              enum: [fetched, reused]
              description: "`reused` when a snapshot younger than 14 days answered the request"
            snapshot:
              $ref: "#/components/schemas/DnsSnapshot"
        usage:
          $ref: "#/components/schemas/DnsLookupUsage"

    DnsLookupUsage:
      type: object
      required: [period, used, limit]
      additionalProperties: false
      properties:
        period:
          type: string
          pattern: "^[0-9]{4}-[0-9]{2}$"
          description: Calendar month (UTC) of the allowance
          example: "2026-10"
        used:
          type: integer
          minimum: 0
          description: Provider lookups the workspace has used this month
        limit:
          type: integer
          minimum: 0
          description: Monthly allowance of the workspace plan

    DnsSnapshotListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/DnsSnapshot"
        meta:
          $ref: "#/components/schemas/PublicListMeta"
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    DnsSnapshot:
      type: object
      required:
        [
          type,
          domain,
          receivedAt,
          reusableUntil,
          source,
          truncated,
          totalARecords,
          changedFromPrevious,
          summary,
          records,
          ontology,
        ]
      additionalProperties: false
      properties:
        type:
          type: string
          const: dns_snapshot
        domain:
          type: string
          example: y2.dev
        receivedAt:
          type: [string, "null"]
          format: date-time
          description: When the provider response was received
        reusableUntil:
          type: [string, "null"]
          format: date-time
          description: Until this time every lookup of the domain returns this snapshot
        source:
          type: object
          required: [type, url]
          additionalProperties: false
          properties:
            type:
              type: string
              const: dnsdumpster
            url:
              type: string
              format: uri
        truncated:
          type: boolean
          description: True when the provider reported more A records than the 50 returned
        totalARecords:
          type: integer
          minimum: 0
        changedFromPrevious:
          type: [boolean, "null"]
          description: Whether the records differ from the previous snapshot. Null for the first
        summary:
          type: object
          required: [hostCount, addressCount, networks]
          additionalProperties: false
          properties:
            hostCount:
              type: integer
              minimum: 0
            addressCount:
              type: integer
              minimum: 0
            networks:
              type: array
              items:
                type: object
                required: [asn, name, addressCount]
                additionalProperties: false
                properties:
                  asn:
                    type: string
                    example: AS13335
                  name:
                    type: [string, "null"]
                    example: Cloudflare, Inc.
                  addressCount:
                    type: integer
                    minimum: 0
        records:
          type: object
          required: [a, mx, ns, cname, txt]
          additionalProperties: false
          properties:
            a:
              type: array
              items:
                $ref: "#/components/schemas/DnsHostRecord"
            mx:
              type: array
              items:
                $ref: "#/components/schemas/DnsHostRecord"
            ns:
              type: array
              items:
                $ref: "#/components/schemas/DnsHostRecord"
            cname:
              type: array
              items:
                type: object
                required: [host, target]
                additionalProperties: false
                properties:
                  host:
                    type: string
                  target:
                    type: [string, "null"]
            txt:
              type: array
              items:
                type: string
        ontology:
          type: object
          required: [status, entity, linkedEntities]
          additionalProperties: false
          properties:
            status:
              type: string
              enum: [pending, running, completed, failed]
              description: Mapping of the snapshot into the shared ontology
            entity:
              oneOf:
                - $ref: "#/components/schemas/DnsEntityRef"
                - type: "null"
              description: The domain's `indicator` entity
            linkedEntities:
              type: array
              description: Known entities whose official website is the domain
              items:
                $ref: "#/components/schemas/DnsEntityRef"

    DnsEntityRef:
      type: object
      required: [id, kind, name]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
        kind:
          $ref: "#/components/schemas/EntityKind"
        name:
          type: string

    DnsHostRecord:
      type: object
      required: [host, priority, addresses]
      additionalProperties: false
      properties:
        host:
          type: string
          example: api.y2.dev
        priority:
          type: [integer, "null"]
          description: MX preference. Null for A and NS records
        addresses:
          type: array
          items:
            $ref: "#/components/schemas/DnsAddress"

    DnsAddress:
      type: object
      required: [ip, asn, asnName, netblock, country, countryCode, ptr, banners]
      additionalProperties: false
      properties:
        ip:
          type: string
          example: 104.18.40.47
        asn:
          type: [string, "null"]
          example: AS13335
        asnName:
          type: [string, "null"]
          example: CLOUDFLARENET - Cloudflare, Inc.
        netblock:
          type: [string, "null"]
          example: 104.18.40.0/24
        country:
          type: [string, "null"]
        countryCode:
          type: [string, "null"]
          pattern: "^[A-Z]{2}$"
          example: US
        ptr:
          type: [string, "null"]
        banners:
          type: array
          items:
            type: object
            required:
              [
                service,
                server,
                title,
                apps,
                tlsCommonName,
                tlsAltNames,
                tlsOrganization,
              ]
            additionalProperties: false
            properties:
              service:
                type: string
                description: Service the banner was read from, such as `http`, `https` or `http8080`
              server:
                type: [string, "null"]
              title:
                type: [string, "null"]
              apps:
                type: array
                items:
                  type: string
              tlsCommonName:
                type: [string, "null"]
              tlsAltNames:
                type: array
                items:
                  type: string
              tlsOrganization:
                type: [string, "null"]

    DisclosureKind:
      type: string
      enum:
        [material_event, insider_transaction, ownership_stake, federal_award]

    DisclosureParty:
      type: object
      required: [role, name, kind, identifiers, entity]
      additionalProperties: false
      properties:
        role:
          type: string
          enum: [issuer, reporting_owner, filer, recipient, awarding_agency]
        name:
          type: string
        kind:
          type: string
          enum: [organization, person]
        identifiers:
          type: object
          required: [secCik, uei, ticker]
          additionalProperties: false
          properties:
            secCik:
              type: [string, "null"]
              description: Zero-padded 10-digit SEC Central Index Key
            uei:
              type: [string, "null"]
              description: SAM.gov Unique Entity ID
            ticker:
              type: [string, "null"]
        entity:
          description: Resolved ontology entity; null when the party could not be linked without risking a false merge.
          oneOf:
            - type: "null"
            - type: object
              required: [id]
              additionalProperties: false
              properties:
                id:
                  type: string
                  pattern: "^ent_[a-f0-9]{24}$"

    DisclosureMaterialEventDetails:
      type: object
      required: [kind, items]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: material_event
        items:
          type: array
          items:
            type: object
            required: [code, label]
            additionalProperties: false
            properties:
              code:
                type: string
                example: "1.05"
              label:
                type: string
        periodOfReport:
          type: string
          format: date
          description: Date of the earliest event reported
        sic:
          type: string
        location:
          type: string
        incorporationState:
          type: string

    DisclosureInsiderTransactionDetails:
      type: object
      required:
        [kind, documentType, roles, transactions, transactionCount, netShares]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: insider_transaction
        documentType:
          type: string
          example: "4"
        roles:
          type: object
          required: [director, officer, tenPercentOwner, other]
          additionalProperties: false
          properties:
            director:
              type: boolean
            officer:
              type: boolean
            tenPercentOwner:
              type: boolean
            other:
              type: boolean
        officerTitle:
          type: string
        transactions:
          type: array
          maxItems: 25
          items:
            type: object
            required: [code, acquired, derivative, security, direct]
            additionalProperties: false
            properties:
              code:
                type: string
                description: SEC transaction code (P purchase, S sale, A grant, M exercise, F tax, G gift)
              acquired:
                type: boolean
              derivative:
                type: boolean
              security:
                type: string
              date:
                type: string
                format: date
              shares:
                type: number
              pricePerShare:
                type: number
              valueUsd:
                type: number
              sharesOwnedAfter:
                type: number
              direct:
                type: boolean
        transactionCount:
          type: integer
          description: Lines in the filing; `transactions` keeps the first 25
        netShares:
          type: number
          description: Non-derivative shares acquired minus shares disposed
        rule10b51:
          type: boolean
          description: Whether the filer marked the trades as made under a Rule 10b5-1 plan

    DisclosureOwnershipStakeDetails:
      type: object
      required: [kind, amendment, reportingPersons]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: ownership_stake
        amendment:
          type: boolean
        securityClass:
          type: string
        eventDate:
          type: string
          format: date
        percentOfClass:
          type: number
        sharesOwned:
          type: number
        reportingPersons:
          type: array
          maxItems: 10
          items:
            type: object
            required: [name]
            additionalProperties: false
            properties:
              name:
                type: string
              cik:
                type: string
              percentOfClass:
                type: number
              type:
                type: string
                description: Schedule 13D reporting-person type (IN individual, IA adviser, PN partnership, CO corporation)

    DisclosureFederalAwardDetails:
      type: object
      required: [kind, awardCategory, awardId, modification, generatedAwardId]
      additionalProperties: false
      properties:
        kind:
          type: string
          const: federal_award
        awardCategory:
          type: string
          enum: [contract, grant]
        awardId:
          type: string
        modification:
          type: string
          description: Modification number; `0` is the base award
        generatedAwardId:
          type: string
          description: USAspending award key
        awardType:
          type: string
        awardingSubAgency:
          type: string
        naics:
          $ref: "#/components/schemas/DisclosureCode"
        psc:
          $ref: "#/components/schemas/DisclosureCode"
        assistanceListing:
          type: object
          required: [number]
          additionalProperties: false
          properties:
            number:
              type: string
            title:
              type: string
        placeOfPerformance:
          type: object
          additionalProperties: false
          properties:
            stateCode:
              type: string
            country:
              type: string
        recipientLocation:
          type: object
          additionalProperties: false
          properties:
            city:
              type: string
            stateCode:
              type: string
            country:
              type: string
        description:
          type: string
          maxLength: 600

    DisclosureCode:
      type: object
      required: [code]
      additionalProperties: false
      properties:
        code:
          type: string
        description:
          type: string

    PublicDisclosure:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^dsc_[a-f0-9]{24}$"
        type:
          type: string
          const: disclosure
        kind:
          $ref: "#/components/schemas/DisclosureKind"
        source:
          type: object
          required: [type, recordId, url]
          additionalProperties: false
          properties:
            type:
              type: string
              enum: [sec_edgar, usaspending]
            recordId:
              type: string
              description: SEC accession number, or USAspending award key, modification and action date
            url:
              type: string
              format: uri
              description: SEC filing index or USAspending award page
        form:
          type: [string, "null"]
          description: SEC form type; null for federal awards
        category:
          type: string
        severity:
          type: string
          enum: [low, medium, high, critical]
        title:
          type: string
        occurredAt:
          type: string
          format: date-time
          description: Event, transaction, or award action date (UTC midnight of the provider date)
        publishedAt:
          type: string
          format: date-time
          description: SEC filing date, or the award action date (UTC midnight)
        amount:
          oneOf:
            - type: "null"
            - type: object
              required: [value, currency]
              additionalProperties: false
              properties:
                value:
                  type: number
                currency:
                  type: string
                  const: USD
        subject:
          $ref: "#/components/schemas/DisclosureParty"
        counterparty:
          oneOf:
            - type: "null"
            - $ref: "#/components/schemas/DisclosureParty"
        entities:
          type: array
          maxItems: 8
          items:
            type: object
            required: [id]
            additionalProperties: false
            properties:
              id:
                type: string
                pattern: "^ent_[a-f0-9]{24}$"
        details:
          oneOf:
            - $ref: "#/components/schemas/DisclosureMaterialEventDetails"
            - $ref: "#/components/schemas/DisclosureInsiderTransactionDetails"
            - $ref: "#/components/schemas/DisclosureOwnershipStakeDetails"
            - $ref: "#/components/schemas/DisclosureFederalAwardDetails"
        provenance:
          type: object
          required: [coverage, retrievedAt, observation]
          additionalProperties: false
          properties:
            coverage:
              type: string
              const: primary_record
            retrievedAt:
              type: string
              format: date-time
            observation:
              description: The ontology observation that carries this disclosure as relation evidence
              oneOf:
                - type: "null"
                - type: object
                  required: [id]
                  additionalProperties: false
                  properties:
                    id:
                      type: string
                      pattern: "^obs_[a-f0-9]{24}$"

    SignalListResponse:
      type: object
      required: [data, meta, links]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicSignal"
        meta:
          allOf:
            - $ref: "#/components/schemas/PublicListMeta"
            - type: object
              required: [filters]
              properties:
                filters:
                  type: object
                  additionalProperties:
                    type: [string, integer, number, boolean, "null"]
        links:
          $ref: "#/components/schemas/PublicCollectionLinks"

    PublicCollectionLinks:
      type: object
      required: [self, next]
      additionalProperties: false
      properties:
        self:
          type: string
        next:
          type: [string, "null"]

    PublicChangeEvent:
      type: object
      required:
        [
          id,
          type,
          changeType,
          resource,
          changedAt,
          tombstone,
          schemaVersion,
          source,
        ]
      additionalProperties: false
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          pattern: "^chg_[a-f0-9]{24}$"
        type:
          type: string
          const: change
        changeType:
          type: string
          enum: [created, updated, deleted]
        resource:
          type: object
          required: [type, id]
          additionalProperties: false
          properties:
            type:
              type: string
            id:
              type: string
              description: "Stable public resource ID. Never a Convex document ID."
        changedAt:
          type: string
          format: date-time
        tombstone:
          type: boolean
          description: True when the referenced resource has been deleted.
        schemaVersion:
          type: string
          const: "1.0"

    ChangeFeedMeta:
      allOf:
        - $ref: "#/components/schemas/PublicListMeta"
        - type: object
          required: [watermark, fromExclusive]
          properties:
            watermark:
              type: [string, "null"]
              description: Exclusive checkpoint after the final event in this response.
            fromExclusive:
              type: boolean
              const: true

    ChangeFeedLinks:
      type: object
      required: [self, next, resume]
      additionalProperties: false
      properties:
        self: { type: string }
        next: { type: [string, "null"] }
        resume:
          type: [string, "null"]
          description: URL containing the checkpoint to persist even when the feed is caught up.

    ChangeFeedResponse:
      type: object
      required: [data, meta, links]
      additionalProperties: false
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicChangeEvent"
        meta:
          $ref: "#/components/schemas/ChangeFeedMeta"
        links:
          $ref: "#/components/schemas/ChangeFeedLinks"

    PublicResourceLinks:
      type: object
      additionalProperties:
        type: [string, "null"]

    PublicPageMeta:
      type: object
      required: [limit, nextCursor, hasMore]
      additionalProperties: false
      properties:
        limit:
          type: integer
          minimum: 1
        nextCursor:
          type: [string, "null"]
        hasMore:
          type: boolean
        scanIncomplete:
          type: boolean
          const: true
          description: |
            Present when a filtered page was cut short by its read budget before it
            filled. The page may hold fewer rows than `limit`, even none, while more
            matches can follow; continue with `nextCursor`.

    PublicListMeta:
      type: object
      required:
        [count, pageCount, limit, isDone, hasMore, nextCursor, asOf, page]
      properties:
        count:
          type: integer
          minimum: 0
          deprecated: true
        pageCount:
          type: integer
          minimum: 0
        limit:
          type: integer
          minimum: 1
        isDone:
          type: boolean
        hasMore:
          type: boolean
        nextCursor:
          type: [string, "null"]
        asOf:
          type: string
          format: date-time
        page:
          $ref: "#/components/schemas/PublicPageMeta"

    GeoJSONPoint:
      type: [object, "null"]
      description: WGS 84 point with longitude first, then latitude.
      required: [type, coordinates]
      additionalProperties: false
      properties:
        type:
          type: string
          const: Point
        coordinates:
          type: array
          minItems: 2
          maxItems: 2
          prefixItems:
            - type: number
              minimum: -180
              maximum: 180
            - type: number
              minimum: -90
              maximum: 90

    GeoJSONFeatureCollection:
      type: object
      required: [type, features, numberReturned, timeStamp, links]
      additionalProperties: false
      properties:
        type:
          type: string
          const: FeatureCollection
        features:
          type: array
          items:
            type: object
            required: [type, geometry, properties]
            properties:
              type: { type: string, const: Feature }
              id: { type: string }
              geometry:
                anyOf:
                  - $ref: "#/components/schemas/GeoJSONPoint"
                  - type: object
                    required: [type, coordinates]
                    properties:
                      type: { type: string, const: Polygon }
                      coordinates:
                        type: array
                        items:
                          type: array
                          items:
                            type: array
                            minItems: 2
                            maxItems: 2
                            prefixItems:
                              - { type: number, minimum: -180, maximum: 180 }
                              - { type: number, minimum: -90, maximum: 90 }
                  - type: "null"
              properties:
                type: object
        numberReturned: { type: integer, minimum: 0 }
        timeStamp: { type: string, format: date-time }
        links:
          type: array
          items:
            type: object
            required: [rel, href]
            properties:
              rel: { type: string, enum: [self, next] }
              href: { type: string }

    PublicEntity:
      type: object
      required: [id, type, source]
      additionalProperties: false
      properties:
        cve:
          description: Compact disclosure summary on the Cyber CVE collection. Select with fields[entities]=cve.
          $ref: "#/components/schemas/CVESummary"
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
        type:
          type: string
          const: entity
        kind:
          $ref: "#/components/schemas/EntityKind"
        name:
          type: string
        aliases:
          type: array
          items:
            type: string
        externalIds:
          type: object
          additionalProperties:
            type: [string, number, boolean, "null"]
        attributes:
          type: object
          properties:
            isKnownExploitedVulnerability:
              type: boolean
            severity:
              type: string
            cvssScore:
              type: number
            publishedAt:
              type: string
              format: date-time
          additionalProperties: false
        footprint:
          type: object
          additionalProperties: false
          properties:
            website: { type: string, format: uri }
            linkedin: { type: string, format: uri }
            x: { type: string, format: uri }
            github: { type: string, format: uri }
            facebook: { type: string, format: uri }
            wikipedia: { type: string, format: uri }
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        links:
          $ref: "#/components/schemas/PublicResourceLinks"

    PublicEntityRelation:
      type: object
      required: [id, type, from, to, confidence, validFrom, validTo]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^rel_[a-f0-9]{24}$"
        type:
          type: string
        from:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
        to:
          type: string
          pattern: "^ent_[a-f0-9]{24}$"
        confidence:
          type: number
          minimum: 0
          maximum: 1
        validFrom:
          type: [string, "null"]
          format: date-time
        validTo:
          type: [string, "null"]
          format: date-time

    PublicIncidentQuality:
      type: object
      required: [observationCount, primarySourceCount, corroborationScore]
      additionalProperties: false
      properties:
        observationCount:
          type: integer
          minimum: 0
          description: Observations attached to the incident. One published article counts once, however many Y2 pipelines collected it.
        primarySourceCount:
          type: integer
          minimum: 0
          description: Distinct publishers among the incident's primary observations. Two outlets are two sources, even when one Y2 pipeline collected both.
        corroborationScore:
          type: number
          minimum: 0
          maximum: 1
          description: Sum, over distinct publishers, of the best quality weight of the data source that carried each publisher's report. Capped at 1.

    PublicIncident:
      type: object
      required: [id, type, source]
      additionalProperties: false
      properties:
        source:
          $ref: "#/components/schemas/RecordSource"
        id:
          type: string
          pattern: "^inc_[a-f0-9]{24}$"
        type:
          type: string
          const: incident
        title:
          type: string
        category:
          type: string
        severity:
          type: string
          enum: [low, medium, high, critical]
        status:
          type: string
          enum: [active, resolved, forecast]
        occurredAt:
          type: string
          format: date-time
        endedAt:
          type: [string, "null"]
          format: date-time
        firstObservedAt:
          type: string
          format: date-time
          description: Earliest time Y2 observed the incident, independent of when it occurred.
        lastObservedAt:
          type: string
          format: date-time
          description: Latest time Y2 observed or refreshed the incident, independent of when it occurred.
        resolutionReason:
          type: [string, "null"]
        quality:
          $ref: "#/components/schemas/PublicIncidentQuality"
        links:
          $ref: "#/components/schemas/PublicResourceLinks"

    PublicObservationSource:
      type: object
      required: [type, recordId]
      additionalProperties: false
      properties:
        type:
          type: string
        recordId:
          type: string

    PublicObservationLocation:
      type: object
      required: [name, countryCode, region]
      additionalProperties: false
      properties:
        name:
          type: [string, "null"]
        countryCode:
          type: [string, "null"]
        region:
          type: [string, "null"]

    PublicProvenance:
      type: object
      required: [tier, method]
      additionalProperties: false
      properties:
        tier:
          type: string
          enum: [primary, derived, synthesized]
        method:
          type: string
          enum: [direct_ingest, model_extraction]

    PublicObservation:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^obs_[a-f0-9]{24}$"
        type:
          type: string
          const: observation
        source:
          $ref: "#/components/schemas/PublicObservationSource"
        title:
          type: string
        description:
          type: [string, "null"]
        category:
          type: string
        severity:
          type: string
        occurredAt:
          type: string
          format: date-time
        observedAt:
          type: string
          format: date-time
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        location:
          $ref: "#/components/schemas/PublicObservationLocation"
        provenance:
          $ref: "#/components/schemas/PublicProvenance"
        links:
          $ref: "#/components/schemas/PublicResourceLinks"

    PublicPlace:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^plc_[a-f0-9]{24}$"
        type:
          type: string
          const: place
        kind:
          type: string
        name:
          type: string
        countryCode:
          type: [string, "null"]
        admin1:
          type: [string, "null"]
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        bbox:
          type: [array, "null"]
          minItems: 4
          maxItems: 4
          items:
            type: number
        h3Index:
          type: [string, "null"]

    PublicMoney:
      type: [object, "null"]
      required: [value, currency, basis]
      additionalProperties: false
      properties:
        value:
          type: number
        currency:
          type: string
        basis:
          type: string

    PublicProbability:
      type: [object, "null"]
      required: [value, scale]
      additionalProperties: false
      properties:
        value:
          type: number
          minimum: 0
          maximum: 1
        scale:
          type: string
          const: 0_to_1

    PublicMarket:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^mkt_[a-f0-9]{24}$"
        type:
          type: string
          const: market
        source:
          type: string
        question:
          type: string
        category:
          type: string
        status:
          type: string
        resolvesAt:
          type: [string, "null"]
          format: date-time
        probability:
          $ref: "#/components/schemas/PublicProbability"
        volume:
          $ref: "#/components/schemas/PublicMoney"
        liquidity:
          $ref: "#/components/schemas/PublicMoney"
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        links:
          $ref: "#/components/schemas/PublicResourceLinks"

    FinintPeriod:
      description: "Provider reporting label or a timestamp tied to the selected quote. Labels are not inferred UTC boundaries. Null when the adapter has no supported timing. Never inferred from fetch time."
      oneOf:
        - type: "null"
        - type: object
          required: [kind, label, frequency]
          additionalProperties: false
          properties:
            kind:
              type: string
              const: provider_period
            label:
              type: string
              description: Unmodified provider observation date or reporting-period label.
            frequency:
              type: string
              enum: [hourly, daily, weekly, monthly, quarterly, annual, unknown]
              description: Requested or provider-reported cadence. FRED frequency is unknown when its observation response does not supply it.
        - type: object
          required: [kind, at]
          additionalProperties: false
          properties:
            kind:
              type: string
              const: instant
            at:
              type: string
              format: date-time

    FinintProvenance:
      type: [object, "null"]
      description: Bounded provider metadata retained with the current cached value, not an archived source payload or evidence of original publication/availability. Null for rows without captured metadata. This feed does not retain historical vintages.
      required: [coverage, dataset, retrievedAt, method, realtimePeriod]
      additionalProperties: false
      properties:
        coverage:
          type: string
          const: provider_metadata
        dataset:
          type: string
          description: Provider series identifier (FRED), dataset route (EIA), or symbol (Yahoo). No request credentials.
        retrievedAt:
          type: string
          format: date-time
          description: When this provider response was retrieved, distinct from the reporting period or quote time.
        method:
          type: string
          enum: [provider_value, sum, ratio_percent, rounded]
          description: How the current value was derived from the response. Sum covers returned rows only, not a guarantee of complete provider discovery.
        realtimePeriod:
          type: [object, "null"]
          description: "Inclusive FRED response real-time validity window. The default request is today's vintage. These are not the original publication dates."
          required: [start, end]
          additionalProperties: false
          properties:
            start:
              type: string
              format: date
            end:
              type: string
              format: date

    PublicFinintObservation:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^fin_[a-f0-9]{24}$"
        type:
          type: string
          const: financial_observation
        indicator:
          type: object
          required: [id, label, category]
          additionalProperties: false
          properties:
            id:
              type: string
            label:
              type: string
            category:
              type: string
        source:
          type: object
          required: [type, url]
          additionalProperties: false
          properties:
            type:
              type: string
            url:
              type: [string, "null"]
              format: uri
        dimension:
          type: [object, "null"]
          required: [key, type]
          additionalProperties: false
          properties:
            key:
              type: string
            type:
              type: string
        measurement:
          type: object
          required: [value, unit, previousValue, change, changePercent]
          additionalProperties: false
          properties:
            value:
              type: number
            unit:
              type: string
            previousValue:
              type: [number, "null"]
            change:
              type: [number, "null"]
            changePercent:
              type: [number, "null"]
        observedAt:
          type: string
          format: date-time
          description: Existing cache fetch timestamp, not a provider quote time, reporting period, or original publication date.
        period:
          $ref: "#/components/schemas/FinintPeriod"
        provenance:
          $ref: "#/components/schemas/FinintProvenance"
        entities:
          type: array
          maxItems: 8
          description: "Up to eight existing canonical ontology entity links per observation, with a lookup budget of 1000 distinct entity IDs across the page. Unresolved or over-budget references are omitted. No company identity is inferred from a ticker. Does not include tenant research or financial history."
          items:
            type: object
            required: [id]
            additionalProperties: false
            properties:
              id:
                type: string
                pattern: "^ent_[a-f0-9]{24}$"
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        signals:
          type: array
          items:
            type: string

    PublicGraphMeta:
      type: object
      required: [depth, capped]
      additionalProperties: false
      properties:
        depth:
          type: integer
          minimum: 0
        capped:
          type: boolean

    PublicResourceReference:
      type: object
      required: [id]
      additionalProperties: false
      properties:
        id:
          type: string

    PublicSignal:
      type: object
      required: [id, type]
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: "^sig_[a-f0-9]{24}$"
        type:
          type: string
          const: signal
        visibility:
          type: string
        reportId:
          type: string
          pattern: "^rpt_[a-f0-9]{24}$"
        profileId:
          type: string
          pattern: "^prf_[a-f0-9]{24}$"
        profileName:
          type: [string, "null"]
        profileTopic:
          type: [string, "null"]
        reportTopic:
          type: [string, "null"]
        occurredAt:
          type: string
          format: date-time
        reportGeneratedAt:
          type: string
          format: date-time
        domain:
          type: string
        actionType:
          type: string
        priority:
          type: string
        confidence:
          type: number
          minimum: 0
          maximum: 1
        inferenceType:
          type: string
        timeHorizon:
          type: string
        title:
          type: string
        signal:
          type: string
        decision:
          type: string
        justification:
          type: string
        summary:
          type: [string, "null"]
        subjects:
          type: array
          items:
            type: object
            required: [kind, label, key, entityId]
            additionalProperties: false
            properties:
              kind:
                type: string
              label:
                type: string
              key:
                type: string
              entityId:
                type: [string, "null"]
        tags:
          type: array
          items:
            type: string
        sources:
          type: array
          items:
            type: object
            required: [id, url]
            additionalProperties: false
            properties:
              id:
                type: string
                pattern: "^src_[a-f0-9]{24}$"
              url:
                type: string
                format: uri
        geometry:
          $ref: "#/components/schemas/GeoJSONPoint"
        location:
          $ref: "#/components/schemas/PublicObservationLocation"
        relationships:
          type: object
          required: [observations, incidents, places, entities]
          additionalProperties: false
          properties:
            observations:
              type: array
              items:
                $ref: "#/components/schemas/PublicResourceReference"
            incidents:
              type: array
              items:
                $ref: "#/components/schemas/PublicResourceReference"
            places:
              type: array
              items:
                $ref: "#/components/schemas/PublicResourceReference"
            entities:
              type: array
              items:
                $ref: "#/components/schemas/PublicResourceReference"
