# Which rules would fire on a conversation, and what they would do

`POST /workspace/inbox/rules/preview` · Rivier · inbox

Which rules would fire on a conversation, and what they would do; a rule not yet saved can be tried. Changes nothing.

- Scope: inbox:write
- Graphql: Mutation.inboxRulePreview
- Sdk: inbox.rule.preview
- Cli: inbox rule preview

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "threadId": {
      "type": "string",
      "format": "uuid"
    },
    "rule": {
      "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"
        }
      },
      "required": [
        "name",
        "conditions",
        "actions"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "threadId"
  ],
  "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 POST 'https://api.rivier.ai/workspace/inbox/rules/preview' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "threadId": "string"
}'
```
