Check whether an address may be contacted
POST /v1/consent/check
| Property | Value |
|---|---|
| Operation | check_consent |
| Group | Consent |
| Scope | contacts:read |
| Route class | read |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Not audited: A read of a consent state that changes nothing and answers no content (ADR 0012). |
| Released in | 1.61.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Answers the consent check admission and the send path run (1.61.0) for an address in the body: allowed unless an Organization-scope opt-out or an opt-out of the sender named applies. Writes nothing; the purpose marketing is capability_not_available.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the contacts:read scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/consent/check" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "channel": "voice", "address": "<address>" }'const response = await fetch(`${process.env.VOCAL_API}/v1/consent/check`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"channel": "voice",
"address": "<address>"
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/consent/check",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"channel": "voice",
"address": "<address>",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: ConsentCheckRequest.
| Field | Type | Required | Description |
|---|---|---|---|
address | ConsentAddress | yes | |
channel | one of "voice", "sms", "whatsapp", "email", "app_push" | yes | An address channel. |
purpose | ConsentPurpose | no | all when omitted, which an opt-out of any purpose refuses. |
sender | ConsentSenderInput | no | The sender to check as well: the caller ID number of a Call, or the Connection of a message. Organization scope only when omitted. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | ConsentCheck | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden |
422 | application/json | ErrorEnvelope | capability_not_available |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is ConsentCheck.
| Field | Type | Required | Description |
|---|---|---|---|
allowed | boolean | yes | |
channel | ConsentChannel | yes | |
object | "consent_check" | yes | |
purpose | ConsentPurpose | yes | |
reason | ConsentCheckReason | yes | |
record_id | ConsentRecordId or null | yes | The record behind that state; null for no_record. |
scope | one of "organization", "sender" or null | yes | The scope of the state that decided; null for no_record. |
state | ConsentSummaryValue | yes |