---
title: "Create an automation rule at the end of the run order"
method: POST
path: "/workspaces/{workspaceId}/agents/{agentId}/support/rules"
tags: ["Agents"]
---

# Create an automation rule at the end of the run order

`POST /workspaces/{workspaceId}/agents/{agentId}/support/rules`

## Request

- Base URL: `https://app.communicate.so/api/v1`
- URL: `https://app.communicate.so/api/v1/workspaces/{workspaceId}/agents/{agentId}/support/rules`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Secure-better-auth.session_token`
  - API key in cookie `better-auth.session_token`

Use an explicitly scoped user-bound account bearer credential or an application session. Scope grants are intersected with live membership, role, tenant isolation, agent access and plan limits; a credential does not grant an owner role. Invitation acceptance requires the verified recipient email.

## Path parameters

- `workspaceId` string, required
- `agentId` string, required

## Request body

- CreateAgentRuleRequest
  - `name` string, required
  - `trigger` 'conversation_created' | 'message_received', required
  - `conditions` object, required
    - `keywords` string[]
    - `channels` string[]
  - `actions` object, required
    - `labelIds` string[]
    - `teamId` string, nullable
    - `priority` 'low' | 'normal' | 'high' | 'urgent', nullable
    - `close` boolean
  - `enabled` boolean

## Response `201`

Create an automation rule at the end of the run order

- CreateAgentRuleResponse
  - `id` string, required
  - `workspaceId` string, required
  - `agentId` string, required
  - `name` string, required
  - `trigger` 'conversation_created' | 'message_received', required
  - `conditions` object, required
    - `keywords` string[], required
    - `channels` string[], required
  - `actions` object, required
    - `labelIds` string[], required
    - `teamId` string, nullable, required
    - `priority` 'low' | 'normal' | 'high' | 'urgent', nullable, required
    - `close` boolean, required
  - `enabled` boolean, required
  - `position` integer, required
  - `createdAt` string, date-time, required
  - `updatedAt` string, date-time, required
  - `firesThisWeek` 0, required

## Other responses

- `400`: Invalid request, timezone, resource association or confirmation.
- `401`: Missing, invalid, expired or revoked account credential or application session.
- `402`: Plan entitlement, capacity or credits do not allow this operation.
- `403`: Required account scope, live verified identity, membership or role permission is missing.
- `404`: Workspace or addressed resource is not visible to this member.
- `409`: Support handle, source URL or pending transfer conflicts with this operation.
- `422`: Website URL or extraction source is not supported.
- `429`: Agent request or website crawl rate limit exceeded.
- `500`: Unexpected server failure.
- `503`: Authorization service temporarily unavailable.

---

[API](https://skmtc.dev/communicate/apis/communicate-public-rest-api-2.md) · [All operations](https://skmtc.dev/communicate/apis/communicate-public-rest-api-2/llms.txt) · [OpenAPI document](https://skmtc.dev/communicate/apis/communicate-public-rest-api-2/revisions/db6be3d36733?raw)
