# Create rule (https://docs.capy.ai/api-reference/reviewfilters/create-rule)

`POST https://api.capy.ai/api/v1/review-filters/rules`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string \| null | yes |  |
| `conditions` | ReviewFilterCondition[] | yes |  |
| `repositoryCondition` | ReviewFilterRepositoryCondition \| null | no |  |

## Responses

- `200` ReviewFilterRule: `ReviewFilterRuleEncoded`
- `400` capy/InvalidRequest: `capy_InvalidRequestEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`

## Example

```bash
curl -X POST "https://api.capy.ai/api/v1/review-filters/rules" \
  -H "Authorization: Bearer $CAPY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"repo":"<repo>","conditions":[]}'
```

## Referenced schemas

```json
{
  "ReviewFilterRuleEncoded": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "allOf": [
          {
            "minLength": 32
          },
          {
            "maxLength": 32
          }
        ],
        "pattern": "^rfilt_"
      },
      "repo": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "githubRepoId": {
        "anyOf": [
          {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "enum": [
                  "Infinity",
                  "-Infinity",
                  "NaN"
                ]
              }
            ]
          },
          {
            "type": "null"
          }
        ]
      },
      "conditions": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/ReviewFilterCondition"
        }
      },
      "repositoryCondition": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/ReviewFilterRepositoryCondition"
          },
          {
            "type": "null"
          }
        ]
      },
      "skipped": {
        "type": "boolean",
        "description": "True when a value exceeds the wildcard limit or a repository is unavailable, so admission skips the rule until it is edited"
      },
      "source": {
        "type": "string",
        "enum": [
          "hand",
          "greptile"
        ]
      },
      "createdByUserId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "createdByName": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "createdAt": {
        "type": "string"
      },
      "updatedAt": {
        "type": "string"
      }
    },
    "required": [
      "id",
      "repo",
      "githubRepoId",
      "conditions",
      "skipped",
      "source",
      "createdByUserId",
      "createdByName",
      "createdAt",
      "updatedAt"
    ],
    "additionalProperties": false
  },
  "ReviewFilterCondition": {
    "type": "object",
    "properties": {
      "field": {
        "type": "string",
        "enum": [
          "label",
          "base_branch",
          "title_or_body",
          "author"
        ]
      },
      "not": {
        "type": "boolean"
      },
      "values": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "field",
      "not",
      "values"
    ],
    "additionalProperties": false
  },
  "ReviewFilterRepositoryCondition": {
    "type": "object",
    "properties": {
      "not": {
        "type": "boolean"
      },
      "repoIds": {
        "type": "array",
        "items": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string",
              "enum": [
                "Infinity",
                "-Infinity",
                "NaN"
              ]
            }
          ]
        }
      }
    },
    "required": [
      "not",
      "repoIds"
    ],
    "additionalProperties": false
  },
  "capy_InvalidRequestEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/InvalidRequest"
        ]
      },
      "message": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "message"
    ],
    "additionalProperties": false
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      },
      "mfaRequiredOrgId": {
        "type": "string"
      },
      "ssoRequired": {
        "type": "boolean"
      },
      "passkeyRequired": {
        "type": "boolean"
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  },
  "CreateReviewFilterRuleRequest": {
    "type": "object",
    "properties": {
      "repo": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "conditions": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/ReviewFilterCondition"
        }
      },
      "repositoryCondition": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/ReviewFilterRepositoryCondition"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": [
      "repo",
      "conditions"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json