Skip to main content

Overview

Account-password sign-in API. Sign in with an account, phone number, or email address plus password.

Provide one of account, phone, or email.

Request

Authentication: This API does not require sign-in. Include only the appkey request header; Authorization is not required. After successful sign-in, the response provides authorization for subsequent authenticated APIs.

Method: POST

Rate limit: 100 requests/second

Endpoint: https://API domain/jim/login

Content-Type: application/json

Request parameters

ParameterData typeRequiredDescription
accountstringNoAccount. Letters and digits are recommended; length: 6–20 characters. Provide one of account, phone, or email.
phonestringNoPhone number
emailstringNoEmail address
passwordstringYesAccount password (plain text).

password usage rules

  • Send the plain-text password (for example, 123456). The server calculates SHA1(password) (lowercase hex) and compares it with LoginPass in the database.
  • Do not apply md5 or sha1 to password on the client before sending it. Otherwise, the server applies SHA1() again and validation fails.

Example: SHA1("123456") = 7c4a8d09ca3762af61e59520943dc26494f8941b. This is only to explain server-side validation; send the plain-text value 123456 as the request parameter.

Request example

POST /jim/login HTTP/1.1
appkey: appkey
Content-Type: application/json

{
"account":"username",
"password":"123456"
}

You can also call the API with curl:

curl -X POST 'https://$api/jim/login' \
-H 'appkey: <your-appkey>' \
-H 'Content-Type: application/json' \
-d '{"account":"username","password":"123456"}'

JavaScript fetch example:

await fetch("https://$api/jim/login", {
method: "POST",
headers: {
appkey: "<your-appkey>",
"Content-Type": "application/json",
},
body: JSON.stringify({
account: "username",
password: "123456",
}),
});

Response example

{
"code":0,
"msg":"sucess",
"data":{
"user_id":"userid1",
"authorization":"xxxxxxxxx",
"nickname":"user1",
"avatar":"xxxxxxxx",
"status":0,
"im_token":"xxxxxxxxx"
}
}

Common Error Codes

codeMeaningTypical trigger
17001Missing appkeyThe request header does not include appkey (validated by the server authentication middleware).
17002Appkey does not exist / application does not existThe application associated with appkey does not exist, or the server cannot obtain an IM SDK instance.
17003Invalid request parametersJSON parsing failed; password is empty; or all of account, phone, and email are empty.
17012User does not existNo user was found by account, phone, or email.
17013Incorrect passwordServer validation found that SHA1(password) does not match the user LoginPass.
17004Internal service timeout or invocation failedThe server failed to register with IM Server or obtain a token (for example, because of network errors or timeouts).