Record text consent
Record that a visitor agreed on your site to get your marketing texts, so your campaigns and workflow texts can reach them.
POST /v1/sms-consents records that someone agreed on your website to get your marketing texts. Text campaigns and text steps in workflows only go to numbers that agreed. See Consent to marketing texts.
Call it when your form is sent with its texting box ticked, like a quote request with "Text me about my quote and offers".
Ask on your form
Add a box next to the phone field that the visitor ticks themselves. Leave it unticked to start, and don't make it required to send the form. Its words should name your organization, say the texts are marketing, and say how to stop. For example:
I agree to get recurring marketing texts from Northside Pottery at this number. Consent is not a condition of purchase. Msg frequency varies. Msg & data rates may apply. Reply HELP for help, STOP to opt out.
Only call this endpoint when the box is ticked.
Record it
Send the number and the words beside the box, exactly as your form showed them.
curl -X POST https://api.lahuta.org/v1/sms-consents \
-H "X-Api-Key: $LAHUTA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+15035550131",
"wording": "I agree to get recurring marketing texts from Northside Pottery at this number. Consent is not a condition of purchase. Msg frequency varies. Msg & data rates may apply. Reply HELP for help, STOP to opt out.",
"pageUrl": "https://northsidepottery.com/commissions",
"ip": "203.0.113.24",
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)"
}'{
"status": "active"
}| Field | Required | What it does |
|---|---|---|
phone | Yes | The number that agreed, in E.164, like +15035550131 |
wording | Yes | The words beside the box, exactly as shown. Up to 2,000 |
pageUrl | No | The page the form was on |
ip | No | The visitor's IP address, as your server saw it |
userAgent | No | The visitor's browser, from their User-Agent header |
status is active when the number can get your marketing texts from now on. It's pending when your organization asks new numbers to reply YES: the number gets a text asking, and counts once they reply.
Things to know:
- Record it before you start a workflow. A text step checks for consent when it runs. If you start a workflow first, its first text can run before the consent is saved and be skipped.
- The consent belongs to the number. It isn't tied to one contact. A contact who gives you a new number needs to agree again for that one.
- Calling again is safe. A second call for the same number keeps it agreed and saves the new proof beside the first.
- It doesn't undo a STOP. A number that replied STOP to your texts stays opted out until the person texts START.
- It's only for marketing. Booking confirmations, tickets and texts from
POST /v1/textsdon't need it.
Errors
| Error | When | What to do |
|---|---|---|
400 | phone isn't in E.164, or wording is missing, empty or over 2,000 characters | Check the number's format and the words |
See the API reference for every field.