Skip to main content
PATCH
/
organization
/
rules
/
{id}
Update a ruleset
curl --request PATCH \
  --url https://api.getfernand.com/organization/rules/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "name": "Updated rule name",
  "trigger": "messages.response",
  "trigger_data": "3 hours",
  "filters": [
    {
      "field": "message.content",
      "operator": "contains",
      "value": "urgent"
    }
  ],
  "actions": [
    {
      "name": "conversation.tag",
      "data": {
        "tag": "urgent"
      }
    }
  ],
  "status": "PAUSED",
  "stop": true,
  "priority": 1
}
'
{
  "id": 123,
  "name": "Auto-close spam conversations",
  "status": "LIVE",
  "priority": 0,
  "stop": false,
  "trigger_name": "messages.incoming",
  "created": "2025-01-21T10:30:00Z",
  "applied_count": 42,
  "description": "Automatically closes conversations marked as spam",
  "trigger_data": "2 hours",
  "filters": [
    {
      "field": "conversation.status",
      "operator": "equals",
      "value": "OPENED"
    }
  ],
  "actions": [
    {
      "name": "conversation.close",
      "data": {}
    }
  ],
  "last_applied_at": "2025-01-21T15:45:30Z"
}
Updates one or more properties of an existing ruleset. All fields are optional - only provided fields will be updated. When updating priority, the system automatically reorders other rules to maintain consistent priority ordering. Validates that any updated trigger, filters, or actions are properly configured and compatible with each other.

Authorizations

X-API-Key
string
header
required

Authenticate your account by including your secret key in API requests. You can manage your API keys in the Dashboard.

Authentication to the API is performed by using the HTTP Header X-API-Key.

Path Parameters

id
integer
required

ID of the ruleset to update.

Body

application/json
name
string

Name of the ruleset (optional).

Maximum string length: 250
Example:

"Updated rule name"

trigger
string

Event that triggers this rule (optional). Must be one of: messages.new_conversation, messages.incoming, messages.response, messages.delivery_failure, messages.spam, messages.note, status.closed, status.opened, status.snoozed, status.unsnoozed, teammates.assigned, teammate.mentioned, time.unanswered_by_client, time.unanswered_by_team, tickets.ticket_done

Maximum string length: 50
Example:

"messages.response"

trigger_data
string

Additional data for the trigger (optional):

  • For "teammates.assigned" or "teammate.mentioned": "no_one", "anyone", or an Agent ID
  • For "time.*" triggers: duration and period in format "{duration} {period}" (e.g., "2 hours", "3 days")
Example:

"3 hours"

filters
object[]

Array of filter conditions (optional).

Example:
[
{
"field": "message.content",
"operator": "contains",
"value": "urgent"
}
]
actions
object[]

Array of actions to execute when rule matches (optional).

Example:
[
{
"name": "conversation.tag",
"data": { "tag": "urgent" }
}
]
status
enum<string>

Status of the ruleset (optional).

Available options:
PAUSED,
LIVE
Example:

"PAUSED"

stop
boolean

If true, stops processing subsequent rules when this rule matches (optional).

Example:

true

priority
integer

Priority order for rule execution (optional). Other rules are automatically reordered.

Example:

1

Response

Ruleset updated successfully.

id
integer<int32>
required

Unique identifier for the ruleset

name
string
required

Name of the ruleset

Maximum string length: 250
Example:

"Auto-close spam conversations"

status
enum<string>
required

Current status of the ruleset

Available options:
PAUSED,
LIVE
Example:

"LIVE"

priority
integer<int16>
required

Priority order for rule execution (lower numbers execute first)

Example:

0

stop
boolean
required

If true, stops processing subsequent rules when this rule matches

Example:

false

trigger_name
string
required

Event that triggers this rule. Accepted triggers:

  • messages.new_conversation
  • messages.incoming
  • messages.response
  • messages.delivery_failure
  • messages.spam
  • messages.note
  • status.closed
  • status.opened
  • status.snoozed
  • status.unsnoozed
  • teammates.assigned
  • teammate.mentioned
  • time.unanswered_by_client
  • time.unanswered_by_team
  • tickets.ticket_done
Maximum string length: 50
Example:

"messages.incoming"

created
string<date-time>
required

Timestamp when the ruleset was created (UTC)

Example:

"2025-01-21T10:30:00Z"

applied_count
integer<int32>
required

Number of times this rule has been successfully applied

Example:

42

description
string | null

Optional description of what the ruleset does

Maximum string length: 500
Example:

"Automatically closes conversations marked as spam"

trigger_data
string | null

Additional data for the trigger (required for certain triggers):

  • For "teammates.assigned" or "teammate.mentioned": "no_one", "anyone", or an Agent ID
  • For "time.*" triggers: duration and period in format "{duration} {period}" (e.g., "2 hours", "3 days")
Maximum string length: 250
Example:

"2 hours"

filters
object[] | null

Array of filter conditions that must be met for the rule to execute. Each filter contains conditions to match against the entity.

Example:
[
{
"field": "conversation.status",
"operator": "equals",
"value": "OPENED"
}
]
actions
object[]

Array of actions to execute when the rule matches. Each action has a name and optional data.

Example:
[
{ "name": "conversation.close", "data": {} }
]
last_applied_at
string<date-time> | null

Timestamp when the rule was last applied (UTC)

Example:

"2025-01-21T15:45:30Z"