# Create a Category Rule

> Solarium docs, Category Rules. All requests are `POST https://api.trysolarium.com/graphql/` with `Authorization: Bearer <api key>` and a JSON body `{"query": ..., "variables": ...}`. Every query and mutation takes an `organizationId` (find it with `myOrganizations`). Index of all pages: https://trysolarium.com/llms.txt

Create an auto-categorization rule. The vendorPattern is matched case-insensitively against merchant names. Use SQL ILIKE patterns (% for wildcard).

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organizationId` | `UUID!` | Yes | Organization ID |
| `vendorPattern` | `String!` | Yes | ILIKE pattern to match vendor names (e.g. "%SHOPIFY%", "%CANADA POST%") |
| `categoryId` | `UUID!` | Yes | Account ID to auto-assign when pattern matches |

### Request

```graphql
mutation {
  createCategoryRule(
    organizationId: "a1b2c3d4-..."
    vendorPattern: "%PETRO-CANADA%"
    categoryId: "vehicle-expense-uuid"
  ) {
    categoryRule {
      id
      vendorPattern
      account { id name }
    }
    success
    error
  }
}
```

### Response

```json
{
  "data": {
    "createCategoryRule": {
      "categoryRule": {
        "id": "r9a8b7c6-...",
        "vendorPattern": "%PETRO-CANADA%",
        "account": {
          "id": "vehicle-expense-uuid",
          "name": "Vehicle Expenses"
        }
      },
      "success": true,
      "error": null
    }
  }
}
```
