Ask before replying or posting on X
postkey_x_check_before_sendPostkey: Checks one proposed X action before it happens: a reply to a DM, a reply to a post that mentioned the account, or a new post. It checks exactly that text against this profile's STOP list, opt-outs, quiet hours, limits and saved replies. For a reply, pass kind, text, event_id (the id of the DM or of the post that mentioned the account) and contact_id (the sender's numeric X user id, not their @handle); without both ids the answer is deny with code missing_inbound. Example: {"kind":"dm_reply","text":"","event_id":"1846...","contact_id":"88213...","first_in_conversation":true}. The text is expected to be one of the customer's saved replies (postkey_x_list_templates). Postkey keeps only a hash of the text. The answer is allow (with a short-lived grant_id), wait (with retry_at when known), deny (with the reason), or needs_approval (a person must say yes in Postkey first); deny and wait are answers, not errors. When the month's included X actions are used, the answer is deny with code x_free_limit_reached (or wait with code free_daily_limit for the day). A usage_note field may carry the numbers: pass it on as it is. An allow covers exactly that text, and postkey_x_record_action records what happened. Sends nothing to X and no X send tool exists: act with the customer's own X access (full scope: postkey_x_status).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | Yes | dm_reply: answer a DM the person sent first. mention_reply: answer a post that mentioned or quoted the account. post: a new post. | |
| text | Yes | The exact text you plan to send, 1 to 4000 characters. Postkey hashes it and does not keep it. | |
| event_id | No | REQUIRED for dm_reply and mention_reply: the id of the inbound DM event, or of the post that mentioned or quoted the account. One reply per id, ever. | |
| contact_id | No | REQUIRED for dm_reply and mention_reply: the sender's numeric X user id (not the @handle). Postkey keeps only a hash. | |
| is_own_post | No | true if the post you would answer was written by the account itself. Replies to your own posts are refused. Default false. | |
| inbound_text | No | Optional: the message you are answering, only so Postkey can look for opt-out words such as STOP. It is checked in this request and dropped. | |
| first_in_conversation | No | dm_reply only. Default true. Set false only if the person has already written back; no links are allowed in a first message. | |
| inbound_looks_like_opt_out | No | Optional: true if you already found that the inbound message asks to stop (STOP, UNSUBSCRIBE, stop messaging me). The person goes on the STOP list. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | false: refused (isError; code, message, guide_topic, url); no change. | |
| code | No | wait or deny: why, for example missing_inbound, x_free_limit_reached, free_daily_limit. | |
| message | No | The answer in a sentence. | |
| decision | No | allow, wait, deny or needs_approval. | |
| grant_id | No | allow: pass it to postkey_x_record_action. | |
| retry_at | No | Some waits: when to ask again (none for a pause or a check in progress). | |
| warnings | No | allow: notes, for example too few saved replies. | |
| expires_at | No | allow: when the grant runs out. | |
| request_id | No | needs_approval: the request a person answers in Postkey. | |
| usage_note | No | Near the month's X allowance: pass on as it is. |