CommentKeyword API Reference

Endpoint-level reference for Personal Access Token (PAT) integrations.

OpenAPI specification

Use the OpenAPI 3.1 JSON document with API clients, code generators, testing tools, or AI integrations.

View OpenAPI JSON

Authentication

All requests require:

Authorization: Bearer YOUR_TOKEN

Tokens are workspace-scoped and do not expire automatically.

Base URL

https://commentkeyword.com/api

Permissions

  • keywords:read
  • keywords:write
  • keywords:delete
  • agents:read (optional; keywords:read can also read agents)
  • conversations:read (list AI agent conversations and read their collected data and transcripts; see Webhooks)

Public IDs

PAT responses expose public IDs (UUID-like strings) for keywords and agents. Use these IDs in API paths and payloads.

{
  "id": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2",
  "aiAgentId": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17"
}

Keyword scopes and message limits

  • global matches comments on any post.
  • post_specific matches only assigned posts - listed in mediaIds, added later via a PATCH, and/or caught while includeNextPost is enabled.
  • includeNextPost (post_specific only) turns waiting on or off. It automatically becomes false after the next publication is found; enable it again whenever you want to catch another future post.
  • Changing a keyword to global removes all assigned posts (manual and auto-added) and stops waiting for the next post.
  • Keyword triggers are normalized before saving: leading and trailing spaces are removed, repeated spaces are collapsed to one, and the text is Unicode NFC-normalized. Only the space character is affected; tabs and line breaks are kept. The result is limited to 100 Unicode characters.
  • Comment replies may render to at most 500 characters. The limit applies only while publicReplyEnabled is true.
  • Each DM plus an assigned agent's conversation hook may render to at most 1,000 characters. The hook is added after a blank line (2 characters) unless the DM already contains it.
  • Placeholders count at their maximum rendered size: {{handle}} 31 characters, {{name}} and {{namefirst}} 64 characters each.

Response format

Single-object responses (GET, POST and PATCH on a keyword), GET /api/agents and GET /api/account wrap the result in data with a meta object:

{
  "data": { ... },
  "meta": { "authType": "pat", "workspaceId": 42 }
}

GET /api/keywords adds pagination:

{
  "data": [ ... ],
  "pagination": { "total": 7, "limit": 20, "offset": 0, "hasMore": false },
  "meta": { "authType": "pat", "workspaceId": 42 }
}

POST /api/keywords also returns meta.trackFirstKeywordCreated and meta.trackFirstAutomationActivated; PATCH returns meta.trackFirstAutomationActivated.

Keyword object

Every keyword response includes all of these fields.

{
  "id": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2",
  "publicId": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2",
  "keyword": "pricing",
  "matchMode": "contains",
  "matchWithoutAccents": false,
  "scope": "post_specific",
  "includeNextPost": false,
  "nextPostStatus": "attached",
  "nextPostArmedAt": "2026-03-07T12:00:00.000Z",
  "nextPostMediaId": "17900000000000002",
  "nextPostClaimedAt": "2026-03-08T09:15:00.000Z",
  "nextPostLastAttemptAt": "2026-03-08T09:15:00.000Z",
  "nextPostLastError": null,
  "nextPostRevision": 2,
  "mediaIds": ["17900000000000001", "17900000000000002"],
  "autoAddedMediaIds": ["17900000000000002"],
  "commentReplies": ["Sent it to you, {{namefirst}}!"],
  "publicReplyEnabled": true,
  "dmMessages": ["Hey {{namefirst}}, here are the pricing details."],
  "trackLinks": false,
  "delaySec": 30,
  "aiAgentId": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17",
  "aiAgent": {
    "id": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17",
    "publicId": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17",
    "name": "Sales Agent",
    "status": "live",
    "isActive": true
  },
  "isActive": true,
  "createdAt": "2026-03-07T12:00:00.000Z",
  "updatedAt": "2026-03-08T09:15:00.000Z"
}
  • aiAgent and aiAgentId are null when no agent is assigned.
  • autoAddedMediaIds is the subset of mediaIds caught while includeNextPost was enabled.
  • nextPostStatus: null (never started, or stopped), waiting, attached (a post was caught, see nextPostMediaId), disabled (the keyword is inactive), reconnect_required (Instagram is disconnected or its token expired), or failed (see nextPostLastError).
  • nextPostRevision increases whenever the wait is started, stopped or cleared, and when the keyword is activated or paused while waiting.

GET /api/account

Required permission: keywords:read or agents:read.

Returns the Instagram account connected to the token's workspace, for example to show its handle and avatar in a video's call to action.profilePictureUrl is an Instagram CDN link that expires after a few days: download the image when you need it rather than storing the URL.

{
  "data": {
    "instagram": {
      "connected": true,
      "username": "youraccount",
      "profilePictureUrl": "https://scontent.cdninstagram.com/..."
    }
  },
  "meta": { "authType": "pat", "workspaceId": 42 }
}

When no Instagram account is connected, connected is false and the other two fields are null.

curl -H "Authorization: Bearer YOUR_TOKEN" https://commentkeyword.com/api/account

GET /api/agents

Required permission: agents:read or keywords:read.

Parameters

FieldTypeRequiredAccepted ValuesNotes
(none)-No-No path, query, or body parameters.
curl -H "Authorization: Bearer YOUR_TOKEN" https://commentkeyword.com/api/agents

Webhooks

CommentKeyword sends a POST with a JSON body to your URL each time an AI agent collects data in a conversation, and when it completes the objective. Data reaches you as it is collected, even if the contact never finishes the conversation.

Where to set it up

  • Settings → Webhooks: the workspace webhook. Every agent without a webhook of its own sends there.
  • An agent's page → Data delivery: a URL just for that agent, used instead of the workspace webhook.
  • Each destination has an optional authorization token and chooses which events it receives. The URL must be public HTTPS on port 443.

Events

FieldTypeRequiredAccepted ValuesNotes
ai_conversation_data_capturedevent--The agent collected a new or corrected value for one of its fields. capturedFields lists which ones.
ai_conversation_completedevent--The agent marked the objective as met. Sent once per conversation, with everything collected.

Request headers

FieldTypeRequiredAccepted ValuesNotes
Content-TypestringYesapplication/json-
X-Event-IdstringYes-Unique per event and the same on every retry. Store it to skip duplicates.
AuthorizationstringOnly with a tokenBearer YOUR_TOKENSent when the destination has a token. Compare it with yours to know the request is from CommentKeyword.

Payload

{
  "event": "ai_conversation_data_captured",
  "timestamp": "2026-03-01T10:29:05.000Z",
  "data": {
    "conversationId": "8b0c2d1e-5f6a-4b7c-9d8e-1f2a3b4c5d6e",
    "instagramUsername": "user123",
    "instagramUserId": "17841400000000000",
    "workspaceId": 1,
    "agent": { "id": "f3a1c9e0-7b2d-4e5f-8a9b-0c1d2e3f4a5b", "name": "Lead Qualifier" },
    "agentId": 12,
    "keywordId": 3,
    "objective": "Get the email and phone number",
    "completed": false,
    "capturedFields": ["email"],
    "collectedData": { "email": "[email protected]", "phone": null }
  }
}
  • collectedData always has every field the agent collects, in the agent's order, with null for the ones not collected yet. Each agent keeps its own fields, so use agent.id to tell them apart.
  • ai_conversation_completed has the same shape with completed: true and no capturedFields.
  • agent.id is the agent's public ID, as in GET /api/agents. agentId and keywordId are internal numeric IDs kept for older integrations.
  • To read the whole conversation, call GET /api/conversations/{conversationId} with a token that has conversations:read.

Delivery and retries

Answer with any 2xx status within 10 seconds. Other statuses, timeouts and connection errors are retried with growing waits (2, 4, 8 and 16 seconds), up to 5 attempts in total. An event that could not start on time, for example during a restart or an outage on our side, is sent once we recover, usually within minutes but later after a long outage, and keeps its X-Event-Id and its original timestamp. Events can arrive more than once, late or out of order, so rely on X-Event-Id and timestamp.

A token is only sent to the site it was saved for: if you move the URL to another domain, the saved token is removed unless you enter a new one.

Deleting an agent deletes its own webhook and token: its events not sent yet are not sent. Events going to the workspace webhook are still sent, with the agent as it was when the event happened.

GET /api/conversations

Required permission: conversations:read.

Lists DM conversations handled by AI agents, newest first, with the data each agent collected and no transcript. Each item has the same fields as GET /api/conversations/{id} without messages.

Query parameters

FieldTypeRequiredAccepted ValuesNotes
stagestringNoany (default), data_collected, completedany: every AI conversation, by last message. data_collected: the agent collected at least one value, by when it got the first (data collected before November 2026 has no such time, so those conversations appear only under any and completed). completed: the objective was reached, by when.
agentIdstring (UUID)NoAgent publicIdOnly this agent.
fromstringNoYYYY-MM-DD (UTC)Default: 30 days before to. Filters the time the stage uses.
tostringNoYYYY-MM-DD (UTC)Default: today. At most 366 days after from.
limitintegerNo1 to 100Default 25.
offsetintegerNo0 or moreUse it with pagination.hasMore to read the next page.
curl -H "Authorization: Bearer YOUR_TOKEN" "https://commentkeyword.com/api/conversations?stage=data_collected&from=2026-03-01"

GET /api/conversations/{id}

Required permission: conversations:read.

Returns one DM conversation: the contact, the agent and keyword behind it, every field the agent collects (null until collected) and the transcript, oldest message first. The id is the conversationId sent in webhook events. Up to the latest 1,000 messages are returned; messagesTruncated is true when older ones were left out. If the agent was deleted, the conversation is still returned, with agent: null and only the values collected.

Parameters

FieldTypeRequiredAccepted ValuesNotes
idstring (UUID)YesPath parameterThe conversationId from a webhook event.
{
  "data": {
    "id": "8b0c2d1e-5f6a-4b7c-9d8e-1f2a3b4c5d6e",
    "instagramUsername": "user123",
    "instagramUserId": "17841400000000000",
    "status": "ai_active",
    "completed": false,
    "dataCapturedAt": "2026-03-01T10:29:05.000Z",
    "objectiveReachedAt": null,
    "handedOffAt": null,
    "agent": { "id": "f3a1c9e0-7b2d-4e5f-8a9b-0c1d2e3f4a5b", "name": "Lead Qualifier" },
    "keyword": { "id": "2c9d1e7a-3b4f-4a5c-8d6e-7f8091a2b3c4", "keyword": "GUIDE" },
    "collectedData": { "email": "[email protected]", "phone": null },
    "createdAt": "2026-03-01T10:20:00.000Z",
    "lastMessageAt": "2026-03-01T10:30:00.000Z",
    "messages": [
      { "sender": "business", "origin": "automation", "text": "Here is your guide!", "attachments": [], "sentAt": "2026-03-01T10:20:00.000Z" },
      { "sender": "contact", "origin": null, "text": "Thanks! It's [email protected]", "attachments": [], "sentAt": "2026-03-01T10:29:00.000Z" }
    ],
    "messagesTruncated": false
  },
  "meta": { "authType": "pat", "workspaceId": 1 }
}
curl -H "Authorization: Bearer YOUR_TOKEN" https://commentkeyword.com/api/conversations/CONVERSATION_ID

GET /api/keywords

Required permission: keywords:read.

Results are newest first (by createdAt).

Query Parameters

FieldTypeRequiredAccepted ValuesNotes
searchstringNoany textCase-insensitive search in the keyword text. % and _ match literally.
statusstringNoactive | inactiveFilters by keyword activation state.
limitintegerNo>= 1Default 50. Must be a whole number; values above 100 are clamped to 100, invalid values return 400.
offsetintegerNo>= 0Default 0. Must be a whole number; invalid values return 400.
curl -H "Authorization: Bearer YOUR_TOKEN" "https://commentkeyword.com/api/keywords?status=active&limit=20&offset=0"

POST /api/keywords

Required permission: keywords:write.

commentReplies and dmMessages support personalization placeholders:{{handle}}, {{name}}, and {{namefirst}}.

Keywords are created active unless you send isActive: false. Active keywords count toward the plan's active-keyword limit: when it is reached, creating an active keyword fails with 409 and code: "keyword_limit_exceeded", while a paused one can still be created. Returns 201 with the Keyword object.

Request Body

FieldTypeRequiredAccepted ValuesNotes
keywordstringYesnon-emptyLeading/trailing spaces removed, repeated spaces collapsed, Unicode NFC. Maximum 100 Unicode characters after normalization.
matchModestringNocontains | exactDefault contains.
matchWithoutAccentsbooleanNotrue | falsetrue is accepted only for keywords with Latin accents (400 otherwise). When true, “guía” also matches “guia”. Default false.
scopestringNoglobal | post_specificDefault global. post_specific matches only assigned posts - see mediaIds and includeNextPost.
commentRepliesstring[]Noarray of stringsDefault []. Variants are trimmed and empty ones removed. Rendered limit: 500 characters per variant, checked only while publicReplyEnabled is true.
publicReplyEnabledbooleanNotrue | falseDefault: true when commentReplies has a variant. false sends only the DM. true requires at least one commentReplies variant.
dmMessagesstring[]Yesarray of stringsVariants are trimmed and empty ones removed; at least one must remain. Rendered DM plus agent conversation hook limit: 1,000 characters.
trackLinksbooleanNotrue | falseDefault false. Replaces eligible DM links with tracked links.
delaySecintegerNo1..60Deprecated. Accepted for compatibility and stored (default 30), but currently ignored: DMs are sent as soon as the comment is processed.
isActivebooleanNotrue | falseDefault true. false creates the keyword paused; a paused keyword does not count toward the active-keyword limit.
aiAgentIdstring | nullNoagent public ID UUID string or nullIf set, must refer to a Live agent in the same workspace.
mediaIdsstring[]Conditionalarray of non-empty stringsRequired when scope is post_specific, unless includeNextPost is true. Ignored for global scope. Values are trimmed and deduplicated.
mediaUrlsobjectNomedia ID → Instagram URLOptional permalink map for selected media IDs. Entries whose URL host is not instagram.com (or a subdomain) are ignored.
includeNextPostbooleanNotrue | falseDefault false. post_specific only (true with another scope returns 400). Waits for the next publication, adds it to mediaIds, then automatically becomes false.
curl -X POST https://commentkeyword.com/api/keywords \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "keyword": "pricing",
    "matchMode": "contains",
    "scope": "global",
    "commentReplies": ["Sent it to you, {{namefirst}}!"],
    "dmMessages": ["Hey {{namefirst}}, here are the pricing details."],
    "trackLinks": true,
    "aiAgentId": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17"
  }'

GET /api/keywords/{id}

Required permission: keywords:read.

Path Parameters

FieldTypeRequiredAccepted ValuesNotes
idstringYeskeyword public ID UUID stringUse keyword public ID.
curl -H "Authorization: Bearer YOUR_TOKEN" https://commentkeyword.com/api/keywords/5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2

PATCH /api/keywords/{id}

Required permission: keywords:write.

Partial update: only provided fields are changed. There are no defaults; omitted fields keep their current values. Returns the updated Keyword object.

Message fields can include {{handle}}, {{name}}, and {{namefirst}}.

Path Parameters

FieldTypeRequiredAccepted ValuesNotes
idstringYeskeyword public ID UUID string-

Request Body

FieldTypeRequiredAccepted ValuesNotes
keywordstringNonon-emptyLeading/trailing spaces removed, repeated spaces collapsed, Unicode NFC. Maximum 100 Unicode characters after normalization.
matchModestringNocontains | exact-
matchWithoutAccentsbooleanNotrue | falsetrue is accepted only when the keyword has Latin accents. Resets to false automatically when the keyword is changed to one without Latin accents.
scopestringNoglobal | post_specificChanging to global removes all assigned posts (manual and auto-added) and stops waiting for the next post.
commentRepliesstring[]Noarray of stringsReplaces all variants. Trimmed; empty variants are removed. Rendered limit: 500 characters, checked only while publicReplyEnabled is true.
publicReplyEnabledbooleanNotrue | falsefalse sends only the DM and keeps commentReplies. true requires at least one commentReplies variant. If omitted while commentReplies is replaced, it follows whether a variant remains; otherwise the current value is kept.
dmMessagesstring[]Noarray of stringsReplaces all variants. Trimmed; empty variants are removed and at least one must remain. Combined DM and agent hook limit: 1,000 characters.
trackLinksbooleanNotrue | falseEnables or disables tracked links in DM variants.
delaySecintegerNo1..60Deprecated. Accepted for compatibility and stored, but currently ignored: DMs are sent as soon as the comment is processed.
isActivebooleanNotrue | falseActivates or pauses the keyword. Activating counts toward the plan’s active-keyword limit (409 keyword_limit_exceeded when full).
aiAgentIdstring | nullNoagent public ID UUID string or nullIf set, must refer to a Live agent in the same workspace.
mediaIdsstring[]Conditionalarray of non-empty stringsWhen provided, replaces the whole set of assigned posts, including auto-added ones. Required only when changing a global keyword to post_specific, unless includeNextPost is true. Existing post-specific keywords may use an empty list to become dormant. Ignored when the resulting scope is global.
mediaUrlsobjectNomedia ID → Instagram URLOptional permalink map, applied only together with mediaIds. Entries whose URL host is not instagram.com (or a subdomain) are ignored.
includeNextPostbooleanNotrue | falsepost_specific only (true with a global scope returns 400). true starts waiting; false stops a pending wait without removing assigned posts; omission preserves the current setting. Automatically false after a post is found.
curl -X PATCH https://commentkeyword.com/api/keywords/5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"isActive": false}'

DELETE /api/keywords/{id}

Required permission: keywords:delete.

If the keyword is linked to an AI agent, the first request returns 409 DELETE_CONFIRMATION_REQUIREDwith an impact summary. Review it, then repeat the request with ?confirm=true.

Path Parameters

FieldTypeRequiredAccepted ValuesNotes
idstringYeskeyword public ID UUID string-

Query Parameters

FieldTypeRequiredAccepted ValuesNotes
confirmstringConditionaltrueSend confirm=true after receiving DELETE_CONFIRMATION_REQUIRED. Only the exact lowercase value true confirms; 1 or True do not.

Success response (200)

{
  "message": "Keyword deleted successfully",
  "data": {
    "id": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2",
    "publicId": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2"
  },
  "meta": { "authType": "pat", "workspaceId": 42 }
}

Confirmation required (409)

Like every other response, the id values inside details are public IDs.

{
  "error": "Conflict",
  "code": "DELETE_CONFIRMATION_REQUIRED",
  "message": "Keyword \"pricing\" is linked to existing automation records. Confirm deletion to continue.",
  "details": {
    "keyword": { "id": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2", "publicId": "5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2", "text": "pricing" },
    "aiAgents": [
      { "id": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17", "publicId": "a6be1900-8f4f-4ae6-8f4e-48f8b28f0f17", "name": "Sales Agent", "isActive": true }
    ],
    "dmJobs": { "total": 40, "pending": 2, "sent": 36, "failed": 1, "cancelled": 1, "other": 0 },
    "usageLogsCount": 40,
    "conversationsCount": 18,
    "deleteEffects": {
      "pendingDmJobsWillBeCancelled": true,
      "dmJobKeywordReferencesWillBeDetached": true
    }
  }
}
curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" https://commentkeyword.com/api/keywords/5f9619c5-daa7-4f2f-ad6f-971f71f8d7f2

Error Format

{
  "error": "Bad Request",
  "message": "dmMessages must contain at least one non-empty DM message variant"
}

Every error has error and message. Some errors add a machine-readable code, and DELETE_CONFIRMATION_REQUIRED also adds details. Match on code rather than on message text.

409 Conflict cases

  • code: "keyword_limit_exceeded" (POST /api/keywords, or PATCH with isActive: true on a paused keyword): the plan's active-keyword limit has been reached. Pause or delete an active keyword to make room.
  • code: "DELETE_CONFIRMATION_REQUIRED" (DELETE /api/keywords/{id}): the keyword is linked to an AI agent. Review details, then repeat with ?confirm=true.
  • Overlapping trigger, no code (POST /api/keywords, PATCH /api/keywords/{id}): the trigger matches another keyword's trigger, ignoring case, and ignoring accents when either keyword has matchWithoutAccents on. A global keyword conflicts with any overlapping keyword; two post_specific keywords conflict only when they share a post.
  • Related records, no code (DELETE /api/keywords/{id}): other records still reference the keyword, so it could not be deleted safely.
{
  "error": "Conflict",
  "code": "keyword_limit_exceeded",
  "message": "Keyword limit reached. Your current plan allows 3 active keywords. Deactivate a keyword to make room."
}
{
  "error": "Conflict",
  "message": "This keyword already exists or overlaps an accent variant. Only one automation can be configured for the same trigger."
}

Common status codes: 200, 201, 400, 401, 403, 404, 409, 500.