Skip to main content

Create otp code

Creates a new otp code

HTTP Request

POST/api/notifications/otp/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO A 500 SERVER ERROR

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
codeIntegerYesThe otp code
mobile_numberStringNoThe mobile number related to the otp code (valid iranian mobile number)
emailStringNoThe email address related to the otp code (valid email format)
valid_toString(Datetime)NoThe expiration datetime of the otp code (default: calculated from the settings)

Example Requests

1import requests
2
3# Create a new otp code
4response = requests.post('http://www.example.com/api/notifications/otp', 
5  json={
6        "code": 255315,
7        "mobile_number": "09123256545",
8        "email": null,
9        "valid_to": "2025-12-30T14:39:10.268800Z"
10  },
11  headers={'Authorization': 'Token <your_api_key>'}
12)
13print(response.json())

Response Fields

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

{
"id": 66,
"code": 255315,
"mobile_number": "09123256545",
"email": null,
"recipient": "09123256545",
"valid_to": "2025-12-29T14:48:02.776780Z",
"ttl": 119,
"is_allow": true,
"created_at": "2025-12-29T14:46:02.777862Z",
"updated_at": "2025-12-29T14:46:02.777866Z"
}

NOTES

  • Either one field from mobile_number or email should be provided (only one)
  • if valid_to is not provided, it will be calculated from the otp expiration time of the project
  • valid_to can not be explicitely set to null
  • recipient, ttl, is_allow are calculated fields