Codes are intended to make one-time verifications which can be used for various features such as verifying a user and generating one-time passwords. These can be sent through various channels such as email, whatsapp, text message or voice call.
The Codes model has the following endpoints:
| Action | Method | Resource | Description |
|---|---|---|---|
| Generate Code | POST | /codes/generate | Generate one time code |
| Generate Code | GET | /codes/generate | Generate one time code |
| Verify Code | POST | /codes/verify | Verify one time code |
| Verify Code | GET | /codes/verify | Verify one time code |
The Codes model has the following attributes:
| Attribute | Type | required | Description |
|---|---|---|---|
| to | String | ||
| type | Integer | ||
| channel | Integer | ||
| code | string | ||
| sender_id | integer | ||
| attemps | Integer | ||
| times | Integer | ||
| send_data | JSON | ||
| last_sent_at | Date |
Restrictions for codes
- Any user can generate codes
- Only Admins can verify codes
Codes types
Below mentioned are the values of the type parameters of the respective Codes Type:
| type | value | description |
|---|---|---|
| General | 1 | |
| Cellphone verification | 2 | |
| Email verification | 3 | |
| One time password | 4 |
Codes Channels
Below mentioned are the values of the channel parameters of the respective Codes Channels:
| type | value | description |
|---|---|---|
1 | Send the code via email | |
| SMS (twilio) | 2 | Send the code via sms using twilio |
| Call (Twilio) | 3 | Send the code via call using twilio |
| Whatsapp (Twilio) | 4 | Send the code via whatsapp using twilio |
| Custom | 5 | A custom channel can by added using the plugins with the hook code_verification_{channel}_sent |

