openapi: 3.1.0
info:
  title: NetRiskScan IP Risk Intelligence API
  version: 1.9.0
  description: |
    The NetRiskScan Developer API.

    This document tracks the shipped contracts in `PublicApiV1Contracts.cs` and is pinned by
    `PaidPublicApiContractTests`. If a field appears here it is returned; if it is returned it appears here.

    All risk, usage and account reads require an API key. Free includes 5,000 monthly units.
    The website uses a separate homepage query and quota.

    Authenticated requests have no browser CORS access. Keep bearer keys on a server you control.
servers:
  - url: https://api.netriskscan.com
paths:
  /v1/ip-risk/{ip}:
    get:
      operationId: getIpRisk
      summary: Query one IP address (1 query unit, including cache hits)
      description: |
        Requires the `ip-risk:read` scope and bills a unit per successful lookup, including cache hits.

        An address that cannot be scored — loopback, private, reserved — is **not** an error: the response
        is `200` with `risk.index` and `risk.band` null and `risk.assessmentGrade` `insufficient`. Only a
        string that is not an IP address at all produces `400`.
      parameters:
        - in: path
          name: ip
          required: true
          description: An IPv4 or IPv6 address. Echoed back canonicalized in `ip`.
          schema: { type: string }
          example: 8.8.8.8
      responses:
        '200':
          description: NetRiskScan risk intelligence result
          headers:
            X-Request-Id: { $ref: '#/components/headers/XRequestId' }
            X-NetRiskScan-Scoring-Version: { $ref: '#/components/headers/XScoringVersion' }
            X-RateLimit-Limit: { $ref: '#/components/headers/XRateLimitLimit' }
            X-RateLimit-Remaining: { $ref: '#/components/headers/XRateLimitRemaining' }
            X-RateLimit-Reset: { $ref: '#/components/headers/XRateLimitReset' }
            X-Quota-Limit: { $ref: '#/components/headers/XQuotaLimit' }
            X-Quota-Used: { $ref: '#/components/headers/XQuotaUsed' }
            X-Quota-Remaining: { $ref: '#/components/headers/XQuotaRemaining' }
            Link:
              description: Routing data attribution when RIPE RIS supplies network.range.
              schema: { type: string }
            Cache-Control:
              description: Always `no-store`; risk data changes, so do not cache the result long-term.
              schema: { type: string }
            X-Quota-Reset:
              schema:
                type: integer
                format: int64
              description: Unix seconds for the end of the current monthly budget.
            X-Quota-Status:
              schema:
                enum:
                - normal
                - warning
                - critical
                - exhausted
              description: Warning starts at 80%, critical at 95% and exhausted at 100%.
            X-Quota-Usage-Percent:
              schema:
                type: number
                minimum: 0
                maximum: 100
              description: Monthly usage percentage.
            X-Upgrade-Url:
              schema:
                type: string
                format: uri
              description: Official plan and upgrade page.
            X-Developer-Plan:
              schema:
                type: string
              description: Effective plan code.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/IpRiskResponse' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '405': { $ref: '#/components/responses/MethodNotAllowed' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
        '503': { $ref: '#/components/responses/Unavailable' }
      security: [{ bearerApiKey: [] }]
  /v1/ip-risk/batch:
    post:
      operationId: batchIpRisk
      summary: Query a small batch of IP addresses
      description: |
        Requires an active account and a bearer key with both `ip-risk:read` and `batch:execute`.
        Business accepts up to 20 input entries and Scale up to 50. All other plans exclude batch queries.
        Monthly and annual subscriptions for an eligible plan have the same batch limit and monthly quota cycle.

        The server checks the original array length before validating or deduplicating. Invalid strings and
        repeated entries count toward the limit and remain in the output in input order. The server reserves
        one unit per valid, distinct address and bills one unit for each successful unique result, including
        cache hits. Invalid, duplicate and failed items consume no units. A 200 can contain item failures.

        To retrieve a result after a disconnect or timeout, resend the same ordered input strings and
        `Idempotency-Key`. The key is scoped to the account and this operation. In-flight work returns 409
        with `batch_in_progress`. A different input with that key returns 409 with `idempotency_conflict`.
        Terminal results are retained for 24 hours from finalization. The key can start a new billable batch
        after the retention window. To retry failed addresses, use a new key and submit only the addresses
        you intend to query again.

        The request is limited to 16 KiB. Applicable aggregate and source caches are shared with single-IP
        lookups, and this operation accepts no cache-refresh parameters.
      parameters:
        - in: header
          name: Idempotency-Key
          required: true
          description: An account-scoped key for this exact ordered batch. Generate a fresh key for each new batch.
          schema: { type: string, pattern: '^[A-Za-z0-9._-]{1,128}$' }
          example: 7c5e8a9d-e914-427a-8149-d79bbac82bca
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/IpRiskBatchRequest' }
            example: { ips: ['8.8.8.8', '1.1.1.1', '2606:4700:4700::1111'] }
      responses:
        '200':
          description: Final batch response or a replay of that response. See the item statuses for individual outcomes.
          headers:
            X-Request-Id: { $ref: '#/components/headers/XRequestId' }
            X-NetRiskScan-Scoring-Version: { $ref: '#/components/headers/XScoringVersion' }
            X-RateLimit-Limit: { $ref: '#/components/headers/XRateLimitLimit' }
            X-RateLimit-Remaining: { $ref: '#/components/headers/XRateLimitRemaining' }
            X-RateLimit-Reset: { $ref: '#/components/headers/XRateLimitReset' }
            Cache-Control:
              description: Always `no-store`.
              schema: { type: string }
            X-Quota-Limit:
              $ref: '#/components/headers/XQuotaLimit'
            X-Quota-Used:
              $ref: '#/components/headers/XQuotaUsed'
            X-Quota-Remaining:
              $ref: '#/components/headers/XQuotaRemaining'
            X-Quota-Reset:
              schema:
                type: integer
                format: int64
              description: Unix seconds for the end of the current monthly budget.
            X-Quota-Status:
              schema:
                enum:
                - normal
                - warning
                - critical
                - exhausted
              description: Warning starts at 80%, critical at 95% and exhausted at 100%.
            X-Quota-Usage-Percent:
              schema:
                type: number
                minimum: 0
                maximum: 100
              description: Monthly usage percentage.
            X-Upgrade-Url:
              schema:
                type: string
                format: uri
              description: Official plan and upgrade page.
            X-Developer-Plan:
              schema:
                type: string
              description: Effective plan code.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/IpRiskBatchResponse' }
        '400': { $ref: '#/components/responses/BatchBadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/BatchForbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '405': { $ref: '#/components/responses/MethodNotAllowed' }
        '409': { $ref: '#/components/responses/BatchConflict' }
        '413': { $ref: '#/components/responses/BatchPayloadTooLarge' }
        '429': { $ref: '#/components/responses/BatchTooManyRequests' }
        '503': { $ref: '#/components/responses/BatchUnavailable' }
      security: [{ bearerApiKey: [] }]
  /v1/usage:
    get:
      operationId: getUsage
      summary: Read the account's usage in the current quota period
      description: |
        Requires the `usage:read` scope. Consumes no query units.

        Units are counted per **quota period**, which is one month for every plan. The quota period is
        independent of how the plan is billed: an annual subscription is charged once a year but still
        receives its full allowance every month. `period` is the current quota period, and `period.end` is
        when `units.used` resets to zero.
      responses:
        '200':
          description: Current usage
          headers:
            X-Request-Id: { $ref: '#/components/headers/XRequestId' }
            X-NetRiskScan-Scoring-Version: { $ref: '#/components/headers/XScoringVersion' }
            X-Quota-Limit: { $ref: '#/components/headers/XQuotaLimit' }
            X-Quota-Used: { $ref: '#/components/headers/XQuotaUsed' }
            X-Quota-Remaining: { $ref: '#/components/headers/XQuotaRemaining' }
            X-Quota-Reset:
              schema:
                type: integer
                format: int64
              description: Unix seconds for the end of the current monthly budget.
            X-Quota-Status:
              schema:
                enum:
                - normal
                - warning
                - critical
                - exhausted
              description: Warning starts at 80%, critical at 95% and exhausted at 100%.
            X-Quota-Usage-Percent:
              schema:
                type: number
                minimum: 0
                maximum: 100
              description: Monthly usage percentage.
            X-Upgrade-Url:
              schema:
                type: string
                format: uri
              description: Official plan and upgrade page.
            X-Developer-Plan:
              schema:
                type: string
              description: Effective plan code.
            X-Developer-Subscription-Status:
              schema:
                type: string
              description: Subscription state or none, returned on usage reads.
            X-Developer-Batch-Allowed:
              schema:
                type: boolean
              description: Whether the credential and plan permit batch calls.
            X-Developer-Batch-Max:
              schema:
                type: integer
              description: Plan limit on raw batch items.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/UsageResponse' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '404': { $ref: '#/components/responses/NotFound' }
        '405': { $ref: '#/components/responses/MethodNotAllowed' }
        '413': { $ref: '#/components/responses/PayloadTooLarge' }
        '429': { $ref: '#/components/responses/TooManyRequests' }
        '503': { $ref: '#/components/responses/Unavailable' }
      security: [{ bearerApiKey: [] }]
  /v1/account/plan:
    get:
      operationId: getAccountPlan
      summary: Read effective plan details
      security:
      - bearerApiKey: []
      responses:
        '200':
          description: Read effective plan details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiAccountPlan'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /v1/cli/authorization:
    post:
      operationId: retiredCliAuthorization
      summary: Identify CLI versions that require an update
      deprecated: true
      security: []
      responses:
        '410':
          description: loopback_required
          content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
  /v1/cli/authorization/loopback:
    post:
      operationId: startCliAuthorization
      summary: Start a 10-minute CLI Google authorization
      description: Use an independent random state and PKCE verifier. codeChallenge is base64url(SHA-256(ASCII
        verifier)). Replay identical inputs to recover the same transaction. Open browserUrl on the same device
        as the listener registered in redirectUri. Set operation to select a key with the scopes required by a CLI command.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliAuthorizeStart'
            example:
              transactionId: 01f0dbe3c8d84926bc9460710dadce01
              state: 4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
              codeChallenge: KEfn-NksRLLFSYdcx7IN9tSCSIGf9mFAYRSJ42QEB3E
              installationId: fa4953570c5d4b12866ffa1df0efc510
              publicKey: BASE64_RSA_SPKI_DER
              redirectUri: http://127.0.0.1:47321/oauth/callback
      responses:
        '200':
          description: Start a 10-minute CLI Google authorization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliStart'
              example:
                flow: loopback
                transactionId: 01f0dbe3c8d84926bc9460710dadce01
                browserUrl: https://www.netriskscan.com/developer/cli/loopback#transactionId=01f0dbe3c8d84926bc9460710dadce01&state=4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
                expiresAt: '2026-12-02T04:10:00Z'
        '400':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: transaction_conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: rate_limit_exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503': { $ref: '#/components/responses/Unavailable' }
  /v1/cli/authorization/loopback/{id}/exchange:
    post:
      operationId: exchangeCliAuthorization
      summary: Redeem the one-time code for CLI access
      description: >-
        The code can be redeemed once within two minutes of browser approval. Successful responses use
        RSA-OAEP with SHA-256 for OAEP and MGF1, an empty label and UTF-8 plaintext. Clients can request
        includeMetadata to receive keySource and an account and quota snapshot. Successful authorization
        is independent of remaining query quota.
      security: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliExchange'
            example:
              codeVerifier: 5sDOUgPbJiYMTKx0P5viTXN9FMEtBdYgXzF-oHV0QfU
              authorizationCode: 4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
      responses:
        '200':
          description: New or recovered API key ciphertext after explicit device authorization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliDelivery'
              example:
                status: issued
                accountEmail: developer@example.com
                keyId: d51edfc6
                encryptedApiKey: BASE64_RSA_CIPHERTEXT
                encryption: RSA-OAEP-256
                expiresAt: '2026-12-02T04:10:00Z'
        '401':
          description: invalid_transaction_proof
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: account_not_active, plan_not_available, or scope_not_allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: authorization_code_used, key_recovery_required (installation_already_authorized for legacy exchange), or key_limit_reached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Authorization recovery rate limit reached
        '503': { $ref: '#/components/responses/Unavailable' }
  /v1/cli/authorization/loopback/{id}/acknowledge:
    post:
      operationId: acknowledgeCliKey
      summary: Acknowledge successful CLI credential delivery
      security: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliExchange'
            example:
              codeVerifier: 5sDOUgPbJiYMTKx0P5viTXN9FMEtBdYgXzF-oHV0QfU
              authorizationCode: 4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
      responses:
        '204':
          description: Delivery acknowledged. The exchange remains single use.
        '401':
          description: invalid_transaction_proof
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: key_not_issued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503': { $ref: '#/components/responses/Unavailable' }
  /v1/cli/upgrade-sessions:
    post:
      operationId: startCliUpgrade
      summary: Create a one-hour session bound to the API-key account
      description: Use a key with usage:read. The browser owner chooses and confirms the plan in the website
        session.
      security:
      - bearerApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliUpgradeStart'
            example:
              transactionId: 01f0dbe3c8d84926bc9460710dadce01
              state: 4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
              codeChallenge: KEfn-NksRLLFSYdcx7IN9tSCSIGf9mFAYRSJ42QEB3E
      responses:
        '200':
          description: Create a one-hour session bound to the API-key account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliUpgradeStartResult'
              example:
                transactionId: 01f0dbe3c8d84926bc9460710dadce01
                browserUrl: https://www.netriskscan.com/developer/cli#transactionId=01f0dbe3c8d84926bc9460710dadce01&state=4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc&purpose=upgrade
                confirmationCode: 2B7AF1F7
                expiresAt: '2026-12-02T04:10:00Z'
                intervalSeconds: 5
        '400':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: transaction_conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: rate_limit_exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503': { $ref: '#/components/responses/Unavailable' }
  /v1/cli/upgrade-sessions/{id}/status:
    post:
      operationId: pollCliUpgrade
      summary: Read the confirmed plan for an upgrade session
      description: plan_changed reports a change in the account’s effective plan, confirmed server-side. The
        authorized status also covers waiting for payment or a session with no purchase.
      security: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliProof'
            example:
              codeVerifier: 5sDOUgPbJiYMTKx0P5viTXN9FMEtBdYgXzF-oHV0QfU
      responses:
        '200':
          description: Read the confirmed plan for an upgrade session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliUpgradeStatus'
              example:
                status: authorized
                initialPlan: free
                plan: free
                subscriptionStatus: null
                planChanged: false
                expiresAt: '2026-12-02T04:10:00Z'
                planEffectiveAt: null
        '401':
          description: invalid_transaction_proof
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/CliSlowDown'
        '403':
          description: account_not_active
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503': { $ref: '#/components/responses/Unavailable' }
  /api/developer/auth/google:
    post:
      operationId: signIntoDeveloperAccountWithGoogle
      summary: Sign into the developer website with a verified Google ID token
      description: Creates or reuses the account, and issues the website session cookie.
      servers: [{ url: 'https://www.netriskscan.com' }]
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [idToken]
              properties:
                idToken: { type: string }
                attribution: { type: [object, 'null'] }
      responses:
        '200':
          description: Browser session and developer account
          content:
            application/json:
              schema:
                type: object
                required: [success, data, traceId, timestamp]
                properties:
                  success: { const: true }
                  code: { type: 'null' }
                  message: { type: 'null' }
                  traceId: { type: string }
                  timestamp: { type: string, format: date-time }
                  data: { $ref: '#/components/schemas/DeveloperGoogleSession' }
        '401':
          description: GOOGLE_AUTH_FAILED or AUTHENTICATION_FAILED
          content: { application/json: { schema: { $ref: '#/components/schemas/WebsiteError' } } }
        '403':
          description: GOOGLE_EMAIL_NOT_VERIFIED or ACCOUNT_DISABLED
          content: { application/json: { schema: { $ref: '#/components/schemas/WebsiteError' } } }
  /api/developer/cli/google/callback:
    post:
      operationId: completeCliGoogleAuthorization
      summary: Complete a CLI transaction with a nonce-bound Google ID token
      description: The website submits the Google ID token as form data. Only a verified Google identity
        and matching unused state can authorize the registered loopback redirect.
      servers:
      - url: https://www.netriskscan.com
      security: []
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required: [transactionId, state, idToken, approved]
              properties:
                transactionId: { type: string, pattern: '^[0-9a-fA-F]{32}$' }
                state: { type: string, pattern: '^[A-Za-z0-9_-]{43}$' }
                idToken: { type: string, maxLength: 4096 }
                approved: { type: boolean, const: true }
      responses:
        '303':
          description: Redirect with only code and state.
          headers:
            Location:
              schema: { type: string, format: uri }
            Referrer-Policy:
              schema: { const: no-referrer }
            Cache-Control:
              schema: { const: no-store }
        '401':
          description: invalid_transaction_proof or google_auth_failed
        '403':
          description: device_approval_required, google_email_not_verified, or account_not_active
        '409':
          description: transaction_already_authorized
        '410':
          description: transaction_expired
  /api/developer/cli/approve:
    post:
      operationId: approveCliInBrowser
      summary: Approve the CLI upgrade from the website
      description: The reviewer must sign in to the account that started the upgrade session.
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      parameters:
      - name: X-CSRF-Token
        in: header
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CliBrowserApprove'
            example:
              transactionId: 01f0dbe3c8d84926bc9460710dadce01
              state: 4wCRtFUABCh9yckZD9XDe2mFY0d7HCKDB_5U0GekcCc
      responses:
        '200':
          description: Approve the transaction from the website
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: object
                    additionalProperties: false
                    required:
                    - nextUrl
                    properties:
                      nextUrl:
                        type:
                        - string
                        - 'null'
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '400':
          description: invalid_request or invalid_transaction_proof
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '410':
          description: transaction_expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/public/home-ip:
    get:
      operationId: detectHomeIp
      summary: Detect the visitor’s trusted public IP
      servers:
      - url: https://www.netriskscan.com
      security: []
      responses:
        '200':
          description: Detect the visitor’s trusted public IP
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: string
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: PUBLIC_IP_UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
    post:
      operationId: queryHomeVisitorIp
      summary: Query the visitor’s public IP
      servers:
      - url: https://www.netriskscan.com
      security: []
      responses:
        '200':
          description: Query the visitor’s public IP
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpRiskResponse'
        '400':
          description: PUBLIC_IP_UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: Cross-site request or verified crawler refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '429':
          description: Website rate limit or daily quota reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '503':
          description: LIVE_LOOKUP_UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/public/home-ip/query:
    post:
      operationId: queryHomeIp
      summary: Query an explicit public IP through the website
      servers:
      - url: https://www.netriskscan.com
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HomeIpQuery'
            example:
              ip: 1.1.1.1
      responses:
        '200':
          description: Query an explicit public IP through the website
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpRiskResponse'
        '400':
          description: INVALID_PUBLIC_IP or PUBLIC_IP_UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: Cross-site request or verified crawler refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '429':
          description: Website rate limit or daily quota reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '503':
          description: LIVE_LOOKUP_UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/developer/plans:
    get:
      operationId: listDeveloperPlans
      summary: List enabled public plans and prices
      servers:
      - url: https://www.netriskscan.com
      security: []
      responses:
        '200':
          description: List enabled public plans and prices
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/DeveloperPlan'
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
  /api/developer/account/plan:
    get:
      operationId: getWebsiteDeveloperPlan
      summary: Read the owner’s plan
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      responses:
        '200':
          description: Read the owner’s plan
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    $ref: '#/components/schemas/DeveloperPlan'
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/developer/billing:
    get:
      operationId: getDeveloperBilling
      summary: Read billing and subscription status
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      responses:
        '200':
          description: Read billing and subscription status
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    $ref: '#/components/schemas/DeveloperBilling'
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/developer/billing/checkout:
    post:
      operationId: startDeveloperCheckout
      summary: Open Stripe Checkout
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      parameters:
      - name: X-CSRF-Token
        in: header
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeveloperCheckoutRequest'
            example:
              planCode: business
              billingCycle: monthly
      responses:
        '200':
          description: Open Stripe Checkout
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: object
                    additionalProperties: false
                    required:
                    - checkoutUrl
                    properties:
                      checkoutUrl:
                        type: string
                        format: uri
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '409':
          description: The plan or subscription conflicts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '503':
          description: BILLING_NOT_CONFIGURED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/developer/billing/upgrade:
    post:
      operationId: upgradeDeveloperSubscription
      summary: Apply a confirmed prorated paid upgrade
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      parameters:
      - name: X-CSRF-Token
        in: header
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeveloperCheckoutRequest'
            example:
              planCode: scale
              billingCycle: monthly
      responses:
        '200':
          description: Apply a confirmed prorated paid upgrade
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: object
                    additionalProperties: false
                    required:
                    - status
                    - providerInvoiceId
                    properties:
                      status:
                        const: applied
                      providerInvoiceId:
                        type:
                        - string
                        - 'null'
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '402':
          description: UPGRADE_PAYMENT_PENDING
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '409':
          description: The current subscription cannot be upgraded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '503':
          description: Billing unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
  /api/developer/billing/portal:
    post:
      operationId: openDeveloperBillingPortal
      summary: Open Stripe Customer Portal
      servers:
      - url: https://www.netriskscan.com
      security:
      - developerCookie: []
      parameters:
      - name: X-CSRF-Token
        in: header
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Open Stripe Customer Portal
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - success
                - code
                - message
                - data
                - traceId
                - timestamp
                properties:
                  success:
                    const: true
                  code:
                    type: 'null'
                  message:
                    type: 'null'
                  data:
                    type: object
                    additionalProperties: false
                    required:
                    - portalUrl
                    properties:
                      portalUrl:
                        type: string
                        format: uri
                  traceId:
                    type: string
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Developer session required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '403':
          description: The developer session or CSRF validation refused the action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
        '503':
          description: BILLING_NOT_CONFIGURED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteError'
components:
  securitySchemes:
    bearerApiKey:
      type: http
      scheme: bearer
      bearerFormat: nrs_live
      description: |
        `Authorization: Bearer nrs_live_...`. Never place the key in a URL, and never ship it to a browser.

    developerCookie:
      type: apiKey
      in: cookie
      name: nrs_dev_session

  headers:
    XScoringVersion:
      description: |
        Which version of the scoring algorithm produced this response — e.g. `risk-v4.35`. Present on
        every `/v1` response including errors, so a report about an unexpected result can be tied to the
        build that produced it.

        **`risk.index` and `risk.band` are not promised to be numerically stable across scoring
        versions.** The algorithm improves, and an improvement that could never change a published number
        would not be one. What is stable is the meaning and direction of every field: a higher `index` is
        safer, and the band vocabulary does not change under you. Log this header alongside results if you
        need to explain why the same address returned a different band months apart.

        Deliberately a header and not a body field: this schema sets `additionalProperties: false`, so a
        new response property would break strictly-validating clients generated from an older spec.
      schema: { type: string }
      example: risk-v4.35
    XRequestId:
      description: |
        Trace ID for this request, `req_…`. Quote it in a support request.

        Send your own `X-Request-Id` matching `^req_[A-Za-z0-9_-]{8,56}$` and it is used verbatim end to
        end; anything else is replaced with a generated one.
      schema: { type: string, pattern: '^req_[A-Za-z0-9_-]{8,56}$' }
    XRateLimitLimit:
      description: Requests allowed per minute on the current plan.
      schema: { type: integer }
    XRateLimitRemaining:
      description: Requests left in the current one-minute window.
      schema: { type: integer }
    XRateLimitReset:
      description: Unix timestamp (seconds) when the current fixed minute window resets.
      schema: { type: integer, format: int64 }
    XQuotaLimit:
      description: Query units the plan allows in the current monthly quota period.
      schema: { type: integer, format: int64 }
    XQuotaUsed:
      description: Query units consumed in the current monthly quota period.
      schema: { type: integer, format: int64 }
    XQuotaRemaining:
      description: Query units left in the current monthly quota period.
      schema: { type: integer, format: int64 }

  schemas:
    CliAuthorizeStart:
      type: object
      additionalProperties: false
      required:
      - transactionId
      - installationId
      - state
      - codeChallenge
      - publicKey
      - redirectUri
      properties:
        transactionId:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
        installationId:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
        state:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
        codeChallenge:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
        redirectUri:
          type: string
          format: uri
          description: Exact HTTP loopback URL using 127.0.0.1 or [::1], an explicit port, and /oauth/callback.
        publicKey:
          type: string
          contentEncoding: base64
          maxLength: 640
          description: RSA 2048 or 3072-bit public key in DER SubjectPublicKeyInfo format.
        operation:
          enum: [check, usage]
          description: Selects a key with ip-risk:read (check, including CLI batch) or usage:read.
    CliUpgradeStart:
      type: object
      additionalProperties: false
      required:
      - transactionId
      - state
      - codeChallenge
      properties:
        transactionId:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
        state:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
        codeChallenge:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
    CliProof:
      type: object
      additionalProperties: false
      required:
      - codeVerifier
      properties:
        codeVerifier:
          type: string
          pattern: ^[A-Za-z0-9._~-]{43,128}$
    CliExchange:
      type: object
      additionalProperties: false
      required:
      - codeVerifier
      - authorizationCode
      properties:
        codeVerifier:
          type: string
          pattern: ^[A-Za-z0-9._~-]{43,128}$
        authorizationCode:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
        includeMetadata:
          type: boolean
          default: false
          description: Include key source, account, plan, quota and management URLs in the exchange response.
    CliBrowserApprove:
      type: object
      additionalProperties: false
      required:
      - transactionId
      - state
      properties:
        transactionId:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
        state:
          type: string
          pattern: ^[A-Za-z0-9_-]{43}$
    CliStart:
      type: object
      additionalProperties: false
      required: [flow, transactionId, browserUrl, expiresAt]
      properties:
        flow: { const: loopback }
        transactionId: { type: string, pattern: '^[0-9a-fA-F]{32}$' }
        browserUrl: { type: string, format: uri }
        expiresAt: { type: string, format: date-time }
    CliUpgradeStartResult:
      type: object
      additionalProperties: false
      required:
      - transactionId
      - browserUrl
      - confirmationCode
      - expiresAt
      - intervalSeconds
      properties:
        transactionId:
          type: string
          pattern: ^[0-9a-fA-F]{32}$
        browserUrl:
          type: string
          format: uri
        confirmationCode:
          type: string
          pattern: ^[A-F0-9]{8}$
        expiresAt:
          type: string
          format: date-time
        intervalSeconds:
          const: 5
    CliDelivery:
      type: object
      additionalProperties: false
      required: [status, accountEmail, keyId, encryptedApiKey, encryption, expiresAt]
      properties:
        status: { enum: [issued, existing, access_token] }
        accountEmail: { type: string, format: email }
        keyId: { type: string }
        encryptedApiKey:
          type: [string, 'null']
          contentEncoding: base64
          description: RSA ciphertext on issued responses. Older origins can return null on access_token or existing responses.
        encryption: { enum: [RSA-OAEP-256, null] }
        expiresAt: { type: string, format: date-time }
        accessToken:
          type: string
          pattern: ^nrs_cli_[A-Za-z0-9_-]+$
          description: Legacy short-lived Developer API Bearer token bound to an existing key.
        accessTokenExpiresAt:
          type: string
          format: date-time
          description: Token expiry, at most 15 minutes from exchange. Present only on access_token responses.
        keySource: { enum: [key_reused, key_created] }
        accountId: { type: integer, format: int64 }
        plan: { type: string }
        quota:
          type: object
          required: [limit, used, remaining, resetsAt]
          properties:
            limit: { type: integer, format: int64 }
            used: { type: integer, format: int64 }
            remaining: { type: integer, format: int64 }
            resetsAt: { type: string, format: date-time }
        keyManagementUrl: { type: string, format: uri }
        upgradeUrl: { type: string, format: uri }
    CliUpgradeStatus:
      type: object
      additionalProperties: false
      required:
      - status
      - initialPlan
      - plan
      - subscriptionStatus
      - planChanged
      - expiresAt
      - planEffectiveAt
      properties:
        status:
          enum:
          - pending
          - authorized
          - plan_changed
        initialPlan:
          type: string
        plan:
          type: string
        subscriptionStatus:
          type:
          - string
          - 'null'
        planChanged:
          type: boolean
        expiresAt:
          type: string
          format: date-time
        planEffectiveAt:
          type:
          - string
          - 'null'
          format: date-time
    PublicApiAccountPlan:
      type: object
      additionalProperties: false
      required:
      - plan
      - name
      - subscriptionStatus
      - requestsPerMinute
      - monthlyUnits
      - allowBatch
      - maxBatchSize
      - upgradeUrl
      - planEffectiveAt
      properties:
        plan:
          type: string
        name:
          type: string
        subscriptionStatus:
          type:
          - string
          - 'null'
        requestsPerMinute:
          type: integer
        monthlyUnits:
          type: integer
        allowBatch:
          type: boolean
        maxBatchSize:
          type: integer
        upgradeUrl:
          type: string
          format: uri
        planEffectiveAt:
          type:
          - string
          - 'null'
          format: date-time
    WebsiteError:
      type: object
      additionalProperties: false
      required:
      - success
      - code
      - message
      - data
      - traceId
      - timestamp
      properties:
        success:
          const: false
        code:
          type: string
        message:
          type: string
        data:
          type: 'null'
        traceId:
          type: string
        timestamp:
          type: string
          format: date-time
    HomeIpQuery:
      type: object
      additionalProperties: false
      required:
      - ip
      properties:
        ip:
          type: string
    DeveloperGoogleSession:
      type: object
      required: [authenticated, user, account, csrfToken, googleAccountLinked, isNewRegistration]
      properties:
        authenticated: { const: true }
        user:
          type: object
          required: [email, emailVerified, createdAt, lastLoginAt]
          properties:
            email: { type: string, format: email }
            emailVerified: { type: boolean }
            createdAt: { type: string, format: date-time }
            lastLoginAt: { type: [string, 'null'], format: date-time }
        account:
          type: object
          required: [status, planCode, planName, billingPeriodStart, billingPeriodEnd, allowBatch, maxBatchSize]
          properties:
            status: { type: string }
            planCode: { type: string }
            planName: { type: string }
            billingPeriodStart: { type: string, format: date-time }
            billingPeriodEnd: { type: string, format: date-time }
            allowBatch: { type: boolean }
            maxBatchSize: { type: integer }
        csrfToken: { type: [string, 'null'] }
        googleAccountLinked: { type: boolean }
        isNewRegistration: { type: boolean }
    DeveloperCheckoutRequest:
      type: object
      additionalProperties: false
      required:
      - planCode
      - billingCycle
      properties:
        planCode:
          type: string
        billingCycle:
          enum:
          - monthly
          - yearly
    DeveloperPlan:
      type: object
      additionalProperties: false
      required:
      - code
      - name
      - description
      - sortOrder
      - requestsPerMinute
      - billingPeriodUnits
      - maxConcurrency
      - maxCredentials
      - allowBatch
      - maxBatchSize
      - hasMonthlyPrice
      - monthlyPrice
      - hasYearlyPrice
      - yearlyPrice
      - currency
      properties:
        code:
          type: string
        name:
          type: string
        description:
          type:
          - string
          - 'null'
        sortOrder:
          type: integer
        requestsPerMinute:
          type: integer
        billingPeriodUnits:
          type: integer
        maxConcurrency:
          type: integer
        maxCredentials:
          type: integer
        allowBatch:
          type: boolean
        maxBatchSize:
          type: integer
        hasMonthlyPrice:
          type: boolean
        monthlyPrice:
          type:
          - number
          - 'null'
        hasYearlyPrice:
          type: boolean
        yearlyPrice:
          type:
          - number
          - 'null'
        currency:
          type:
          - string
          - 'null'
    DeveloperBilling:
      type: object
      additionalProperties: false
      required:
      - billingConfigured
      - planCode
      - planName
      - subscriptionStatus
      - periodStart
      - periodEnd
      - cancelAtPeriodEnd
      - hasStripeCustomer
      - allowBatch
      - maxBatchSize
      properties:
        billingConfigured:
          type: boolean
        planCode:
          type: string
        planName:
          type: string
        subscriptionStatus:
          type:
          - string
          - 'null'
        periodStart:
          type:
          - string
          - 'null'
          format: date-time
        periodEnd:
          type:
          - string
          - 'null'
          format: date-time
        cancelAtPeriodEnd:
          type: boolean
        hasStripeCustomer:
          type: boolean
        allowBatch:
          type: boolean
        maxBatchSize:
          type: integer
    IpRiskBatchRequest:
      type: object
      additionalProperties: false
      required: [ips]
      properties:
        ips:
          type: array
          minItems: 1
          maxItems: 50
          items: { type: string }
          description: Ordered input strings containing IPv4 or IPv6 addresses. Business has a maximum of 20 entries.

    IpRiskBatchResponse:
      type: object
      additionalProperties: false
      required: [batchId, inputCount, invalidCount, duplicateCount, uniqueIpCount, successCount, failureCount, billedUnits, scoringVersion, items]
      properties:
        batchId:
          type: string
          description: Stable identifier of this batch, shared by all replays.
        inputCount: { type: integer, minimum: 1, maximum: 50 }
        invalidCount: { type: integer, minimum: 0 }
        duplicateCount: { type: integer, minimum: 0 }
        uniqueIpCount: { type: integer, minimum: 0 }
        successCount:
          type: integer
          minimum: 0
          description: Number of successful unique lookups.
        failureCount:
          type: integer
          minimum: 0
          description: Number of failed unique lookups. Invalid and duplicate entries have separate counts.
        billedUnits:
          type: integer
          minimum: 0
          description: Units billed for the original batch, including on a replay. A replay creates no additional charge.
        scoringVersion:
          type: string
          description: Scoring version recorded with the original batch.
        items:
          type: array
          minItems: 1
          maxItems: 50
          items: { $ref: '#/components/schemas/IpRiskBatchItem' }
          description: One result per submitted entry, in input order.

    IpRiskBatchItem:
      type: object
      additionalProperties: false
      required: [position, input, ip, status, data, error, duplicateOf, retryable, freshness, attribution]
      properties:
        position: { type: integer, minimum: 0, maximum: 49, description: Zero-based input position. }
        input: { type: string, description: Original input string. }
        ip:
          type: [string, 'null']
          description: Canonical address when the input parsed successfully.
        status:
          type: string
          enum: [success, failed, invalid, duplicate]
        data:
          oneOf:
            - $ref: '#/components/schemas/IpRiskResponse'
            - type: 'null'
          description: The public single-IP result for a successful lookup. Quota metadata is sent in response headers.
        error:
          oneOf:
            - $ref: '#/components/schemas/BatchItemError'
            - type: 'null'
          description: The item error for a failed or invalid input. Batch-level failures use ErrorResponse instead.
        duplicateOf:
          type: [integer, 'null']
          minimum: 0
          maximum: 49
          description: Zero-based position of the first canonical occurrence. Read that item's outcome for a duplicate.
        retryable:
          type: boolean
          description: Whether a failed item can be retried as a new lookup.
        freshness:
          type: [string, 'null']
          enum: [stale, null]
          description: Stale aggregate fallback when used. See the result's evidence for source-freshness details.
        attribution:
          type: [string, 'null']
          description: Routing-data attribution in the same format as the Link response header on the single-IP route.

    BatchItemError:
      type: object
      additionalProperties: false
      required: [code, message]
      properties:
        code:
          type: string
          description: '`invalid_ip`, `temporarily_unavailable`, `query_timeout`, or `query_incomplete`. Open value set.'
        message: { type: string }

    IpRiskResponse:
      type: object
      additionalProperties: false
      required: [requestId, ip, risk, network, flags, location]
      properties:
        requestId:
          type: string
          description: Trace ID for this request.
          examples: [req_8f3ab21c9dab]
        ip:
          type: string
          description: |
            The queried address, **canonicalized** — the server's parse of it, not a verbatim echo of the
            path segment. `2001:0DB8::0001` returns `2001:db8::1`; `0177.0.0.1` returns `127.0.0.1`. Use
            this value to match a response back to its request when batching.

            Canonicalization does not cross address families: an IPv4-mapped address stays IPv6, so
            `::FFFF:8.8.8.8` returns `::ffff:8.8.8.8`, not `8.8.8.8`.
          examples: ['8.8.8.8']
        risk: { $ref: '#/components/schemas/Risk' }
        network: { $ref: '#/components/schemas/Network' }
        flags: { $ref: '#/components/schemas/Flags' }
        location:
          oneOf:
            - $ref: '#/components/schemas/Location'
            - type: 'null'
          description: |
            Network-level geolocation of the address. **Always present as a key**; `null` — the whole
            object, not six null members — when nothing is known about where this network is.

            Added in schema 1.3.0. Unlike `tor`, which is omitted entirely when absent, this key is
            always sent, so a client reads it positionally without distinguishing "no location" from
            "old server".
        tor:
          allOf: [{ $ref: '#/components/schemas/TorRelay' }]
          description: |
            Present **only** when the address is a Tor relay and the Tor Project consensus answered.
            Omitted entirely — not `null` — for every other address, so responses for addresses you
            already query are byte-identical to what they were before this block existed.

            Purely additive: `flags.tor` keeps its published exit-only meaning, and this is where the
            distinctions a single boolean cannot carry are published.

    Risk:
      type: object
      additionalProperties: false
      required: [index, band, assessmentGrade, reasons, evidence, signals]
      properties:
        index:
          type: [integer, 'null']
          minimum: 0
          maximum: 100
          description: |
            The NetRiskScan Index. **Higher means cleaner** — this is not a threat score. `null` when the
            address cannot be scored at all, in which case `assessmentGrade` is `insufficient`.
          examples: [95]
        band:
          type: [string, 'null']
          description: |
            Server-side classification of `index`: 90-100 `excellent`, 75-89 `good`, 60-74 `fair`,
            40-59 `poor`, 0-39 `high_risk`. `unknown` means no index could be produced. Read this rather
            than re-deriving thresholds locally. `null` whenever `index` is `null`.

            Treat the value set as open: render an unrecognised value rather than rejecting it.
          examples: [excellent]
        assessmentGrade:
          type: string
          description: |
            Evidence completeness behind this assessment: `complete`, `partial`, `limited`, `insufficient`.
            Reported separately from `band`, and always present. Open value set.
          examples: [complete]
        reasons:
          type: array
          items: { $ref: '#/components/schemas/RiskReason' }
          description: |
            Why the address scores the way it does. **Always present**; an empty array when nothing
            fired, never `null`.

            **Ordered**: severity descending (`critical`, `high`, `medium`, `low`, `info`), then by
            `code`. The same result always serializes identically, so the array is safe to diff or hash.

            **Explanations, not accusations.** Each entry reports an observed network characteristic or
            a piece of risk evidence — not proof of fraud. `VPN_DETECTED` means a VPN was detected, not
            that the user behind it is malicious; `DATACENTER_PROXY_DETECTED` is not a fraud verdict.
            What to do about an observation depends on your own context, which is yours to apply.

            **Identity and threat entries are orthogonal.** A verified search crawler that is also a
            confirmed abuse source publishes both, because both are true. A crawler identity is never a
            whitelist and never removes a finding.

            **Not the scoring engine's internals.** These codes describe network facts, not how the
            Index was computed: no rule names, no provider names, no weights or contributions. That is
            what lets the scoring algorithm be revised without breaking your integration.

            Added in schema 1.3.0.
        evidence: { $ref: '#/components/schemas/Evidence' }
        signals: { $ref: '#/components/schemas/Signals' }

    Signals:
      type: object
      description: |
        The full four-value verdict per curated signal, keyed by signal name (e.g. `Proxy`, `Tor`,
        `ResidentialProxy`, `MaliciousAsn`) — additive alongside `flags`, whose booleans cannot tell two
        of these four states apart.

        Every value is one of:

        - `detected` — a reliable source confirmed this signal for this address this round.
        - `not_detected` — at least one source that actually checks for this signal ran and reported no.
          A real negative, not a guess.
        - `unknown` — a source that can answer this exists, but nothing answered it this round (timeout,
          quota, or it simply had no opinion for this address). Never treat this as a negative.
        - `not_supported` — no source this deployment uses even checks for this signal. A capability gap,
          not a statement about the address. Never treat this as a negative either.

        `unknown` and `not_supported` both publish `null` in the corresponding `flags` boolean, because a
        boolean cannot say both — this object is what lets a caller who needs the distinction get it.

        Added in schema 1.5.0.
      additionalProperties:
        type: string
        enum: [detected, not_detected, unknown, not_supported]

    Evidence:
      type: object
      additionalProperties: false
      required: [coverage, confidence, agreement, freshnessSeconds]
      description: |
        How much to trust `risk.index`, without naming which providers were consulted to reach it.
        NetRiskScan resolves conflicting third-party signals into one Index rather than handing you a
        provider-by-provider table — this object is the trust-and-transparency layer for that decision,
        not a second score, and it can never move `index`.

        Added in schema 1.4.0.
      properties:
        coverage:
          type: integer
          minimum: 0
          maximum: 100
          description: |
            What share of the risk questions worth asking actually got an answer this round. Purely
            descriptive: low coverage never lowers `index` by itself.
          examples: [87]
        confidence:
          type: string
          description: |
            How much to trust `index` given coverage, evidence strength and freshness: `high`, `medium`,
            `low`, `insufficient`. Treat the value set as open.
          examples: [high]
        agreement:
          type: string
          description: |
            Whether the independent evidence behind this round's verdict corroborates itself: `high`,
            `medium`, `low`, `unknown`. **Not a risk signal** — `low` means sources disagreed or only one
            ever spoke, never which side was right. Treat the value set as open.
          examples: [high]
        freshnessSeconds:
          type: [integer, 'null']
          minimum: 0
          description: |
            How many seconds ago the most recently observed signal behind this result was collected.
            `null` when no signal evidence was collected at all (e.g. a private or not-applicable
            address).
          examples: [1080]

    RiskReason:
      type: object
      additionalProperties: false
      required: [code, category, severity]
      description: |
        One published reason. Three fields, deliberately — see `risk.reasons`.
      properties:
        code:
          type: string
          description: |
            What was observed. **Treat this as an open value set**: new codes are added as intelligence
            improves, without a new API version, so render an unrecognised code rather than rejecting
            the response.

            *Anonymity*
            - `RESIDENTIAL_PROXY_DETECTED` — egress through a residential proxy network.
            - `ISP_PROXY_DETECTED` — a proxy on ISP-allocated ("static residential") space. Requires
              explicit subtype evidence; no wired source answers that today, so it is part of the
              vocabulary and is not currently returned.
            - `MOBILE_PROXY_DETECTED` — a confirmed proxy on a mobile network.
            - `DATACENTER_PROXY_DETECTED` — a confirmed proxy on datacenter/hosting infrastructure.
            - `PROXY_DETECTED` — a confirmed proxy whose subtype could not be established. Emitted
              **only** when none of the four above applies: you never receive a general and a specific
              proxy statement about the same detection.
            - `VPN_DETECTED` — a VPN endpoint.
            - `TOR_EXIT_NODE` — a confirmed Tor **exit**. Same fact as `flags.tor`.
            - `TOR_RELAY` — a Tor Middle or Guard relay, which has no exit capability. Never emitted
              together with `TOR_EXIT_NODE`.

            *Threat*
            - `BOTNET_C2` — confirmed botnet command-and-control infrastructure.
            - `COMPROMISED_HOST` — the host is under someone else's control.
            - `MALWARE_HOST` — running or serving malware.
            - `ATTACK_SOURCE` — observed as a source of attack traffic.
            - `SPAM_SOURCE` — observed sending spam.
            - `SSH_BRUTE_FORCE` — SSH brute-force, where a source named SSH explicitly.
            - `CREDENTIAL_ATTACK` — an authentication endpoint was attacked, transport unestablished.
              Deliberately weaker than `SSH_BRUTE_FORCE`, and not merged with it.
            - `KNOWN_SCANNER` — scanning, crawling or bot behaviour observed. Same signals as
              `flags.scanner`, so the two never disagree.

            *Reputation*
            - `BLACKLIST_MATCH` — listed by multiple independent blacklist sources.
            - `ABUSE_ACTIVITY` — a standing abuse record. Never emitted alongside `BLACKLIST_MATCH`:
              they are two tiers of one fact.

            *Identity / network*
            - `VERIFIED_SEARCH_CRAWLER` — verified search-engine crawler infrastructure, from a range
              the operator itself publishes. Identity, not a whitelist.
            - `PUBLIC_INFRASTRUCTURE` — public internet infrastructure (public DNS resolver, CDN edge,
              crawler, measurement platform). This is what explains a high Index on an address that is
              nonetheless hosted in a datacenter.
            - `RESIDENTIAL_NETWORK` — an ordinary consumer access network.
            - `DATACENTER_NETWORK` — datacenter or hosting infrastructure. Informational: a datacenter
              is not a fraud signal.

            At most one of the three network codes appears, and it is dropped when a proxy code already
            names the same network kind — a residential proxy publishes `RESIDENTIAL_PROXY_DETECTED`
            alone, never that plus `RESIDENTIAL_NETWORK`.

            *Data quality* — statements about the evidence, not about the address.
            - `CONFLICTING_EVIDENCE` — independent sources disagreed.
            - `INSUFFICIENT_EVIDENCE` — too little evidence to assess the address; the companion to a
              null `index` and an `insufficient` `assessmentGrade`.
          examples: [VERIFIED_SEARCH_CRAWLER]
        category:
          type: string
          enum: [network, anonymity, reputation, threat, identity, quality]
          description: |
            Which axis the observation belongs to. A closed set, and never a provider name.
          examples: [identity]
        severity:
          type: string
          enum: [info, low, medium, high, critical]
          description: |
            How much weight the observation deserves — **not** a recommendation about what to do with
            it, and not a fraud probability. `info` marks the identity and data-quality entries, which
            are not risk findings at all.

            Severity answers "how significant is this observation", which is related to but not the
            same as "how many points did it move the Index". Where the two differ this reports the
            first: a Tor relay contributes almost nothing to the score by design, yet knowing the
            address is on the Tor network is worth `medium` to a reader.
          examples: [info]

    Location:
      type: object
      additionalProperties: false
      required: [countryCode, country, regionCode, region, city, timeZone, continentCode, continent, postalCode, latitude, longitude]
      description: |
        **Network-level IP geolocation — not GPS, and not device location.** It describes where the
        address's network is registered or routed. `city` and `region` in particular can be wrong: a
        national ISP's pool routinely geolocates to its head office rather than to a subscriber. Do not
        present it to an end user as where somebody is.

        **Every member is nullable, and a `null` means "not known".** An unknown city is `null`, never
        `"Unknown"` and never a placeholder, and it is never filled in from an ASN's registration
        country, a time zone, or a hostname. A partially-known location keeps the object and nulls only
        what is genuinely unknown; an entirely unknown one makes the whole `location` key `null`.

        **Independent of `network.profile`.** Identity and geography are different questions:
        Googlebot's identity is a crawler, and its location is still United States / California /
        Mountain View. Neither overrides the other.

        Added in schema 1.3.0 with six fields. **Schema 1.6.0 adds `continentCode`, `continent`,
        `postalCode`, `latitude` and `longitude`** as a deliberate additive revision; the original six
        keep their names, positions, types and null semantics. Currency remains internal. Regenerate a
        strictly validating client against this revision: this schema sets `additionalProperties: false`,
        so a client built from 1.5.0 rejects a response that carries the new keys.

        **Coordinates are an approximate network estimate, never a physical address.** `latitude` and
        `longitude` are the geolocation database's estimate of where the network is registered/routed —
        city-level at best, often the operator's registration address. They are JSON numbers, published
        as a pair (never one without the other), null together when unknown, and a genuine zero is
        preserved (`null` is never coerced to `0`). For anycast services (public DNS, CDN edges) no
        verifiable node location exists, so the pair is `null`. Missing values are completed only from
        unique, verifiable standard mappings (ISO 3166-2 subdivision codes, single-timezone-country IANA
        zones, UN geoscheme continents) — never guessed, and never over a source's own answer.
      properties:
        countryCode:
          type: [string, 'null']
          description: ISO 3166-1 alpha-2.
          examples: [US]
        country:
          type: [string, 'null']
          description: English country name.
          examples: [United States]
        regionCode:
          type: [string, 'null']
          description: Subdivision code as the source reports it. Open value set.
          examples: [CA]
        region:
          type: [string, 'null']
          examples: [California]
        city:
          type: [string, 'null']
          examples: [Mountain View]
        timeZone:
          type: [string, 'null']
          description: IANA time-zone name.
          examples: [America/Los_Angeles]
        continentCode:
          type: [string, 'null']
          description: Continent code (UN geoscheme convention). Added in schema 1.6.0.
          examples: [NA]
        continent:
          type: [string, 'null']
          description: English continent name. Added in schema 1.6.0.
          examples: [North America]
        postalCode:
          type: [string, 'null']
          description: Postal/ZIP code as the source reports it. Added in schema 1.6.0.
          examples: ['94043']
        latitude:
          type: [number, 'null']
          description: |
            Approximate network latitude, -90..90. Added in schema 1.6.0. Null when unknown, when the
            address is an anycast service with no verifiable node location, or when no valid pair exists.
          examples: [37.4056]
        longitude:
          type: [number, 'null']
          description: |
            Approximate network longitude, -180..180. Added in schema 1.6.0. Always null together with
            `latitude` when the pair is unknown.
          examples: [-122.0775]

    Network:
      type: object
      additionalProperties: false
      required: [type, connectionType, asn, organization, domain, range]
      properties:
        type:
          type: [string, 'null']
          description: |
            Published network classification: `residential`, `mobile`, `business_access`, `education`,
            `hosting`, `datacenter`, `public_infrastructure`, `unknown`. `public_infrastructure` outranks
            the underlying access-network label once such an identity is reliably established. `unknown`
            is a legitimate answer, not an error. Open value set.
          examples: [public_infrastructure]
        profile:
          type: string
          description: |
            What the network is for: `public_dns_resolver`, `cdn_edge`, `search_crawler`,
            `security_scanner`, `internet_measurement`, and others as official sources are onboarded.

            **The key is omitted entirely — never sent as `null` — when NetRiskScan holds no record
            covering the address.** Test for the key's presence, not for a null value. Open value set.
          examples: [public_dns_resolver]
        service:
          type: string
          description: |
            The specific service. Display text, not an identifier: it is the registered source's name and
            can be reworded, so branch on `profile` instead. A value here means the address was found in a
            range list the operator itself publishes — never that its ASN merely resembled one.

            Omitted, not null, when there is no match.
          examples: [Google Public DNS]
        connectionType:
          type: [string, 'null']
          description: |
            How the address connects: `direct`, `vpn`, `proxy`, `residential_proxy`, `tor`, `relay`,
            `unknown`. Open value set.
          examples: [direct]
        asn:
          type: [string, 'null']
          examples: [AS15169]
        organization:
          type: [string, 'null']
          description: Canonical operator of the network or ASN.
          examples: [Google LLC]
        domain:
          type: [string, 'null']
          description: |
            The trusted primary domain of the network's operating organization. Added in schema 1.6.0.

            It names the **operator**, not a website hosted on the address and not the cloud customer
            whose workload sits on it: a shared cloud ASN publishes the cloud operator's domain
            (`amazon.com` for AS16509, not a tenant's site). It is never derived from a PTR/reverse-DNS
            name, a hosted website, an abuse contact, or a guess from the organization's name.

            Normalized to a registrable domain: lower-case, punycode for internationalized names, and
            public-suffix aware (`bbc.co.uk`, never `co.uk`). `null` means no trustworthy mapping exists —
            coverage is partial by design and grows as the verified mapping catalog grows.
          examples: [google.com]
        range:
          type: [string, 'null']
          description: |
            The network range this address belongs to, as a canonical CIDR — IPv4 (`8.8.8.0/24`) or
            IPv6 (`2001:4860:4860::/48`). Added in schema 1.6.0.

            Prefer the longest fresh RIPE RIS prefix seen by at least five peers for an origin
            matching the published ASN. An ASN conflict at the longest eligible prefix, a missing
            route or an unavailable or expired snapshot falls back to the existing operator service
            range or provider coverage. An explicit start/end range must exactly equal one CIDR.

            **The published CIDR always contains the queried address.** A single-address CIDR (`/32`,
            `/128`) appears only when a source actually declared one — the queried IP is never forced
            into a host route. `null` when no source stated a usable, containing range.
          examples: [8.8.8.0/24]

    Flags:
      type: object
      additionalProperties: false
      required: [proxy, proxyType, vpn, tor, datacenter, scanner, abuse, searchCrawler, searchCrawlerName]
      description: |
        Seven independent detection facts, each **three-valued**: `true` detected, `false` checked and
        negative, `null` unknown — nothing that could answer did, or no source used this round supports the
        check.

        `null` is not `false`. Collapsing it turns an unanswered question into a finding; render the three
        states as three states.

        None of these is a projection of `network.type`: `type = public_infrastructure` implies nothing
        about `datacenter`, because a public DNS resolver is routinely public infrastructure and not a
        datacenter.

        Two of the nine keys — `proxyType` and `searchCrawlerName` — are **descriptors, not detections**.
        Each is subordinate to the boolean above it and carries its own invariant, stated on the field.
        They add granularity to answers that already existed; neither is a new question, and neither
        affects `risk.index`.

        Both were added in schema 1.2.0 and are always present, `null` included. Regenerate a strictly
        validating client against this revision: this schema sets `additionalProperties: false`, so a
        client built from 1.1.0 rejects a response that carries them.
      properties:
        proxy: { $ref: '#/components/schemas/DetectionFlag' }
        proxyType:
          type: [string, 'null']
          enum: [residential_proxy, isp_proxy, mobile_proxy, datacenter_proxy, unknown_proxy, null]
          description: |
            What kind of proxy infrastructure this is. **Non-null exactly when `proxy` is `true`.**

            `null` means the proxy itself was not confirmed (`proxy` is `false` or `null`), so there is no
            subtype to describe. That is a different statement from `unknown_proxy`, which means "this IS
            a proxy and the evidence does not say which kind" — a confirmed proxy always carries a value.

            - `residential_proxy` — explicit residential-proxy subtype evidence.
            - `isp_proxy` — explicit ISP-hosted / static-residential proxy evidence. Never inferred from
              an ISP ASN: ordinary consumer broadband is ISP address space too.
            - `mobile_proxy` — a confirmed proxy whose own network is reliably classified as mobile.
            - `datacenter_proxy` — explicit datacenter-proxy operator evidence, or a confirmed proxy whose
              own network is reliably classified as datacenter/hosting.
            - `unknown_proxy` — confirmed proxy, subtype not established, or two sources claimed
              incompatible subtypes.

            **Not a projection of `network.type`.** A residential address is not a residential proxy; a
            datacenter is not a datacenter proxy. The network classification is consulted only to describe
            a proxy some source already detected. A confirmed proxy on a residential network reports
            `unknown_proxy` unless a source answered the subtype question directly.

            Unlike `searchCrawlerName` this is a closed enum: the taxonomy is small and stable.
          examples: [residential_proxy]
        vpn: { $ref: '#/components/schemas/DetectionFlag' }
        tor: { $ref: '#/components/schemas/DetectionFlag' }
        datacenter: { $ref: '#/components/schemas/DetectionFlag' }
        scanner:
          allOf: [{ $ref: '#/components/schemas/DetectionFlag' }]
          description: |
            Internet-scanning, crawling, or bot behaviour actually observed. An address correctly
            identified as an official crawler is not `true` by that fact alone — identity is
            `network.profile`, this is behaviour.
        abuse:
          allOf: [{ $ref: '#/components/schemas/DetectionFlag' }]
          description: Standing abuse reputation — abuse history or blacklist presence.
        searchCrawler:
          allOf: [{ $ref: '#/components/schemas/DetectionFlag' }]
          description: |
            Whether this address is verified **search-engine crawler** infrastructure.

            **Identity, not behaviour, and not a whitelist.** `true` says only that the address is in a
            search engine's own published crawler ranges. It never clears or softens anything beside it: a
            crawler address that is also a confirmed proxy, scanner or abuse source publishes all of those
            unchanged, and `risk.index` is unaffected by this field.

            **What produces `true`.** Only a match against a range list the crawler's operator itself
            publishes, or a human-verified first-party registry row. An ASN does not: Google Public DNS,
            Google Cloud and Googlebot share AS15169. A reverse-DNS name does not either — no hostname is
            read on this path at all, so a forged `*.googlebot.com` PTR cannot reach this field. Nor does
            `scanner`, or any provider's crawler/bot flag: those are observed behaviour, and SEO scrapers,
            monitoring agents and security scanners all set them.

            **The operator's whole fleet counts.** Google publishes Googlebot, its ads-quality fetchers
            (AdsBot, Mediapartners) and its user-triggered fetchers as separate range lists for one search
            operator's crawling infrastructure, and all of them are `true` here. Which fetcher a range
            belongs to is `network.service`'s question, not this field's.

            **Narrower than "crawler".** AI training and assistant-retrieval crawlers (GPTBot,
            ChatGPT-User, ClaudeBot) and SEO/analytics crawlers (AhrefsBot, SemrushBot) are `false` here —
            declared, well-behaved crawler infrastructure operated by someone who is not a search engine.
            They stay visible as `network.profile` / `network.service`.

            `false` means the published crawler catalogues were consulted and this address is in none of
            them as a search operator's crawler. `null` means the question could not be asked: this
            deployment's crawler catalogue was empty, or the address is special-purpose and has no public
            identity.
          examples: [true]
        searchCrawlerName:
          type: [string, 'null']
          description: |
            The canonical search **operator**, when `searchCrawler` is `true`: `Google`, `Bing`, `Apple`,
            `DuckDuckGo`, `Baidu`, `Yandex`, `Petal Search`, `Seznam`, `Sogou`, `OpenAI`.

            **The operator, not the fetcher.** A range match establishes who announces the address and
            nothing more, so an address in Google's `special-crawlers.json` publishes `Google` — calling it
            `Googlebot` would assert a User-Agent the address itself cannot evidence. Which fetcher the
            range belongs to is published beside it, unchanged, as `network.service`
            (`Googlebot`, `Applebot`, `Google 特殊爬虫 (AdsBot / Mediapartners 等)`).

            **Non-null exactly when `searchCrawler` is `true`**; both other states publish `null`. Where
            the registry confirms search-crawler infrastructure but holds no canonical operator for it the
            value is `Other`, so the invariant has no exception to code around.

            **Deliberately an open string, not an enum.** New search engines will be onboarded without a
            new API version, and a closed union would break the moment one is. Model it as a plain string
            and render an unrecognised value rather than rejecting it.

            NetRiskScan's canonical name, never a source's raw text and never a legal entity: every
            spelling of a given operator's fetchers collapses onto one published name, and `Google LLC`
            belongs to `network.organization`.
          examples: [Google]

    TorRelay:
      type: object
      additionalProperties: false
      required: [isRelay, isExit, isBadExit, role]
      description: |
        What the Tor Project relay consensus says about this address.

        This block exists because `flags.tor` is one boolean documented as "detected as a Tor **exit**
        node", and it has to keep meaning exactly that. A Tor Middle or Guard relay is a real Tor node with
        no exit capability whatsoever — it cannot originate traffic toward the destination internet — and a
        consumer that needs to tell those apart cannot do so from the boolean alone.
      properties:
        isRelay:
          type: boolean
          description: Participates in the Tor network — Middle, Guard or Exit. Always `true` when this block is present.
        isExit:
          type: boolean
          description: |
            A confirmed exit: the consensus grants the Exit role **and** the Exit Policy for this address
            family permits at least one destination port. This is the same fact as `flags.tor`.
        isBadExit:
          type: boolean
          description: |
            The directory authorities flagged this relay `BadExit`. Independent of `isExit` — a BadExit is
            still an exit, just one the Tor network distrusts.
        role:
          type: string
          enum: [middle, guard, exit]

    DetectionFlag:
      type: [boolean, 'null']
      description: '`true` detected, `false` checked and negative, `null` unknown or unsupported.'

    UsageResponse:
      type: object
      additionalProperties: false
      required: [plan, period, units, rateLimit]
      properties:
        plan:
          type: string
          description: Plan code currently in effect.
          examples: [growth]
        period:
          type: object
          additionalProperties: false
          required: [start, end]
          description: |
            The current quota period — one month, for every plan — as a half-open interval
            `[start, end)`. This is not the subscription's billing period: on an annual subscription the
            billing period is a year, while quota periods still roll monthly. `end` is when usage resets.
          properties:
            start: { type: string, format: date-time }
            end: { type: string, format: date-time }
        units:
          type: object
          additionalProperties: false
          required: [used, limit, remaining]
          properties:
            used: { type: integer, format: int64 }
            limit: { type: integer, format: int64 }
            remaining: { type: integer, format: int64 }
        rateLimit:
          type: object
          additionalProperties: false
          required: [requestsPerMinute]
          properties:
            requestsPerMinute: { type: integer }

    ErrorResponse:
      type: object
      required: [error]
      description: The single error envelope. Every `/v1` failure uses it, so one parser covers them all.
      properties:
        error:
          type: object
          required: [code, message, requestId]
          properties:
            code:
              type: string
              description: |
                `invalid_ip`, `invalid_request`, `unsupported_parameter`, `api_key_required`, `invalid_api_key`,
                `api_key_disabled`, `scope_not_allowed`, `plan_not_allowed`, `batch_size_exceeded`,
                `idempotency_conflict`, `batch_in_progress`, `payload_too_large`, `not_found`, `method_not_allowed`, `feature_not_available`,
                `rate_limit_exceeded`, `monthly_quota_exceeded`,
                `temporarily_unavailable`. Open value set — surface an unrecognised code as-is.
            message: { type: string }
            requestId:
              type: string
              pattern: '^req_[A-Za-z0-9_-]{8,56}$'
            action:
              type: object
              required: [type, title, description, url, provider]
              properties:
                type: { type: string, const: google_sign_in }
                title: { type: string }
                description: { type: string }
                url: { type: string, format: uri }
                provider: { type: string, const: google }
            onboarding:
              description: Shown for a missing API key. Email verification applies to verified Google identities.
              type: object
              required: [manualRegistrationRequired, additionalEmailVerificationRequired, automaticApiKeyForNewUsers]
              properties:
                manualRegistrationRequired: { type: boolean, const: false }
                additionalEmailVerificationRequired: { type: boolean, const: false }
                automaticApiKeyForNewUsers: { type: boolean, const: true }
            freePlan:
              type: object
              required: [name, monthlyQuota, quotaUnit, batchSupported]
              properties:
                name: { type: string, example: Free }
                monthlyQuota: { type: integer, format: int64, example: 5000 }
                quotaUnit: { type: string, const: query_units }
                batchSupported: { type: boolean, example: false }
            authentication:
              type: object
              required: [type, header, example]
              properties:
                type: { type: string, const: Bearer }
                header: { type: string, const: Authorization }
                example: { type: string, example: 'Authorization: Bearer YOUR_API_KEY' }
            quickStart:
              type: object
              required: [cli]
              properties:
                cli: { type: string, example: 'npx netriskscan-cli@latest check 8.8.8.8' }
                curl: { type: string, example: 'curl https://api.netriskscan.com/v1/ip-risk/8.8.8.8 -H "Authorization: Bearer YOUR_API_KEY"' }
            links:
              type: object
              required: [website]
              properties:
                getApiKey: { type: string, format: uri }
                manageApiKeys: { type: string, format: uri }
                website: { type: string, format: uri }

  responses:
    CliSlowDown:
      description: slow_down. The gateway can also return rate_limit_exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds before retrying.
    BadRequest:
      description: |
        Invalid IP (`invalid_ip`), an unsupported query parameter (`invalid_request`), or a cache-refresh
        parameter (`unsupported_parameter`). `/v1` accepts no query string at all.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    Unauthorized:
      description: |
        Missing key (`api_key_required`), or invalid or revoked key (`invalid_api_key`).
        Both include Google onboarding, Free plan information and quick-start instructions in the JSON error.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        WWW-Authenticate:
          schema: { type: string, example: 'Bearer realm="NetRiskScan"' }
          description: Includes error="invalid_token" for an invalid or revoked credential.
        X-NetRiskScan-Developer-Url:
          schema: { type: string, format: uri, example: 'https://www.netriskscan.com/developer/keys?source=api_401' }
        X-NetRiskScan-Free-Quota:
          schema: { type: integer, format: int64, example: 5000 }
        X-NetRiskScan-Auth-Provider:
          schema: { type: string, const: google }
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorResponse' }
          example:
            error:
              code: api_key_required
              message: 'An API key is required. Sign in with Google to automatically get your first API key when you sign up. Start with 5,000 free queries every month. Get started: https://www.netriskscan.com/developer/keys?source=api_401'
              requestId: req_example401
              action:
                type: google_sign_in
                title: Sign in with Google
                description: Automatically create your developer account and get your API key when you sign up.
                url: https://www.netriskscan.com/developer/keys?source=api_401
                provider: google
              onboarding: { manualRegistrationRequired: false, additionalEmailVerificationRequired: false, automaticApiKeyForNewUsers: true }
              freePlan: { name: Free, monthlyQuota: 5000, quotaUnit: query_units, batchSupported: false }
              authentication: { type: Bearer, header: Authorization, example: 'Authorization: Bearer YOUR_API_KEY' }
              quickStart:
                cli: npx netriskscan-cli@latest check 8.8.8.8
                curl: 'curl https://api.netriskscan.com/v1/ip-risk/8.8.8.8 -H "Authorization: Bearer YOUR_API_KEY"'
              links: { getApiKey: 'https://www.netriskscan.com/developer/keys?source=api_401', website: 'https://www.netriskscan.com' }
    Forbidden:
      description: |
        Disabled or expired credential (`api_key_disabled`), or a missing scope
        (`scope_not_allowed`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        X-NetRiskScan-Key-Expired:
          description: Present when the credential is rejected because its timestamp has expired.
          schema: { type: string, const: 'true' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchBadRequest:
      description: |
        Invalid JSON, request structure or idempotency key (`invalid_request`), input count over the plan's
        limit (`batch_size_exceeded`), or any URL query parameter (`unsupported_parameter`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchForbidden:
      description: |
        Disabled credential or inactive account (`api_key_disabled`), missing required scope
        (`scope_not_allowed`), or current plan excludes batch queries (`plan_not_allowed`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        X-NetRiskScan-Key-Expired:
          description: Present when the credential is rejected because its timestamp has expired.
          schema: { type: string, const: 'true' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchConflict:
      description: |
        Key already used with different input (`idempotency_conflict`), or the original batch is still
        running (`batch_in_progress`). For an in-progress batch retry the original request with the same key.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        Retry-After:
          description: Seconds to wait for an in-progress batch before retrying.
          schema: { type: integer }
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorResponse' }
          examples:
            conflictingInput:
              value:
                error:
                  code: idempotency_conflict
                  message: This Idempotency-Key is already bound to different IP entries.
                  requestId: req_d61458501f
            inProgress:
              value:
                error:
                  code: batch_in_progress
                  message: The original batch is still processing.
                  requestId: req_8f3ab21c9d
    NotFound:
      description: |
        No such path (`not_found`), or a capability that is not open yet (`feature_not_available`, e.g.
        `POST /v1/ip-risk/query`). A batch CORS preflight also returns 404.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    MethodNotAllowed:
      description: |
        The path exists but does not accept this method (`method_not_allowed`). `Allow` lists the supported
        method for the route. The batch path accepts POST.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        Allow:
          description: The methods this path accepts.
          schema: { type: string, example: GET }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    PayloadTooLarge:
      description: Request body over the edge limit (`invalid_request`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchPayloadTooLarge:
      description: Batch request body over 16 KiB (`payload_too_large`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchTooManyRequests:
      description: |
        Request rate, processing rate or concurrency limit exceeded (`rate_limit_exceeded`), or insufficient
        monthly quota to reserve one unit for each valid distinct address (`monthly_quota_exceeded`).
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        X-RateLimit-Limit: { $ref: '#/components/headers/XRateLimitLimit' }
        X-RateLimit-Remaining: { $ref: '#/components/headers/XRateLimitRemaining' }
        X-RateLimit-Reset: { $ref: '#/components/headers/XRateLimitReset' }
        Retry-After:
          description: Seconds to wait before retrying, when available.
          schema: { type: integer }
        X-Quota-Limit:
          $ref: '#/components/headers/XQuotaLimit'
        X-Quota-Used:
          $ref: '#/components/headers/XQuotaUsed'
        X-Quota-Remaining:
          $ref: '#/components/headers/XQuotaRemaining'
        X-Quota-Reset:
          schema:
            type: integer
            format: int64
          description: Unix seconds for the end of the current monthly budget.
        X-Quota-Status:
          schema:
            enum:
            - normal
            - warning
            - critical
            - exhausted
          description: Warning starts at 80%, critical at 95% and exhausted at 100%.
        X-Quota-Usage-Percent:
          schema:
            type: number
            minimum: 0
            maximum: 100
          description: Monthly usage percentage.
        X-Upgrade-Url:
          schema:
            type: string
            format: uri
          description: Official plan and upgrade page.
        X-Developer-Plan:
          schema:
            type: string
          description: Effective plan code.
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    BatchUnavailable:
      description: Temporarily unavailable (`temporarily_unavailable`). Retry with the original key and inputs.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        Retry-After:
          description: Seconds to wait before retrying, when available.
          schema: { type: integer }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    TooManyRequests:
      description: |
        Rate, concurrency, or monthly quota-period allowance exceeded (`rate_limit_exceeded` / `monthly_quota_exceeded`).
      headers:
        Retry-After:
          description: |
            Seconds to wait before retrying. For `monthly_quota_exceeded` this is the time until the current
            monthly quota period ends — never the end of an annual billing period.
          schema: { type: integer }
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
        X-RateLimit-Limit: { $ref: '#/components/headers/XRateLimitLimit' }
        X-RateLimit-Remaining: { $ref: '#/components/headers/XRateLimitRemaining' }
        X-RateLimit-Reset: { $ref: '#/components/headers/XRateLimitReset' }
        X-Quota-Limit:
          $ref: '#/components/headers/XQuotaLimit'
        X-Quota-Used:
          $ref: '#/components/headers/XQuotaUsed'
        X-Quota-Remaining:
          $ref: '#/components/headers/XQuotaRemaining'
        X-Quota-Reset:
          schema:
            type: integer
            format: int64
          description: Unix seconds for the end of the current monthly budget.
        X-Quota-Status:
          schema:
            enum:
            - normal
            - warning
            - critical
            - exhausted
          description: Warning starts at 80%, critical at 95% and exhausted at 100%.
        X-Quota-Usage-Percent:
          schema:
            type: number
            minimum: 0
            maximum: 100
          description: Monthly usage percentage.
        X-Upgrade-Url:
          schema:
            type: string
            format: uri
          description: Official plan and upgrade page.
        X-Developer-Plan:
          schema:
            type: string
          description: Effective plan code.
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
    Unavailable:
      description: Temporarily unavailable (`temporarily_unavailable`) — retry with backoff.
      headers:
        X-Request-Id: { $ref: '#/components/headers/XRequestId' }
      content: { application/json: { schema: { $ref: '#/components/schemas/ErrorResponse' } } }
