API reference
Compliance / CASL
CASL consent and opt-out management.
/v1/compliance/consentsList consent records for account's subscribers
compliance:rNode.js SDKhonkio.consents.list()Requires compliance:r.
Parameters
| Parameter | Type | Description |
|---|---|---|
phone_numberquery | string | |
email_addressquery | string | Filter to the email consents for this address. Email consent is available when the email product launches. |
statusquery | string |
|
pagequery | integer |
|
limitquery | integer |
|
Responses
200A page of consent records, newest first. No total is returned.
Field Type Description data[]requiredobject[] idrequiredstring accountIdrequiredstring channelrequiredstring - One of: SMS | EMAIL
phoneNumberrequiredstring - Can be null
emailAddressrequiredstring - Can be null
consentTyperequiredstring - One of: EXPRESS | IMPLIED
statusrequiredstring - One of: ACTIVE | EXPIRED | REVOKED
sourceDescriptionrequiredstring - Can be null
sourceIprequiredstring - Can be null
sourceUrlrequiredstring - Can be null
relationshipTyperequiredstring - Can be null
expiresAtrequiredstring - Format: date-time
- Can be null
grantedAtrequiredstring - Format: date-time
revokedAtrequiredstring - Format: date-time
- Can be null
revokedReasonrequiredstring - Can be null
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 422VALIDATION_ERROR: the request failed validation; details names the fields.The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
- 501EMAIL_COMING_SOON: email consent is available when the email product launches (sent only for an email_address request).The standard error body.
Example
const { data, error } = await honkio.consents.list({ status: 'ACTIVE', limit: 50 })
if (error) throw new Error(error.message)
console.log(data.data.length)curl https://api.honkio.ca/v1/compliance/consents \
-H "Authorization: Bearer mk_live_YOUR_KEY"/v1/compliance/consentsRecord CASL consent for a phone number or email address
compliance:wNode.js SDKhonkio.consents.create()Records express or implied consent per CASL §6-10. Required before sending commercial messages.
Requires compliance:w.
Request body
| Field | Type | Description |
|---|---|---|
phone_number | string | E.164 phone number of subscriber |
email_address | string | Email address of the subscriber (email channel). Email consent is available when the email product launches.
|
consent_typerequired | string |
|
source_description | string | How/where consent was obtained (required for express)
|
source_ip | string | IP address of subscriber at time of consent
|
source_url | string | URL where consent was obtained
|
relationship_type | string | Business relationship type (required for implied; e.g. "purchase")
|
last_transaction_date | string | Date of last transaction (implied consent: expiry calculated from this)
|
expires_at | string | Explicit expiry (ISO 8601 date or date-time) for implied consent. Overrides the expiry derived from last_transaction_date. Not accepted for express consent, which never expires (CASL §10). |
Responses
201Default Response
Field Type Description statusstring phone_numberstring email_addressstring expires_atstring When this consent lapses (implied only); null for express consent.
- Can be null
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 422INVALID_PHONE_NUMBER, EMAIL_INVALID_ADDRESS, or VALIDATION_ERROR (provide exactly one of phone_number or email_address; express consent needs source_description and takes no expires_at; implied consent needs relationship_type).The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
- 501EMAIL_COMING_SOON: email consent is available when the email product launches (sent only for an email_address request).The standard error body.
Example
const { error } = await honkio.consents.create({
phoneNumber: '+1613XXXXXXX',
consentType: 'express',
sourceDescription: 'Website opt-in form',
})
if (error) throw new Error(error.message)curl -X POST https://api.honkio.ca/v1/compliance/consents \
-H "Authorization: Bearer mk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+1613XXXXXXX",
"consent_type": "express",
"source_description": "Website opt-in form"
}'/v1/compliance/consents/checkCheck if a phone number or email address has valid CASL consent
compliance:rNode.js SDKhonkio.consents.check()A consent this check finds past its expiry is marked EXPIRED as a side effect of the check itself, not only by a background job: this call can write, not just read.
Requires compliance:r.
Parameters
| Parameter | Type | Description |
|---|---|---|
phone_numberquery | string | |
email_addressquery | string | Check an email address instead of a phone number. Email consent is available when the email product launches. |
Responses
200Whether a send to the phone number or email address would pass the CASL gate. Exactly one of phone_number/email_address is present, matching the subject queried. consentType and reason are camelCase and mutually exclusive.
Field Type Description phone_numberstring email_addressstring allowedrequiredboolean consentTypestring Present when allowed.
- One of: EXPRESS | IMPLIED
reasonstring Present when not allowed.
- One of: OPT_OUT | NO_CONSENT | CONSENT_EXPIRED
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 422INVALID_PHONE_NUMBER, EMAIL_INVALID_ADDRESS, or VALIDATION_ERROR (provide exactly one of phone_number or email_address).The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
- 501EMAIL_COMING_SOON: email consent is available when the email product launches (sent only for an email_address request).The standard error body.
Example
const { data, error } = await honkio.consents.check({ phoneNumber: '+1613XXXXXXX' })
if (error) throw new Error(error.message)
console.log(data.allowed, data.reason)curl https://api.honkio.ca/v1/compliance/consents/check \
-H "Authorization: Bearer mk_live_YOUR_KEY"/v1/compliance/consents/{phone}Revoke CASL consent for a phone number
compliance:mdNode.js SDKhonkio.consents.revoke()Revokes consent records for the given number. Note: opt-outs are separate. Use POST /opt-outs to also block future sends.
Requires compliance:m or compliance:d (any of).
Parameters
| Parameter | Type | Description |
|---|---|---|
phonerequiredpath | string |
Responses
- 204Every active consent for the number is revoked.
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 404NOT_FOUND: no active consent for the number.The standard error body.
- 422INVALID_PHONE_NUMBER.The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
Example
const { error } = await honkio.consents.revoke({ phoneNumber: '+1613XXXXXXX' })
if (error) throw new Error(error.message)curl -X DELETE https://api.honkio.ca/v1/compliance/consents/PHONE \
-H "Authorization: Bearer mk_live_YOUR_KEY"/v1/compliance/consents/email/{address}Revoke CASL consent for an email address
compliance:mdNode.js SDKhonkio.consents.revoke()Revokes the ACTIVE email consents for the address. Opt-outs and suppressions are separate.
Requires compliance:m or compliance:d (any of).
Parameters
| Parameter | Type | Description |
|---|---|---|
addressrequiredpath | string |
Responses
- 204Every active consent for the email address is revoked.
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 404NOT_FOUND: no active consent for the email address.The standard error body.
- 422EMAIL_INVALID_ADDRESS.The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
- 501EMAIL_COMING_SOON: email consent is available when the email product launches.The standard error body.
Example
const { error } = await honkio.consents.revoke({ emailAddress: 'sam@example.com' })
if (error) throw new Error(error.message)curl -X DELETE https://api.honkio.ca/v1/compliance/consents/email/ADDRESS \
-H "Authorization: Bearer mk_live_YOUR_KEY"/v1/compliance/opt-outsList opt-out records
compliance:rRequires compliance:r.
Parameters
| Parameter | Type | Description |
|---|---|---|
phone_numberquery | string | |
from_numberquery | string | |
pagequery | integer |
|
limitquery | integer |
|
Responses
200A page of opt-out records, newest first. No total is returned.
Field Type Description data[]requiredobject[] idrequiredstring accountIdrequiredstring channelrequiredstring - One of: SMS | EMAIL
phoneNumberrequiredstring - Can be null
fromNumberrequiredstring The sending number the subscriber opted out from (SMS).
- Can be null
fromAddressrequiredstring - Can be null
emailAddressrequiredstring - Can be null
keywordUsedrequiredstring STOP, UNSUBSCRIBE and so on; null for an opt-out recorded through the API.
- Can be null
optedOutAtrequiredstring - Format: date-time
reinstatedAtrequiredstring - Format: date-time
- Can be null
reinstateKeywordrequiredstring - Can be null
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403The API key lacks the permission this operation requires, or the account is suspended or closed.The standard error body.
- 422VALIDATION_ERROR: the request failed validation; details names the fields.The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
Example
curl https://api.honkio.ca/v1/compliance/opt-outs \
-H "Authorization: Bearer mk_live_YOUR_KEY"/v1/compliance/opt-outsManually record an opt-out for a phone number
compliance:wRequires compliance:w.
Request body
| Field | Type | Description |
|---|---|---|
phone_numberrequired | string | Number that is opting out (subscriber) |
from_numberrequired | string | Your sending number they are opting out from |
Responses
201Opted out.
Field Type Description statusrequiredstring - One of: opted_out
- 401Missing, invalid, revoked or expired API key.The standard error body.
- 402The account has no balance, or a LIVE key was used before the first top-up.The standard error body.
- 403PHONE_NUMBER_NOT_OWNED: a live key recorded an opt-out from a number the account does not hold.The standard error body.
- 422INVALID_PHONE_NUMBER or VALIDATION_ERROR.The standard error body.
- 429Rate limit reached: 100 requests per second per account, or a route-specific limit (Retry-After set where one applies).The standard error body.
- 500Unexpected server error.The standard error body.
Example
curl -X POST https://api.honkio.ca/v1/compliance/opt-outs \
-H "Authorization: Bearer mk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+1613XXXXXXX",
"from_number": "+1416XXXXXXX"
}'
HonkIO