Skip to main content
Question

Why does SMS Opt In API not produce a Consent record?

  • November 19, 2025
  • 5 replies
  • 71 views

I'm working with the Consent API. My flow is as follows,

 

  1. Make a request to Opt In a customer phone number for SMS
  1. Use a GET request to confirm the Opt In has been registered. 

Below is my code snippet

 

            SmsOptRecord smsOptRecord = new SmsOptRecord();            smsOptRecord.from(RINGOUT_CALLER);            smsOptRecord.to(RINGOUT_RECIPIENT);            smsOptRecord.optStatus("OptIn");            smsOptRecord.source("Api");            Map<String, Object> body = new HashMap<>();            body.put("records", List.of(smsOptRecord));            var createConsent = rc.patch("/restapi/v2/accounts/~/sms/consents", body);            System.out.println(createConsent.string());            Map<String, Object> getConsentsRequestBody = new HashMap<>();            getConsentsRequestBody.put("from", List.of(RINGOUT_CALLER));            getConsentsRequestBody.put("optStatus", List.of("OptIn"));//            var getConsents = rc.get("restapi/v2/accounts/~/sms/consents");            var getConsents = rc.get("restapi/v2/accounts/~/sms/consents", getConsentsRequestBody);            System.out.println(getConsents.string());

 

This code produces the following logs.

 

{"failedRecords":[]}
{"records":[],"paging":{"perPage":0}}

 

I am expecting the second log to have a record of my OptIn. Whenever I do the opposite and register an OptOut, I get the expected record in the second log message. 

 

Why isn't my Opt In being registered and returned in my GET request?

5 replies

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • November 19, 2025

Can you remove this line and run the code again

getConsentsRequestBody.put("from", List.of(RINGOUT_CALLER));  

If you get the result, check the from number format and see if they matches the “RINGOUT_CALLER”


  • Author
  • New Participant
  • November 20, 2025

Can you remove this line and run the code again

getConsentsRequestBody.put("from", List.of(RINGOUT_CALLER));  

If you get the result, check the from number format and see if they matches the “RINGOUT_CALLER”

Removing this line yields the same result. Empty records array.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • November 20, 2025

Can you remove this line and run the code again

getConsentsRequestBody.put("from", List.of(RINGOUT_CALLER));  

If you get the result, check the from number format and see if they matches the “RINGOUT_CALLER”

Removing this line yields the same result. Empty records array.

That’s weird. Please submit a dev support ticket for this.


  • Author
  • New Participant
  • November 20, 2025

The documentation is a little bit confusing. For OptIn, you need to have a query parameter. Putting OptIn into the request body will not work.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • November 20, 2025

The documentation is a little bit confusing. For OptIn, you need to have a query parameter. Putting OptIn into the request body will not work.

It should work. I just don’t know why it does not work in your case. Try this if you have installed the JS SDK and can run Node JS
 

async function read_consents(){
let params = {
optStatus: ["OptIn"]
perPage: 20
}
let endpoint = '/restapi/v2/accounts/~/sms/consents'

try {
var resp = await platform.get(endpoint, params)
var jsonObj = await resp.json()
console.log(jsonObj)
} catch (e) {
console.log("Error:", e.message)
}
}

// Response

{

  records: [

    {

      from: '+1209294XXXX',

      to: '+1650224XXXX',

      optStatus: 'OptIn',

      source: 'Api',

      lastModifiedTime: '2025-11-18T16:16:15.142810Z',

      coverage: 'PhoneNumber'

    },

    {

      from: '+1657390XXXX',

      to: '+1650224XXXX',

      optStatus: 'OptIn',

      source: 'Recipient',

      lastModifiedTime: '2025-07-30T14:48:41.982484Z',

      coverage: 'PhoneNumber'

    },

   ...

]