跳转到主要内容
PATCH
curl
Didit 的更新消息同意 API 为某个收件人的某一渠道记录一次选择加入或选择退出。 此后,向该渠道上已选择退出的收件人发送的消息会被拒绝,返回 opted_out,且不收费。 每次发送只读取其所属渠道的记录。 to 为 E.164 格式的号码(由 + 和 ASCII 数字组成)、电子邮件地址或 WhatsApp 企业范围的用户 ID,channel 必须与之匹配:参见查询同意记录中的收件人类型。 source 记录该选择的来源,省略时为 api。 当 status 不是 opted_in 或 opted_out 时,调用返回 400 和 invalid_status;当 to 不属于上述三种收件人类型之一(包括 person@ 这类格式错误的邮箱),或 channel 与之不匹配时,返回 invalid_channel;当无法写入记录时,返回 consent_unavailable,请稍后重试。 带范围限制的 API 密钥需要具有消息的写入权限。

授权

x-api-key
string
header
必填

Your application's API key, from Developers -> API keys in the Business Console. The primary key has full access. A named key can be scoped: none, read or write per resource, limited to some workflows or to approved sessions, to a list of IP addresses, and to an expiry date. 401 means the key is wrong, revoked or expired; 403 means no key was sent, the key has no access to this resource or action, or the request came from an address outside its IP list; 404 on a session route means the session is outside the key's workflows or statuses. A key without media access receives image, video and PDF URLs as null, and a key without sessions write receives session links and tokens as null. See https://docs.didit.me/console/api-keys.

请求头

Idempotency-Key
string

Optional retry-safety key you choose for one operation, up to 255 characters (a UUID works). A request repeated with the same key, endpoint, query and body is answered with the first response, same status and same body, and runs and bills nothing a second time. The same key with another endpoint, query or body returns 409 idempotency_key_reused, and while the first request is still running, 409 idempotency_key_in_progress with Retry-After. A failed request (any 4xx or 5xx) is not stored, so you can send it again with the same key. Keys belong to your application, whether you call with an API key or an access token. See Retries and idempotency.

Required string length: 1 - 255

路径参数

to
string
必填

The recipient: an E.164 number (+ and up to 15 ASCII digits), an email address, or a WhatsApp business-scoped user id.

示例:

"+34600000012"

请求体

application/json
channel
enum<string>
必填

The channel the choice applies to.

可用选项:
sms,
whatsapp,
telegram,
rcs,
viber,
voice,
email
status
enum<string>
必填

opted_out refuses sends on this channel; opted_in allows them again.

可用选项:
opted_in,
opted_out
source
enum<string>
默认值:api

Where the choice came from, returned as you send it; api when left out. reassigned is only a label you can record: Didit does not detect a change of owner.

可用选项:
stop_reply,
start_reply,
bot_left,
api,
console,
reassigned

响应

The recipient's consent per channel, with this choice recorded.

channels
object[]
必填

The recipient's consent per channel, as the retrieve call returns it.

最后修改于 2026年11月24日