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

# Create Routing Rule

> Cria uma nova regra de roteamento para direcionar mensagens a bots específicos com base em condições.



## OpenAPI

````yaml openapi-v2 POST /router/create/{instance}
openapi: 3.0.3
info:
  title: ZapThinker API
  version: 2.1.1
servers:
  - url: https://api.zapthinker.com
security: []
paths:
  /router/create/{instance}:
    post:
      tags:
        - Router Controller
      summary: Create a routing rule
      description: >-
        Cria uma nova regra de roteamento para direcionar mensagens a bots
        específicos com base em condições.
      operationId: createRouterRule
      parameters:
        - name: instance
          in: path
          required: true
          description: Nome da instância
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Nome da regra
                description:
                  type: string
                enabled:
                  type: boolean
                  default: true
                priority:
                  type: integer
                  minimum: 0
                  maximum: 1000
                  description: Prioridade (maior = avaliada primeiro)
                conditions:
                  type: object
                  description: Condições de roteamento
                  properties:
                    textMatch:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - contains
                            - equals
                            - startsWith
                            - endsWith
                            - regex
                        value:
                          type: string
                        caseInsensitive:
                          type: boolean
                    timeRange:
                      type: object
                      properties:
                        start:
                          type: string
                          description: HH:mm
                        end:
                          type: string
                          description: HH:mm
                        timezone:
                          type: string
                    daysOfWeek:
                      type: object
                      properties:
                        days:
                          type: array
                          items:
                            type: integer
                            minimum: 0
                            maximum: 6
                          description: 0=Dom, 1=Seg, ..., 6=Sáb
                    jidType:
                      type: string
                      enum:
                        - contact
                        - group
                        - all
                    fromMe:
                      type: boolean
                    triggerOverride:
                      type: boolean
                    specificJids:
                      type: array
                      items:
                        type: string
                    excludeJids:
                      type: array
                      items:
                        type: string
                targetBotId:
                  type: string
                  description: ID do bot alvo
                fallbackChain:
                  type: array
                  items:
                    type: string
                  description: Chain de fallback de integrações
              required:
                - name
                - conditions
      responses:
        '201':
          description: Regra criada com sucesso
          content:
            application/json:
              schema:
                type: object
        '400':
          description: Dados inválidos
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: apikey
      description: Your authorization key header

````