Skip to main content

List All OTP Codes

List all otp codes

HTTP Request​

GET/api/notifications/otp/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO AN EXTRA REDIRECT WITH 301 STATUS

Authorization​

Authorization

  • Required: Yes
  • Permission: Staff with OTPPermission or Admin
  • Permission Code: 2852
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Query Parameters​

ParameterTypeDefaultDescription
limitinteger—Number of results to return per page.
offsetinteger—Number of results to skip before returning results.
searchstring—Search term to lookup results by `code`, `mobile_number`, `email`
orderingstring—Order results by `id`, `code`, `mobile_number`, `email`, `ttl`
id_mininteger—Minimum ID of the otp code.
id_maxinteger—Maximum ID of the otp code.
created_datestring—Exact creation date (`YYYY-MM-DD`).
updated_datestring—Exact last update date (`YYYY-MM-DD`).
created_fromstring—Start date for otp codes created after this date (`YYYY-MM-DD`).
updated_fromstring—Start date for otp codees updated after this date (`YYYY-MM-DD`).
created_tostring—End date for otp codes created before this date (`YYYY-MM-DD`).
updated_tostring—End date for otp codes updated before this date (`YYYY-MM-DD`).
has_mobile_numberboolean—filters otp codes that are/are not for a mobile number
has_emailboolean—filters otp codes that are/are not for an email
mobile_numberstring—filters otp codes by their related mobile number
emailstring—filters otp codes by their related emails
is_allowboolean—filters otp codes that are/are not valid

Example Requests​

1import requests
2
3# List all otp codes
4response = requests.get('http://www.example.com/api/notifications/otp',
5  headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())

Object Structure​

FieldTypeDescription
countIntegerTotal number of categories
nextStringURL for the next page of results
previousStringURL for the previous page of results
resultsArray[Object]Array of OTPCode objects

OTPCode Object Data Structure

FieldTypeDescription
idIntegerUnique ID of the otp code.
codeIntegerThe otp code
mobile_numberStringThe related mobile number (nullable, valid iranian mobile number)
emailStringThe related email address (nullable, valid email format)
recipientStringThe receiver of the otp code (either email or mobile number, calculated field)
valid_toString (ISO 8601)Timestamp when the otp code will be expired.
ttlIntegerThe duration in seconds which the otp code will be valid (calculated field)
is_allowBooleanWhether the otp code is still valid and usable or not (calculated field)
created_atString (ISO 8601)Timestamp when the otp code was created.
updated_atString (ISO 8601)Timestamp when the otp code was last updated.

Example Response​

{
"count": 4,
"next": null,
"previous": null,
"results": [
{
"id": 21,
"code": 28455,
"mobile_number": "09123456789",
"email": null,
"recipient": "09123456789",
"valid_to": "2025-11-28T15:12:55.826028Z",
"ttl": 0,
"is_allow": false,
"created_at": "2025-11-28T15:10:55.827732Z",
"updated_at": "2025-11-28T15:10:55.827735Z"
},
{
"id": 22,
"code": 96669,
"mobile_number": "09123456789",
"email": null,
"recipient": "09123456789",
"valid_to": "2025-11-28T15:18:42.812141Z",
"ttl": 0,
"is_allow": false,
"created_at": "2025-11-28T15:16:42.813949Z",
"updated_at": "2025-11-28T15:16:42.813953Z"
},
{
"id": 23,
"code": 31295,
"mobile_number": "09123456789",
"email": null,
"recipient": "09123456789",
"valid_to": "2025-11-28T15:20:45.774219Z",
"ttl": 0,
"is_allow": false,
"created_at": "2025-11-28T15:18:45.775861Z",
"updated_at": "2025-11-28T15:18:45.775865Z"
},
{
"id": 24,
"code": 49459,
"mobile_number": "09123456789",
"email": null,
"recipient": "09123456789",
"valid_to": "2025-11-28T15:24:31.102466Z",
"ttl": 0,
"is_allow": false,
"created_at": "2025-11-28T15:22:31.104239Z",
"updated_at": "2025-11-28T15:22:31.104242Z"
}
]
}