> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withsplendor.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a detection

> Updates a detection rule. Requires an admin role.



## OpenAPI

````yaml /api-reference/openapi.json put /v1/admin/detections/{rule_id}
openapi: 3.1.0
info:
  description: >-
    Splendor is a search and retrieval API for your operational data. Ingest

    datasets — logs, documents, and structured records — and query them through
    one

    consistent interface that spans full-text, SQL, and semantic (vector)
    search.


    Every request authenticates with a bearer token and selects a workspace with
    the

    `X-Splendor-Tenant-Id` header. Read and query operations are available to
    any

    member; operations that create, change, or delete data require an admin
    role.


    All search modes return one shared envelope, and every result carries
    provenance

    back to the exact source object it came from.
  title: Splendor API
  version: 1.0.0
servers:
  - description: Production
    url: https://api.withsplendor.com
security:
  - bearerAuth: []
tags:
  - description: Resolve the authenticated user and the tenants they can access.
    name: Identity
  - description: >-
      Build on Splendor as a platform: authenticate with a platform API key to
      provision an isolated tenant per end-customer and manage your platform
      keys.
    name: Platform
  - description: >-
      List datasets, inspect inferred schemas and readiness, and manage dataset
      lifecycle including deletion and schema rebuilds.
    name: Datasets & schema
  - description: >-
      Run full-text, SQL, and semantic search over your datasets, stream
      results, and resolve object media.
    name: Search & query
  - description: Save queries and materialize result sets for repeatable analysis.
    name: Views
  - description: >-
      Define named, versioned, parameterized SQL queries and manage their
      versions.
    name: Query Endpoints
  - description: Create and manage asynchronous exports of search results.
    name: Exports
  - description: >-
      Configure data sources, upload data through hosted multipart uploads,
      stream logs, and track ingest runs.
    name: Sources & ingest
  - description: >-
      Connect third-party systems by managing connector instances in the
      selected tenant.
    name: Connectors
  - description: Define and test detection rules that run against incoming data.
    name: Detections
  - description: Inspect discovered fields and promote them to fast, aggregatable fields.
    name: Fields
  - description: >-
      Operational visibility and recovery: audit logs, usage, dead-letter queue,
      reindex jobs, and data-deletion jobs.
    name: Operations
paths:
  /v1/admin/detections/{rule_id}:
    put:
      tags:
        - Detections
      summary: Update a detection
      description: Updates a detection rule. Requires an admin role.
      operationId: updateDetection
      parameters:
        - in: path
          name: rule_id
          required: true
          schema:
            title: Rule Id
            type: integer
        - $ref: '#/components/parameters/SplendorTenantId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DetectionRuleUpdateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectionRuleItem'
          description: Successful Response
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          description: The requested resource was not found.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  parameters:
    SplendorTenantId:
      description: Selects the tenant (workspace) the request acts within.
      in: header
      name: x-splendor-tenant-id
      required: true
      schema:
        type: string
  schemas:
    DetectionRuleUpdateRequest:
      properties:
        code:
          anyOf:
            - maxLength: 100000
              type: string
            - type: 'null'
          title: Code
        condition_type:
          anyOf:
            - enum:
                - count_gt
                - count_lt
                - avg_gt
                - avg_lt
                - p95_gt
              type: string
            - type: 'null'
          title: Condition Type
        description:
          default: ''
          title: Description
          type: string
        enabled:
          default: true
          title: Enabled
          type: boolean
        kind:
          default: threshold
          enum:
            - threshold
            - code
          title: Kind
          type: string
        name:
          maxLength: 255
          minLength: 1
          title: Name
          type: string
        query:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Query
        schedule_cron:
          minLength: 1
          title: Schedule Cron
          type: string
        threshold:
          anyOf:
            - type: number
            - type: 'null'
          title: Threshold
        webhook_url:
          maxLength: 2048
          minLength: 1
          title: Webhook Url
          type: string
      required:
        - name
        - schedule_cron
        - webhook_url
      title: DetectionRuleUpdateRequest
      type: object
    DetectionRuleItem:
      example:
        code: null
        condition_type: count_gt
        consecutive_triggers: 0
        created_at: '2026-01-15T09:30:00Z'
        description: Alerts when error volume spikes.
        enabled: true
        kind: threshold
        last_run_at: '2026-01-15T09:30:00Z'
        last_triggered_at: null
        name: High error rate
        query:
          text: error
        rule_id: 3
        schedule_cron: '*/5 * * * *'
        tenant_id: acme
        threshold: 100
        updated_at: '2026-01-15T09:30:00Z'
        webhook_url: https://hooks.example.com/splendor
      properties:
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
        condition_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Condition Type
        consecutive_triggers:
          title: Consecutive Triggers
          type: integer
        created_at:
          format: date-time
          title: Created At
          type: string
        description:
          title: Description
          type: string
        enabled:
          title: Enabled
          type: boolean
        kind:
          enum:
            - threshold
            - code
          title: Kind
          type: string
        last_run_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Run At
        last_triggered_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Triggered At
        name:
          title: Name
          type: string
        query:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Query
        rule_id:
          title: Rule Id
          type: integer
        schedule_cron:
          title: Schedule Cron
          type: string
        tenant_id:
          title: Tenant Id
          type: string
        threshold:
          anyOf:
            - type: number
            - type: 'null'
          title: Threshold
        updated_at:
          format: date-time
          title: Updated At
          type: string
        webhook_url:
          title: Webhook Url
          type: string
      required:
        - rule_id
        - tenant_id
        - name
        - description
        - kind
        - query
        - condition_type
        - threshold
        - code
        - schedule_cron
        - webhook_url
        - enabled
        - last_run_at
        - last_triggered_at
        - consecutive_triggers
        - created_at
        - updated_at
      title: DetectionRuleItem
      type: object
    ApiError:
      description: >-
        Error envelope returned by every Splendor API endpoint.


        ``detail`` is either a plain message string (most errors) or a
        structured

        ``{code, message}`` object (validation and capacity errors that carry a
        stable

        machine-readable code).
      examples:
        - detail: Dataset not found
        - detail:
            code: semantic_search_capacity_exhausted
            message: Semantic search capacity is temporarily exhausted; retry shortly.
      properties:
        detail:
          anyOf:
            - type: string
            - $ref: '#/components/schemas/ErrorBody'
          title: Detail
      required:
        - detail
      title: ApiError
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ErrorBody:
      description: Structured error detail returned by validation and capacity errors.
      examples:
        - code: semantic_query_text_required
          message: Semantic vector search requires non-empty text.
      properties:
        code:
          title: Code
          type: string
        message:
          title: Message
          type: string
      required:
        - code
        - message
      title: ErrorBody
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  responses:
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
      description: The bearer token is missing, malformed, or expired.
    Forbidden:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
      description: The token lacks access to the tenant or the role required.
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      description: API token issued from the Splendor console.
      scheme: bearer
      type: http

````