Mint a hosted-form consent token
Mint a signed token bound to the organization, phone number, contact
number, agreement text, and an expiry, and return the public URL to hand
to the end user. The end user opens the URL, reviews a consent form
pre-bound with the agreement text, and submits. AgentMessage records the
evidence and the opt-in with a consent method of hosted_form.
The token is single-use in spirit: a duplicate submit on an already opted-in contact is idempotent. It expires after the configured lifetime (default one hour).
Requires the consent:write scope.
Authenticate by sending your API key as a bearer token:
Authorization: Bearer am_live_.... Every request is automatically
scoped to the organization that owns the key and to the scopes granted
to that key.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/consent/hosted" \ -H "Content-Type: application/json" \ -d '{ "phone_number_id": "7c1f0a2d-9e8b-4c3a-9d2e-1f0a2b3c4d5e", "contact_number": "+15554443333", "agreement_text": "By submitting this form you agree to receive appointment reminders from Agentmessage. Msg & data rates may apply. Reply STOP to opt out." }'{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmciOiIwMTkw…",
"url": "https://api.agentmsg.io/consent/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmciOiIwMTkw…",
"expires_at": "2026-04-27T13:00:00Z"
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "authentication failed",
"request_id": "01JTBQH2FZ8K1RXC0WJ4Z9P3VM"
}
}{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "missing required scope",
"request_id": "01JTBQH2FZ8K1RXC0WJ4Z9P3VM"
}
}{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "not found",
"request_id": "01JTBQH2FZ8K1RXC0WJ4Z9P3VM"
}
}{
"success": false,
"error": {
"code": "VALIDATION_FAILED",
"message": "validation failed",
"request_id": "01JTBQH2FZ8K1RXC0WJ4Z9P3VM",
"details": {
"to": "must be E.164",
"body": "must be 1..1600 chars"
}
}
}