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
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page. |
| offset | integer | — | Number of results to skip before returning results. |
| search | string | — | Search term to lookup results by `code`, `mobile_number`, `email` |
| ordering | string | — | Order results by `id`, `code`, `mobile_number`, `email`, `ttl` |
| id_min | integer | — | Minimum ID of the otp code. |
| id_max | integer | — | Maximum ID of the otp code. |
| created_date | string | — | Exact creation date (`YYYY-MM-DD`). |
| updated_date | string | — | Exact last update date (`YYYY-MM-DD`). |
| created_from | string | — | Start date for otp codes created after this date (`YYYY-MM-DD`). |
| updated_from | string | — | Start date for otp codees updated after this date (`YYYY-MM-DD`). |
| created_to | string | — | End date for otp codes created before this date (`YYYY-MM-DD`). |
| updated_to | string | — | End date for otp codes updated before this date (`YYYY-MM-DD`). |
| has_mobile_number | boolean | — | filters otp codes that are/are not for a mobile number |
| has_email | boolean | — | filters otp codes that are/are not for an email |
| mobile_number | string | — | filters otp codes by their related mobile number |
| string | — | filters otp codes by their related emails | |
| is_allow | boolean | — | filters otp codes that are/are not valid |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# List all otp codes
2curl "http://www.example.com/api/notifications/otp" -H "Authorization: Token <your_api_key>"Object Structure
| Field | Type | Description |
|---|---|---|
| count | Integer | Total number of categories |
| next | String | URL for the next page of results |
| previous | String | URL for the previous page of results |
| results | Array[Object] | Array of OTPCode objects |
OTPCode Object Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the otp code. |
| code | Integer | The otp code |
| mobile_number | String | The related mobile number (nullable, valid iranian mobile number) |
| String | The related email address (nullable, valid email format) | |
| recipient | String | The receiver of the otp code (either email or mobile number, calculated field) |
| valid_to | String (ISO 8601) | Timestamp when the otp code will be expired. |
| ttl | Integer | The duration in seconds which the otp code will be valid (calculated field) |
| is_allow | Boolean | Whether the otp code is still valid and usable or not (calculated field) |
| created_at | String (ISO 8601) | Timestamp when the otp code was created. |
| updated_at | String (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"
}
]
}