Docs home

Get API Key with Login OTP

Exchanges a login OTP for an API key. First call "Login OTP Send" with the user's email or contact number, then call this with the same value as `username` and the code received as `otp`.

POST/tutor/login
Get API Key with Login OTP
curl --request POST \
  --url 'https://<your-api-host>/nuSource/api/v1/tutor/login' \
  --form 'JSONString={"username":"hemal@edmingle.com","otp":"205627","persistent_login":true}'
{
  "code": 200,
  "message": "Login successful",
  "user": {
    "username": "DemoHemal2944375",
    "apikey": "2514e6e496a4dfa5ee22759b55040959",
    "role": 1,
    "user_id": 89158911,
    "name": "DemoHemal",
    "contact_number": "7359943259",
    "email": "hemal@edmingle.com",
    "is_sign_up": 0,
    "server_key": "d43015e672cd3b3c76c7d42a6c26b3c5",
    "is_user_mfa_enabled": 0
  }
}

Access: Public, no API key.

Request body: form-data with one field, JSONString, containing this JSON:

BodyJSONString
usernamestringrequired
Email, username or contact number. Up to 50 characters. Not case-sensitive.
passwordstringOne of password or otp
The user's password.
otpstringOne of password or otp
Login OTP from "Login OTP Send". Only works with an email or contact number as username.
true (default) gives a key valid for 30 days (1 day for some institutes); false gives 5 hours. Send a JSON boolean.
user_idinteger
Picks one account when the same credentials match several (see Notes).
1 web (default), 2 Android, 3 iOS, 4 API.
Device identifier used by Edmingle's apps. Integrations can leave it out.
Device session key returned by an earlier login on the same device. Integrations can leave it out.
Response200application/json
codeinteger
Example: 200
messagestring
Example: Login successful
userobject
Show child attributesHide child attributes
Example: DemoHemal2944375
Send it as the APIKEY header
Example: 2514e6e496a4dfa5ee22759b55040959
user.roleinteger
0 tutor, 1 learner, 2 admin or institute admin, 4 parent, 7 custom role
Example: 1
Example: 89158911
user.namestring
Example: DemoHemal
Example: 7359943259
Example: hemal@edmingle.com
0
Example: 0
Example: d43015e672cd3b3c76c7d42a6c26b3c5
Example: 0

Notes:

  • Log in on your institute's own API host; the institute is taken from the host name and only its users can log in.
  • If the credentials match more than one account, there is no apikey: payload.users lists each account as [id, name, email, contact_number, username]. Send the login again with the chosen user_id.
  • If is_user_mfa_enabled is 1 after a password login, the key is not active: your institute requires OTP login for this role. Use the OTP flow instead.
  • Errors: "PLEASE ENTER PASSWORD / OTP" (neither sent), invalid.credentials, "Invalid OTP", a blocked-user error, "Please Contact Admin." (user has no active organization), "Please login using mobile application" (learners, when the institute allows app-only login) and "You already have N active sessions" when the institute limits learner sessions. With a session limit and no such error, the learner's oldest sessions are logged out.
  • Rate limit: 30 requests per minute; going over locks you out for 30 minutes.
  • The OTP is valid for 30 minutes and only the latest one sent works. OTP login skips the multi-factor check, so the key is always active.

Updated yesterday

Ask AI