Home > other >  What are all the responses from Twilio Fetch a Verification by SID?
What are all the responses from Twilio Fetch a Verification by SID?

Time:09-29

Documentation:

https://www.twilio.com/docs/verify/api/verification#fetch-a-verification

Backgroud

After reading the documentation the functionality is simple. I am checking the status of my code so I know when to prompt my user to enter it or try the process again if errors occur.

Issues

When I test my phone number I receive "pending" every time yet the code has already been sent. I cannot find a full list of responses from the Twilio API. This is the only response.

I am assuming that it returns pending because the verification of the device is pending. So what do I check to see if the message was sent to the user?

I cannot find the description of the response keys so it makes it difficult to understand which key to check.

{
  "sid": "VEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "service_sid": "VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "to": " 15017122661",
  "channel": "sms",
  "status": "pending",
  "valid": false,
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "lookup": {
    "carrier": {
      "error_code": null,
      "name": "Carrier Name",
      "mobile_country_code": "310",
      "mobile_network_code": "150",
      "type": "mobile"
    }
  },
  "amount": null,
  "payee": null,
  "send_code_attempts": [
    {
      "time": "2015-07-30T20:00:00Z",
      "channel": "SMS",
      "channel_id": null
    }
  ],
  "url": "https://verify.twilio.com/v2/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Verifications/VEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

CodePudding user response:

Twilio developer evangelist here.

The properties are described in the documentation under "Verification Response Properties". The entry for "status" reads:

The status of the verification. One of: pending, approved, or canceled

Once you have created a verification it will be in "pending" status until it is successfully checked.

Checking whether a message has been sent is as simple as a status, when you consider that Twilio Verify can send verifications by SMS, WhatsApp, Voice call or email. You should assume that once you have successfully created a Verification that Twilio will enact the delivery of the code over the chosen channel.

This blog post might give you some good ideas for how to control the experience for you users and create a UI that helps them receive the verification codes successfully.

  • Related