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

# Create rule

> Create a rule: a standing instruction injected into a QA.tech agent's context. Agent rules support filters to target specific applications, labels, scenarios or URL paths.



## OpenAPI

````yaml /api-reference/api.json post /v1/rules
openapi: 3.0.0
info:
  title: QA.tech API
  version: 1.0.0
  contact:
    name: QA.tech
    url: https://qa.tech
    email: support@qa.tech
  description: API for triggering and managing AI-powered test runs
servers:
  - url: https://api.qa.tech
    description: Production
    variables: {}
security:
  - BearerAuth: []
tags:
  - name: Runs
  - name: Infrastructure
  - name: Test Cases
  - name: Application Builds
  - name: Status badge
  - name: Remote Tunnels
  - name: Chat
  - name: Applications
  - name: Features
  - name: Metrics
  - name: Release Checks
  - name: Projects
  - name: Knowledge
  - name: Rules
paths:
  /v1/rules:
    post:
      tags:
        - Rules
      summary: Create rule
      description: >-
        Create a rule: a standing instruction injected into a QA.tech agent's
        context. Agent rules support filters to target specific applications,
        labels, scenarios or URL paths.
      operationId: CreateRule
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRuleRequest'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateRuleResponse'
components:
  schemas:
    CreateRuleRequest:
      type: object
      required:
        - consumer
        - title
        - content
      properties:
        consumer:
          $ref: '#/components/schemas/RuleConsumer'
        title:
          type: string
          minLength: 1
          maxLength: 200
        content:
          type: string
          minLength: 1
          maxLength: 10000
        applicationShortId:
          allOf:
            - $ref: '#/components/schemas/ApplicationShortId'
          description: >-
            Only apply the rule to tests running against this application (agent
            rules only)
        labelFilter:
          type: string
          description: >-
            Only apply the rule to test cases carrying this label (agent rules
            only)
        scenarioShortIds:
          type: array
          items:
            $ref: '#/components/schemas/ScenarioShortId'
          description: >-
            Only apply the rule to test cases in these scenarios (agent rules
            only)
        urlPathFilter:
          type: string
          description: >-
            Only apply the rule to tests whose start URL path contains this
            substring (agent rules only)
        sortOrder:
          type: integer
          format: int32
          description: Rules are applied in ascending sort order
        projectShortId:
          allOf:
            - $ref: '#/components/schemas/ProjectShortId'
          description: >-
            Target a specific project by its prefixed short ID
            (proj-slug_shortId or proj_shortId), as returned by the projects
            API. Required for organization-scoped API keys; project-scoped keys
            may only pass their own project's short ID.
    CreateRuleResponse:
      type: object
      required:
        - success
        - rule
      properties:
        success:
          type: boolean
        rule:
          $ref: '#/components/schemas/ProjectRule'
    RuleConsumer:
      type: string
      enum:
        - chat
        - agent
        - pr_review
      description: >-
        Which QA.tech agent the rule applies to: `chat` steers the AI chat
        assistant, `agent` steers the test agent during runs, `pr_review` steers
        PR review checks.
    ApplicationShortId:
      type: string
      pattern: ^app(-.+_.+|_.+)$
    ScenarioShortId:
      type: string
      pattern: ^scenario(-.+_.+|_.+)$
    ProjectShortId:
      type: string
      pattern: ^proj(-.+_.+|_.+)$
    ProjectRule:
      type: object
      required:
        - id
        - consumer
        - title
        - content
        - applicationShortId
        - labelFilter
        - scenarioShortIds
        - urlPathFilter
        - sortOrder
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        consumer:
          $ref: '#/components/schemas/RuleConsumer'
        title:
          type: string
        content:
          type: string
        applicationShortId:
          type: string
          allOf:
            - $ref: '#/components/schemas/ApplicationShortId'
          nullable: true
          description: >-
            When set, the rule only applies to tests running against this
            application
        labelFilter:
          type: string
          nullable: true
          description: When set, the rule only applies to test cases carrying this label
        scenarioShortIds:
          type: array
          items:
            $ref: '#/components/schemas/ScenarioShortId'
          nullable: true
          description: When set, the rule only applies to test cases in these scenarios
        urlPathFilter:
          type: string
          nullable: true
          description: >-
            When set, the rule only applies to tests whose start URL path
            contains this substring
        sortOrder:
          type: integer
          format: int32
          description: Rules are applied in ascending sort order
        createdAt:
          type: string
        updatedAt:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: Bearer

````