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
appkeyrequest header;Authorizationis not required. After successful sign-in, the response providesauthorizationfor subsequent authenticated APIs.
Method:
POST
Rate limit:
100 requests/second
Endpoint: https://API domain/jim/login
Content-Type:
application/json
Request parameters
| Parameter | Data type | Required | Description | |
|---|---|---|---|---|
| account | string | No | Account. Letters and digits are recommended; length: 6–20 characters. Provide one of account, phone, or email. | |
| phone | string | No | Phone number | |
| string | No | Email address | ||
| password | string | Yes | Account password (plain text). |
password usage rules
- Send the plain-text password (for example,
123456). The server calculatesSHA1(password)(lowercase hex) and compares it withLoginPassin the database. - Do not apply
md5orsha1topasswordon the client before sending it. Otherwise, the server appliesSHA1()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
| code | Meaning | Typical trigger |
|---|---|---|
| 17001 | Missing appkey | The request header does not include appkey (validated by the server authentication middleware). |
| 17002 | Appkey does not exist / application does not exist | The application associated with appkey does not exist, or the server cannot obtain an IM SDK instance. |
| 17003 | Invalid request parameters | JSON parsing failed; password is empty; or all of account, phone, and email are empty. |
| 17012 | User does not exist | No user was found by account, phone, or email. |
| 17013 | Incorrect password | Server validation found that SHA1(password) does not match the user LoginPass. |
| 17004 | Internal service timeout or invocation failed | The server failed to register with IM Server or obtain a token (for example, because of network errors or timeouts). |