---
title: "Create a Comment to DM rule"
method: POST
path: "/v1/comment-dm-rules"
---

# Create a Comment to DM rule

`POST /v1/comment-dm-rules`

## Request

- Base URL: `https://api.breakreach.com`
- URL: `https://api.breakreach.com/v1/comment-dm-rules`
- Auth: HTTP bearer

Starts watching the comments of the account (Breakreach subscribes it to Instagram's comment webhooks, or the Page's feed webhooks). Requires a Pro, Agency or Developer plan on the workspace.

## Headers

- `Idempotency-Key` string

## Request body

- CommentDmRuleInput
  - `accountId` string: Instagram account or Facebook Page id from /v1/accounts (create only, a rule can't change account)
  - `mediaId` string, nullable: Instagram or Facebook post id to watch (from /v1/comment-dm-rules/media or the postId of /v1/comments). Omit or null for every post
  - `postId` string: Instead of mediaId: a Breakreach post id published on this account
  - `keywords` string[]: Words or phrases that trigger the DM, case and accents ignored. Empty = every comment
  - `match` 'contains' | 'exact': contains = the keyword appears as a whole word or phrase; exact = the comment is just the keyword (punctuation and emoji around it ignored)
  - `dmText` string: The DM sent to the commenter, links allowed. {username} becomes their @handle on Instagram, their first name on Facebook. Required on create
  - `publicReplies` string[]: Optional public replies under the comment once the DM is sent, one picked at random. {username} becomes their @handle on Instagram, their first name on Facebook
  - `active` boolean
  - `workspace` string

## Response `200`

Created

- object
  - `rule` CommentDmRule, required
    - `id` string, required
    - `accountId` string, required
    - `platform` 'instagram' | 'facebook', required
    - `account` object
      - `displayName` string
      - `avatarUrl` string, nullable
    - `mediaId` string, nullable, required: The Instagram or Facebook post the rule watches; null = every post of the account
    - `media` object, nullable, required
      - `caption` string
      - `thumbnailUrl` string, nullable
      - `permalink` string, nullable
      - `timestamp` string, date-time, nullable
    - `keywords` string[], required: Empty = every comment triggers the rule
    - `match` 'contains' | 'exact', required
    - `dmText` string, required
    - `publicReplies` string[], required
    - `active` boolean, required
    - `stats` object, required
      - `triggered` integer
      - `sent` integer
      - `failed` integer
    - `lastTriggeredAt` string, date-time, nullable, required
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required

## Other responses

- `400`: Invalid field, not an Instagram account or a Facebook Page, or the post isn't on this account
- `401`: Missing, invalid or expired API key
- `402`: No active Breakreach subscription or trial
- `403`: Not a member of the requested workspace
- `404`: Account, post or workspace not found
- `409`: A request with this Idempotency-Key is still running: retry after Retry-After seconds to get its response
- `422`: This Idempotency-Key was already used with a different request in the last 24 hours
- `502`: Instagram refused to read the account or to send its comments

---

[API](https://skmtc.dev/breakreach/apis/breakreach-api.md) · [All operations](https://skmtc.dev/breakreach/apis/breakreach-api/llms.txt) · [OpenAPI document](https://skmtc.dev/breakreach/apis/breakreach-api/revisions/290d285f8d73?raw)
