SMS

Consent (CASL)

Under CASL you must record consent before sending a commercial message. The API refuses sends to numbers without valid consent (HTTP 451).

CASL Consent (required before sending)

Under CASL, you must record consent before sending a commercial message to any recipient. The API will block sends to phone numbers without valid consent (HTTP 451).

const { error } = await honkio.consents.create({
  phoneNumber: '+1613XXXXXXX',
  consentType: 'express',
  sourceDescription: 'Website opt-in form',
  sourceIp: '203.0.113.1',
})
if (error) throw new Error(error.message)

Implied consent for an existing customer, with the clock running from their last transaction:

const { data, error } = await honkio.consents.create({
  phoneNumber: '+1613XXXXXXX',
  consentType: 'implied',
  relationshipType: 'purchase',
  lastTransactionDate: '2025-11-04',
})
if (error) throw new Error(error.message)
console.log(data.expires_at) // '2027-11-04T00:00:00.000Z'

Express consent never expires. Implied consent expires after 2 years per CASL §10(9). Pass last_transaction_date so the two-year clock runs from the real relationship rather than from the day you record it, or set expires_at outright when you have already worked out the expiry. The response echoes expires_at so you can verify it.