# Change a rule

`PATCH /workspace/inbox/rules/{id}` · Rivier · inbox

Change a rule.

- Scope: inbox:write
- Graphql: Mutation.inboxRuleUpdate
- Sdk: inbox.rule.update
- Cli: inbox rule update

## Parameters

- `id` (path, required), string

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "enabled": {
      "type": "boolean"
    },
    "position": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1000
    },
    "scopeInbox": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "scopeMailbox": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 254
        },
        {
          "type": "null"
        }
      ]
    },
    "match": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    },
    "conditions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string",
            "enum": [
              "from",
              "from_domain",
              "to",
              "subject",
              "body",
              "mailbox",
              "has_attachment",
              "is_reply",
              "category",
              "sentiment",
              "lang",
              "label"
            ]
          },
          "op": {
            "type": "string",
            "enum": [
              "contains",
              "not_contains",
              "equals",
              "not_equals",
              "starts_with",
              "ends_with",
              "matches",
              "is_true",
              "is_false"
            ]
          },
          "value": {
            "type": "string",
            "maxLength": 200
          }
        },
        "required": [
          "field",
          "op"
        ],
        "additionalProperties": false
      },
      "maxItems": 10
    },
    "actions": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "label"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              }
            },
            "required": [
              "type",
              "label"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "assign"
              },
              "to": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              }
            },
            "required": [
              "type",
              "to"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "route_agent"
              },
              "agentId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              }
            },
            "required": [
              "type",
              "agentId"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "status"
              },
              "status": {
                "type": "string",
                "enum": [
                  "open",
                  "waiting",
                  "done"
                ]
              }
            },
            "required": [
              "type",
              "status"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "archive"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "star"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "mark_read"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "junk"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "notify"
              },
              "to": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              }
            },
            "required": [
              "type",
              "to"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "draft_from_template"
              },
              "templateId": {
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "type",
              "templateId"
            ],
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 8
    },
    "stop": {
      "type": "boolean"
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X PATCH 'https://api.rivier.ai/workspace/inbox/rules/{id}' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "enabled": false,
  "position": 0,
  "scopeInbox": "string",
  "scopeMailbox": "string",
  "match": "all",
  "conditions": [
    {
      "field": "from",
      "op": "contains"
    }
  ],
  "actions": [
    {
      "type": "label",
      "label": "string"
    }
  ]
}'
```
