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

# Update extraction rules

> Replaces built-in field extraction rules (Contact-only) and updates extraction rules on existing custom-field properties within DynamicProperties for the given section type. Validates regex patterns and rejects unknown custom field keys.



## OpenAPI

````yaml /api-reference/openapi.yaml put /api/organizations/{organizationId}/extraction-rules
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/organizations/{organizationId}/extraction-rules:
    put:
      tags:
        - Organizations
      summary: Update extraction rules
      description: >-
        Replaces built-in field extraction rules (Contact-only) and updates
        extraction rules on existing custom-field properties within
        DynamicProperties for the given section type. Validates regex patterns
        and rejects unknown custom field keys.
      operationId: put_organizations_organizationId_extraction_rules
      parameters:
        - in: path
          name: organizationId
          required: true
          schema:
            type: string
        - in: query
          name: type
          required: false
          schema:
            type: string
            default: Contact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateExtractionRulesRequest'
      responses:
        '200':
          description: Extraction rules updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractionRulesUpdateResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationErrorResponse'
        '404':
          description: Organization not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateExtractionRulesRequest:
      type: object
      properties:
        builtInFields:
          type: object
          description: >-
            Only allowed when type=Contact. Keys must be one of the built-in
            extraction field names; pass an empty / null rule to clear.
          additionalProperties:
            nullable: true
            allOf:
              - $ref: '#/components/schemas/ExtractionRule'
        customFields:
          type: object
          description: >-
            Custom field keys (must exist in DynamicProperties for the given
            type).
          additionalProperties:
            nullable: true
            allOf:
              - $ref: '#/components/schemas/ExtractionRule'
      additionalProperties: true
      example:
        builtInFields:
          province:
            mode: allowlist
            values:
              - 'ON'
              - QC
              - BC
              - AB
            regex: []
        customFields:
          creditScore: null
    ExtractionRulesUpdateResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        data:
          type: object
          properties:
            builtInFields:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/ExtractionRule'
            customFields:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/ExtractionRule'
          additionalProperties: true
      additionalProperties: true
      example:
        success: true
        message: Extraction rules updated
        data:
          builtInFields:
            province:
              mode: allowlist
              values:
                - 'ON'
                - QC
              regex: []
          customFields: {}
    OrganizationErrorResponse:
      type: object
      properties:
        error:
          type: string
        details:
          type: string
      additionalProperties: true
      example:
        error: Organization not found
        details: No organization exists with the provided id
    ExtractionRule:
      type: object
      properties:
        mode:
          type: string
          enum:
            - allowlist
            - blacklist
        values:
          type: array
          items:
            type: string
        regex:
          type: array
          items:
            type: string
        prompt:
          type: string
          maxLength: 500
      required:
        - mode
        - values
        - regex
      additionalProperties: true
      example:
        mode: allowlist
        values:
          - 'ON'
          - QC
          - BC
          - AB
        regex:
          - ^[A-Z]{2}$
        prompt: Two-letter Canadian province code
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````