IM REST API

The JMessage API provides developers with an HTTP API for related IM functionality.

Addresses of these API are unified (note that unlike the Push API): https://api.im.jpush.cn

HTTP Authentication

Authentication uses the HTTP Basic mechanism, which adds a field (Key/Value pair) to the HTTP Header (header):

Authorization: Basic base64_auth_string

The generation algorithm of base64_auth_string is: base64(appKey:masterSecret)

That is, add a colon to the appKey, plus the string assembled by masterSecret, and do a base64 conversion.

Overview of User Object Fields

Parameter Meaning Limits of character length
username User login name Byte(4~128)
password Login password Byte(4~128)
appkey Appkey to which the user belongs
nickname User nickname Byte(0~64)
birthday Birthday yyyy-MM-dd HH:mm:ss
gender Gender 0 - Unknown, 1 - Male, 2 - Female
signature User signature Byte(0~250)
region User area Byte(0~250)
address Detailed address Byte(0~250)
ctime User creation time
mtime Last modified time
extras User-defined json objects Byte(0~512)

User Registration

Register as user

Batch registration of users to JMessage server, up to 500 users in one batch registration

  1. POST /v1/users/

Example Request

  1. [{"username": "dev_fang", "password": "password"}]

Request Params

JSON Array.

  • username (required)
    • At the beginning: letters or numbers
    • letters, numbers, underscores
    • English, minus, @
  • password (required) JMessage server will be saved with MD5 encryption.
  • nickname (optional)
    • Unsupported characters: English characters: \n \r\n
  • avatar (optional)
    • Need to fill in the media_id obtained from the uploading interface of files
  • birthday (optional) example: 1990-01-24
    • yyyy-MM-dd
  • signature (optional)
    • Supported characters: All, including Emoji
  • gender (optional)
    • 0 - Unknown, 1 - Male, 2 - Female
  • region (optional)
    • Supported characters: All, including Emoji
  • address (optional)
    • Supported characters: All, including Emoji
  • extras (optional) user-defined json objects

Example Response

  1. < HTTP/1.1 201 Created
  2. < Content-Type: application/json
  3. <
  4. [{"username": "dev_fang" }]

Response Params

JSON Array.

  • username
  • Error: When an error occurs in the registration of a user, there is an error object in the object indicating the cause of the error.
    • 899003: parameter error, Request Body does not meet the requirements
    • 899001: user already exists

Admin Registration

Admin Register (Administrator api sends permissions of message interface)

  1. POST /v1/admins/

Example Request

  1. {"username": "dev_fang", "password": "password"}

Request Params

  • username Byte(4-128) supported character
    • At the beginning: letters or numbers
    • letters, numbers, underscores
    • English, minus, @
  • password Byte(4-128) Characters are not limited
  • nickname (optional)
    • Unsupported characters: English characters: \n \r\n
  • avatar (optional)
    • Need to fill in the media_id obtained from the uploading interface of files
  • birthday (optional) birthday example: 1990-01-24
    • yyyy-MM-dd
  • signature (optional)
    • Supported characters: All, including Emoji
  • gender (optional)
    • 0 - Unknown, 1 - Male, 2 - Female
  • region (optional)
    • Supported characters: All, including Emoji
  • address (optional)
    • Supported characters: All, including Emoji
  • extras (optional) user-defined json objects

Example Response

  1. HTTP/1.1 201 Created
  2. Content-Type: application/json; charset=utf-8

GetAdminsListByAppkey: Get admin list of app

  1. GET /v1/admins?start={start}&count={count}

Example Request

Request Header

  1. GET /admins?start=1&count=30
  2. Acct: application/json

Request Body

  • N/A

request params

  • start: record position of starting, starts from 0
  • count: query number, supports up to 500

Example Response

Response Header

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. {
  2. "total":1233,
  3. "start":1100,
  4. "count":3,
  5. "users":
  6. [{ "username": "cai",
  7. "nickname": "hello",
  8. "mtime": "2015-01-01 00:00:00",
  9. "ctime": "2015-01-01 00:00:00"
  10. }, {"username": "yi",
  11. "nickname": "hello",
  12. "mtime": "2015-01-01 00:00:00",
  13. "ctime": "2015-01-01 00:00:00"
  14. }, {"username": "huang",
  15. "nickname": "hello",
  16. "mtime": "2015-01-01 00:00:00",
  17. "ctime": "2015-01-01 00:00:00"
  18. }]}

User Maintenance

Get user information

  1. GET /v1/users/{username}

Request Params

  • username: Fill to the request path

Example Response

  1. {
  2. "username": "javen",
  3. "nickname": "hello",
  4. "avatar": "/avatar",
  5. "birthday": "1990-01-24 00:00:00",
  6. "gender": 0,
  7. "signature": "orz",
  8. "region": "shenzhen",
  9. "address": "shenzhen",
  10. "mtime": "2015-01-01 00:00:00",
  11. "ctime": "2015-01-01 00:00:00"}

Instructions

In addition to the username mtime ctime, these three sub-sections, if there is no json for the the remaining fields, then there is no corresponding key.

Update user information

  1. PUT /v1/users/{username}

Example Request

  1. {
  2. "nickname": "Hello JMessage"
  3. }

Request Params

  • nickname (optional)
    • Unsupported characters: English characters: \n \r\n
  • avatar (optional)
    • Need to fill in the media_id obtained from the uploading interface of files
  • birthday (optional) birthday example: 1990-01-24
    • yyyy-MM-dd
  • signature (optional)
    • Supported characters: All, including Emoji
  • gender (optional)
    • 0 - Unknown, 1 - Male, 2 - Female
  • region (optional)
    • Supported characters: All, including Emoji
  • address (optional) address
    • Supported characters: All, including Emoji
  • extras (optional) user-defined json objects

Example Response

  1. < HTTP/1.1 204
  2. < Content-Type: application/json; charset=utf-8

Query user online status

  1. Get /v1/users/{username}/userstat

Example Request

Request Header

  1. Get /v1/users/caiyh/userstat
  2. Content-Type: application/json; charset=utf-8

Request Params

  • username

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 200 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. {"login":true, "online": false}

This interface is not applicable to multi-end online. Please use batch status interface for multi-end online.

Error Code

  • 899003: username is illegal
  • 899002: user does not exist

Query bulk user online status

  1. Post /v1/users/userstat

Example Request

Request Header

  1. Post /v1/users/userstat
  2. Content-Type: application/json; charset=utf-8

Request Params

  • N/A

Request Body

  1. ["USER1","USER2"]

Example Response

Response Header

  1. HTTP/1.1 200
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. [
  2. {
  3. "devices": [],
  4. "username": "caiyh01"
  5. },
  6. {
  7. "devices": [{
  8. "login": false,
  9. "online": false,
  10. "platform": "a"
  11. }],
  12. "username": "Rauly"
  13. }
  14. ]
  • devices: Array of device login status. Array as empty if no login.
  • Platform SDK Platforms: a-Android, i-iOS, j-JS, w-Windows

Error Code

  • 899003: username is illegal
  • 899002: user does not exist

Change password

  1. PUT /v1/users/{username}/password

Request Header

  1. PUT /v1/users/javen/password

Example Request

  1. {
  2. "new_password": "654321"
  3. }

Request Params

  • new_password (required)

Example Response

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Delete users

  1. DELETE /v1/users/{username}

Request Params

  • username

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Ctent-Type: application/json; charset=utf-8

Delete users in batches

  1. DELETE /v1/users/

Request Body

  1. ["USER1","USER2"]
  • username: Array of usernames. (Maximum support for deleting 100 users at the same time)

Example Response

  1. < HTTP/1.1 20 NO CONTENT
  2. < Content-Type: application/json; charset=utf-8

Add blacklist

  1. Put /v1/users/{username}/blacklist

Example Request

Request Header

  1. Put /v1/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • JsonArray
  • username的JsonArray

Request Body

  1. [
  2. "test1",
  3. "test2"
  4. ]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Remove blacklist

  1. Delete /v1/users/{username}/blacklist

Example Request

Request Header

  1. Delete /v1/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • JsonArray
  • username的JsonArray

Request Body

  1. [
  2. "test1",
  3. "test2"
  4. ]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

List of blacklist

  1. Get /v1/users/{username}/blacklist

Example Request

Request Header

  1. Put /v1/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • username

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 200 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. [{
  2. "username": "javen",
  3. "nickname": "hello",
  4. "avatar" = "/avatar",
  5. "birthday": "1990-01-24 00:00:00",
  6. "gender": 0,
  7. "signature": "orz",
  8. "region": "shenzhen",
  9. "address": "shenzhen",
  10. "mtime": "2015-01-01 00:00:00",
  11. "ctime": "2015-01-01 00:00:00"
  12. }]

Get user list

  1. GET /v1/users/?start={start}&count={count}

Request Params

  • start: Number of records started
  • count: Number of records to retrieve

Example Response

  1. < HTTP/1.1 200
  2. < Content-Type: application/json
  3. {
  4. "total": 12580,
  5. "start": 1100,
  6. "count": 100,
  7. "users":
  8. [{ "username": "cai",
  9. "nickname": "hello",
  10. "mtime": "2015-01-01 00:00:00",
  11. "ctime": "2015-01-01 00:00:00"
  12. }, {"username": "yi",
  13. "nickname": "hello",
  14. "mtime": "2015-01-01 00:00:00",
  15. "ctime": "2015-01-01 00:00:00"
  16. },{ "username": "huang",
  17. "nickname": "hello",
  18. "mtime": "2015-01-01 00:00:00",
  19. "ctime": "2015-01-01 00:00:00"
  20. }]
  21. }

Do-Not-Disturb

Do-Not-Disturb settings

  1. POST /v1/users/{username}/nodisturb

Example Request

Request Header

  1. POST /v1/users/{username}/nodisturb
  2. Content-Type: application/json; charset=utf-8

Request Params

  • single: single chat DND, supports add remove array (optional)
  • group: group chat DND, supports add remove array (optional)
  • global: global DND, 0 or 1 0 means closed, 1 means open (optional)

Request Body

  1. {
  2. "single":{
  3. "add":[
  4. "username1",
  5. "username2"
  6. ]
  7. },
  8. "group":{
  9. "add":[
  10. 110000101
  11. ],
  12. "remove":[
  13. 1000001111
  14. ]
  15. },
  16. "global":0
  17. }

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Error Code

  • 899003: username is illegal;
  • 899002: user does not exist;
  • 899051: group does not exist
  • 899052: sets group
  • Blocked, group blocking is turned on
  • 99053: sets group message block and the group blocking is turned off

Disable users

  1. PUT /v1/users/{username}/forbidden?disable={disable}

Request Params

  • disable boolean, true for disabled users, false for activated users

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Content-Type: application/json

Message Related

Send a message

  1. POST /v1/messages
Parameter Meaning
version Version number is currently 1 (required)
target_type Target type: single - person, group – group, chatroom - chat room (required)
from_type The sender’s identity is currently restricted to the admin user and must be registered as an admin user (required)
msg_type Message type: text, image, custom message (msg_body is json object, server does not check) voice (required)
target_id Target id: single to fill username, group to fill group id, chatroom to fill chatroomid (required)
target_appkey Cross-app target appkey (optional)
from_id Sender’s username (required)
from_name Sender’s display name (optional)
target_name Recipient’s display name (optional)
no_offline Whether the message is stored offline, true or false, defaults to false, indicating that it needs to be stored offline (optional)
no_notification Whether the message is displayed in the notification bar, true or false, the default is false, which means to display in the notification bar (optional)
notification Custom notification bar display (optional)
notification->title Title of the notification (optional)
notification->alert Content of notification (optional)
msg_body The body of the Json object is limited to 4096 bytes
When msg_type is text, the format of msg_body is as follows
msg_body -> text Message content (required)
msg_body-> extras Optional json objects. Developers can customize the extra key value (optional)
When msg_type is an image, msg_body is the json returned by the uploaded image in the following format
msg_body->media_id String: The key returned by the server after the file is uploaded. It is used to generate the downloaded URL (required)
msg_body->media_crc32 The crc32 checksum of a long file, used to download the checksum of the large image (required)
msg_body->width Int: Original width of image (required)
msg_body->height Int: Original height of image (required)
msg_body->format String: Image format (required)
msg_body->hash String: Image hash (optional)
msg_body->fsize Int: File size (bytes) (required)
When msg_type is voice, msg_body is the json returned by uploading voice. The format is as follows:
msg_body->media_id String: The key returned by the server after the file is uploaded. It is used to generate the downloaded URL (required)
msg_body->media_crc32 The crc32 checksum of a long file, used to download the checksum of the large image (required)
msg_body->duration Int: Audio duration (required)
msg_body->hash String: Audio hash (optional)
msg_body->fsize Int: File size (bytes) (required)

Example Request

  1. msg_type:text
  2. {
  3. "version": 1,
  4. "target_type": "single",
  5. "target_id": "javen",
  6. "from_type": "admin",
  7. "from_id": "fang",
  8. "msg_type": "text",
  9. "msg_body": {
  10. "extras": {},
  11. "text": "Hello, JMessage!"
  12. }
  13. }
  14. msg_type:image
  15. {
  16. "version": 1,
  17. "target_type": "single",
  18. "target_id": "javen",
  19. "from_type": "admin",
  20. "from_id": "fang",
  21. "msg_type": "image",
  22. "msg_body": {
  23. "media_id": "qiniu/image/CE0ACD035CBF71F8",
  24. "media_crc32":2778919613,
  25. "width":3840,
  26. "height":2160,
  27. "fsize":3328738,
  28. "format":"jpg"
  29. }
  30. }
  31. msg_type:voice
  32. {
  33. "version": 1,
  34. "target_type": "single",
  35. "target_id": "ppppp",
  36. "from_type": "admin",
  37. "from_id": "admin_caiyh",
  38. "msg_type": "voice",
  39. "msg_body": {
  40. "media_id": "qiniu/voice/j/A96B61EB3AF0E5CDE66D377DEA4F76B8",
  41. "media_crc32":1882116055,
  42. "hash":"FoYn15bAGRUM9gZCAkvf9dolVH7h",
  43. "fsize" :12344;
  44. "duration": 6
  45. }
  46. }
  1. msg_type:custom
  2. {
  3. "version": 1,
  4. "target_type": "single",
  5. "target_id": "ppppp",
  6. "from_type": "admin",
  7. "from_id": "admin_caiyh",
  8. "msg_type": "voice",
  9. "msg_body": {
  10. json define yourself
  11. }
  12. }

Request Params

  • JSON Object.
  • Follow the protocol document: IM Message Protocol
  • This api can only be sent by admin user

Example Response

  1. < HTTP/1.1 201 Created
  2. < Content-Type: application/json
  3. <
  4. {"msg_id": 43143728109, "msg_ctime":1493794522950}

msg_ctime: time stamp created the message

Error Code

  • 899003: parameter error, Request Body parameter does not meet the requirements
  • 899002: user does not exist, and target_id or from_id does not exist
  • 899016: from_id does not have permission to send messages

Retract message

  1. POST /v1/messages/{username}/{msgid}/retract

Example Request

Request Header

  1. POST /v1/messages/{username}/{msgid}/retract

Request Body

  • N/A

Request Params

Parameter Meaning Note
msgid Message msgid
username Username who send this msg

Example Response

Response Header

  1. HTTP/1.1 204 No Content
  2. Content-Type: application/json; charset=utf-8

Error Code

  • 855001: Exceed the withdrawal time. The effective withdrawal time was within 3 minutes after the message was sent.
  • 855003: Revocation message does not exist
  • 855004: Message has been withdrawn

Download and Upload Media Files

Download Document

  1. GET /v1/resource?mediaId={mediaId}

Example Request

Request Header

  1. GET /v1/resource?mediaId={mediaId}

Request Body

  • N/A

Request Params

Parameter Meaning Note
mediaId The mediaId of the resource, including the user’s avatar field

Example Response

Response Header

  1. HTTP/1.1 200 no content
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. {"url":"http://........."}

Upload File

  1. POST /v1/resource?type=image

Example Request

File uploading uses form to upload curl examples:

image uploading curl -F “filename=@/home/test.jpg” https://api.im.jpush.cn/v1/resource?type=image -u “appkey:secret “”

File uploading curl -F “filename=@/home/test.mp3” https://api.im.jpush.cn/v1/resource?type=file -u “appkey:secret”

Voice uploading curl -F “filename=@/home/test.mp3” https://api.im.jpush.cn/v1/resource?type=voice -u “appkey:secret”

Note: The file size is limited to 8m. It only supports image formats currently, including jpg bmp gif png, etc.

Parameter Meaning Note
filename File path of local disk
type File type: Supports “image”, “file”, “voice”

Response Header

Example Response

  1. HTTP/1.1 200
  2. Content-Type: application/json; charset=utf-8

Response Data

Image Response

  1. {
  2. "media_id":"qiniu/image/F39AA12204DAB6A2",
  3. "media_crc32":1338734977,
  4. "width":720,
  5. "height":1280,
  6. "format":"jpg",
  7. "fsize":52468
  8. }
  • media_id String: The key returned by the server after the file is uploaded
  • Crc32 checksum of media_crc32 long file
  • width int: original width of picture
  • height int: original height of picture
  • format String: image format
  • fsize int: file size (bytes)
  • hash String: optional, for alternative verification when the crc checksum does not exist

File Response

  1. {
  2. "media_id":"qiniu/file/j/1BB3B833AEABFF62E883C5CE421867A9",
  3. "media_crc32":1415584260,
  4. "fname":"0839d1c0-48e9-4032-9333-f3691a7d9e48.dmp",
  5. "fsize":176512,
  6. "hash":"FtH0kPT0YI89HAw1K9wv_vVKiNab"
  7. }
  • media_id String: The key returned by the server after the file is uploaded. It is used to generate the downloaded URL.
  • Crc32 checksum of media_crc32 long file
  • hash String; optional, for alternative verification when the crc checksum does not exist
  • fsize int: file size (bytes)
  • fname String: file names of sending and receiving

Voice Response

  1. {
  2. "media_id":"qiniu/voice/j/9C4312B1EA0FB28337566D1A29A244B5",
  3. "media_crc32":1882116055,
  4. "hash":"FoYn15bAGRUM9gZCAkvf9dolVH7h",
  5. "format":"m4a",
  6. "fsize":238105
  7. }
  • media_id String: The key returned by the server after the file is uploaded. It is used to generate the downloaded URL
  • Crc32 checksum for media_crc32 long file
  • hash String: optional, for alternative verification when the crc checksum does not exist
  • fsize int: file size (bytes)
  • format String: format of source file

Overview of Group Object Fields

Parameter Meaning Limits of character length
name Group name Byte(0~64)
desc Group description Byte(0~250)
owner_username Owner’s username Byte(4-128)
MaxMemberCount Group default to 500 people
ctime Creation time
mtime Last Modified Time
avatar Group avatar

Group Maintenance

Create a group

  1. POST /v1/groups/

Group MaxMemberCount (number limit) definition

Example Request

  1. {
  2. "owner_username": "tom",
  3. "name": "群聊天室",
  4. "members_username": ["eddie", "annie"],
  5. "flag": 1,
  6. "desc": "运动"
  7. }

Request Params

  • owner_username (required)
  • name (required) group name
    • Supported characters: All, including Emoji.
  • members_username
  • avatar (optional) group avatar, media_id obtaine when uploading interfaces
  • desc (optional) group description
    • Supported characters: All, including Emoji.
  • flag (optional) type
    • 1 - private group (default)
    • 2 - public group
    • does not specify the flag, the default is 1

Example Response

  1. < HTTP/1.1 201 Created
  2. < Content-Type: application/json
  3. <
  4. {
  5. "gid":12345,
  6. "owner_username": 123456,
  7. "name": "display_name",
  8. "members_username": [],
  9. "desc":"doubi",
  10. "MaxMemberCount" = 500
  11. }

Get group details

  1. GET /v1/groups/{Group id}

Request Params

  • Group id: assigned when creating a group

Example Response

  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json
  3. <
  4. {
  5. "gid": 12345,
  6. "name": "jpush",
  7. "desc": "push",
  8. "appkey": "dcf71ef5082057832bd44fbd",
  9. "MaxMemberCount": 500,
  10. "mtime": "2014-07-01 00:00:00",
  11. "ctime": "2014-06-05 00:00:00"
  12. }

Update group information

  1. PUT /v1/groups/{Group id}

Request Params

  • name: group name
  • desc: group description
  • atar: group avatar, media_id
  1. PUT /v1/groups/{Group id}

Request Body

  1. { "the key you want to update": "the value you want to update" }

Example Response

  1. HTTP/1.1 204 NO Content

Delete group

Delete a group.

All members of the group will receive notification that the group has been dissolved.

  1. DELETE /v1/groups/{Group id}

Request Params

  • Group id

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Content-Type: application/json

Update group members

Batch adding and deleting members of a gid group.

Group members will receive notifications of adding and deleting members

  1. POST /v1/groups/{Group id}/members

Request Params

  • gid: group ID
  • add json array: Indicates the user to add to the group (optional)
  • remove json array: Indicates the user to remove from the group (optional)
  • At least one of the two

Example Request

  1. {
  2. "add":[
  3. "test1", "test2"
  4. ],
  5. "remove":[
  6. "test3", "test4"
  7. ]
  8. }

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Content-Type: application/json

Add group members V2

Batch add group members

Group members will receive notifications of adding members

  1. POST /v2/groups/{Group id}/addMembers

Request Params

  • gid group ID

Example Request

  1. ["test1", "test2"]

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Content-Type: application/json

Delete group members V2

Batch delete group members

Group members will receive notifications of deleting members

  1. POST /v2/groups/{Group id}/delMembers

Request Params

  • gid 群组ID

Example Request

  1. ["test1", "test2"]

Example Response

  1. < HTTP/1.1 204 NO CONTENT
  2. < Content-Type: application/json

Get a list of group members

  1. GET /v1/groups/{Group id}/members/

Request Params

  • Group id

Example Response

  • JsonObject UID array
  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json; charset=utf-8
  3. [
  4. {
  5. "username": "javen",
  6. "nickname": "hello",
  7. "avatar" = "/avatar",
  8. "birthday": "1990-01-24 00:00:00",
  9. "gender": 0, "signature": "orz",
  10. "region": "shenzhen",
  11. "address": "shenzhen",
  12. "flag":0
  13. }
  14. ]
  • flag
    • 0 - common group members
    • 1 - Group owner

Get the group list of some user

  1. GET /v1/users/{username}/groups/

Request Params

  • username

Example Response

  • ctime: group
  • Creation time
  • Mtime: last modified time of group
  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json
  3. [ {
  4. "gid": 12345,
  5. "name": "jpush",
  6. "desc": "push",
  7. "appkey": "dcf71ef5082057832bd44fbd",
  8. "MaxMemberCount": 500,
  9. "mtime": "2014-07-01 00:00:00",
  10. "ctime": "2014-06-05 00:00:00"
  11. }
  12. ]

Get the group list of current application

  1. GET /v1/groups/?start={start}&count={count}

Request Params

  • Start: number of records started
  • count: number of records read this time. The maximum is 500

Example Response

  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json
  3. {
  4. "total":1233,
  5. "start":1100,
  6. "count":1,
  7. "groups":
  8. [{
  9. "gid": 12345,
  10. "name": "jpush",
  11. "desc": "push",
  12. "appkey": "dcf71ef5082057832bd44fbd",
  13. "MaxMemberCount": 500,
  14. "mtime": "2014-07-01 00:00:00",
  15. "ctime": "2014-06-05 00:00:00"
  16. }]
  17. }

Block group message

  1. POST /v1/users/{username}/groupsShield

Request Param

  • N/A

Request Body

  1. {
  2. "add":[
  3. 110000101
  4. ],
  5. "remove":[
  6. 1000001111
  7. ]
  8. }
Parameter Meaning
add Add the gid array of the group message blocking (optional)
remove Remove the gid array of group message blocking(optional)

Example Response

  1. < HTTP/1.1 204 OK
  2. < Content-Type: application/json

Ban group members

  1. PUT /groups/messages/{gid}/silence?status={status}

Request body

  1. [ "username1", "username2"]
  2. 备注:username json数组

Request Params

  1. status:开启或关闭禁言 true表示开启 flase表示关闭

Example Response

  1. < HTTP/1.1 204 OK
  2. < Content-Type: application/json

Friends

Add friend

  1. POST /v1/users/{username}/friends

Request Params

  • json array: Indicates the list of user names to be added. Maximum limit is 500.

Example Request

  1. ["user01","user02"]

Example Response

  1. < HTTP/1.1 201
  2. < Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Error Code

  • 899003: format of Request Body json does not meet the requirements, and json parameter does not meet the requirements;
  • 899002: user does not exist
  • 899070: has added friends

Delete friend

  1. DELETE /v1/users/{username}/friends

Request Params

  • The json array represents the list of user names to be removed. The maximum limit is 500.

Example Request

  1. ["user01","user02"]

Example Response

  1. < HTTP/1.1 204 NO Content
  2. < Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Error Code

  • 899003: format of Request Body json does not meet the requirements, and json parameter does not meet the requirements;
  • 899002: user does not exist;

Update friend notes

  1. PUT /v1/users/{username}/friends

Request Params

  • note_name indicates the list of friends to add. Format: Supported characters of byte(64) excludes “\n” “\r”.
  • others: Other note information, Format: byte(250) supports all characters, including Emoji.
  • Username;
  • Support batch modification with maximum limit as 500.

Example Request

  1. [{
  2. "note_name": "new note name",
  3. "others": “好友备注文档",
  4. "username":"user01"
  5. }]

Example Response

  1. < HTTP/1.1 204 NO Content
  2. < Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Error Code

  • 899003: format of Request Body json does not meet the requirements, and json parameter does not meet the requirements;
  • 899002: user does not exist;

Get friend list

  1. GET /v1/users/{username}/friends

Request Params

  • N/A

Example Request

Example Response

  1. < HTTP/1.1 200 NO Content
  2. < Content-Type: application/json; charset=utf-8

Response Data

  1. [{
  2. "username": "javen",
  3. "nickname": "hello",
  4. "avatar": "/avatar",
  5. "birthday": "1990-01-24 00:00:00",
  6. "gender": 0,
  7. "signature": "orz",
  8. "region": "shenzhen",
  9. "address": "shenzhen",
  10. "mtime": "2015-01-01 00:00:00",
  11. "ctime": "2015-01-01 00:00:00",
  12. "note_name":"= =",
  13. "others":"test",
  14. "appkey":"pojkasouduioadk"
  15. }]

Error Code

  • 899003: format of Request Body json does not meet the requirements, and json parameter does not meet the requirements;
  • 899002: user does not exist;

Cross-application

Cross-application manage group members

  1. POST /v1/cross/groups/{gid}/members

Request Params

  • add json array: Indicates the user to add to the group (optional)
  • remove json array: Indicates the user to remove from the group (optional)
  • appkey: The appkey of user managed is required

at least one of the add and remove

Example Request

  1. [{
  2. "appkey":" 4f7aef34fb361292c566a1cd",
  3. "add": [
  4. "test1",
  5. "test2"
  6. ],
  7. "remove": [
  8. "name3",
  9. "name4"
  10. ]
  11. }]

Example Response

  1. < HTTP/1.1 204 NO Content
  2. < Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Remarks: The group wille deleted when the group has no members

Error Code

  • 899003: format of Request Body json does not meet the requirements, and json parameter does not meet the requirements;
  • 899002: user does not exist;
  • 899012: There are not enough places to add group members;
  • 899014: users do not exist in the group
  • 899011: users already exist in the group

Get a group member list across applications

  1. GET /v1/cross/groups/{Group id}/members/

Request Params

  • Group id

Example Response

  • JsonObject UID: array
  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json; charset=utf-8
  3. [{
  4. "username": "javen",
  5. "nickname": "hello",
  6. "avatar": "/avatar",
  7. "birthday": "1990-01-24 00:00:00",
  8. "gender": 0,
  9. "signature": "orz",
  10. "region": "shenzhen",
  11. "address": "shenzhen",
  12. "flag":0,
  13. "appkey":"appkey"
  14. }]
  • flag
    • 0 - common group members
    • 1 - Group owner

Get user groups across applications

  1. GET /v1/cross/users/{username}/groups

Request Params

  • username

Example Response

  1. < HTTP/1.1 200 OK
  2. < Content-Type: application/json; charset=utf-8
  3. [ {
  4. "gid": 12345,
  5. "name": "jpush",
  6. "desc": "push",
  7. "appkey": "dcf71ef5082057832bd44fbd",
  8. "max_member_count": 200,
  9. "mtime": "2014-07-01 00:00:00",
  10. "ctime": "2014-06-05 00:00:00",
  11. "appkey":"appkey"
  12. }]

Add a blacklist across applications

  1. Put /v1/cross/users/{username}/blacklist

Example Request

Request Header

  1. Put /v1/cross/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • username: An array of added users
  • appkey: appkey to which the user belongs

Request Body

  1. [{
  2. "appkey":"appkey",
  3. "usernames": [
  4. "test1", "test2"
  5. ]
  6. }]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Cross-application remove blacklist

  1. Delete /v1/cross/users/{username}/blacklist

Example Request

Request Header

  1. Delete /v1/cross/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • username: An array of removed users
  • appkey: appkey to which the user belongs

Request Body

  1. [{
  2. "appkey": "appkey",
  3. "usernames": [
  4. "test1", "test2"
  5. ]
  6. }]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Cross-application list of blacklists

  1. Get /v1/cross/users/{username}/blacklist

Example Request

Request Header

  1. Get /v1/cross/users/{username}/blacklist
  2. Content-Type: application/json; charset=utf-8

Request Params

  • username

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 200
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. [{
  2. "username": "javen",
  3. "nickname": "hello",
  4. "avatar": "/avatar",
  5. "birthday": "1990-01-24 00:00:00",
  6. "gender": 0,
  7. "signature": "orz",
  8. "region": "shenzhen",
  9. "address": "shenzhen",
  10. "mtime": "2015-01-01 00:00:00",
  11. "ctime": "2015-01-01 00:00:00",
  12. "appkey":"appkey"
  13. }]

Cross-application Do-Not-Disturb Settings

  1. POST /v1/cross/users/{username}/nodisturb

Example Request

Request Header

  1. POST /v1/cross/users/{username}/nodisturb
  2. Content-Type: application/json; charset=utf-8

Request Params

  • single: single chat DND, supports adding or removing array (optional)
  • group: group chat DND, supports adding or removing array (optional)
  • appkey: appkey of targets

Request Body

  1. [ {
  2. "appkey":"appkey1","single":{"add":["username1","username2"]},"group":{"add":[110000101],"remove":[1000001111]}
  3. }]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Error Code

  • 899003: username is illegal;
  • 899002: user does not exist
  • 899051: group does not exist
  • 899052: Set the group message blocj and the setting of group block is already open
  • 899053: Set the group message blocj and the setting of group block is already turned off

Add friends across applications

  1. POST /v1/cross/users/{username}/friends

Example Request

Request Header

  1. POST /v1/cross/users/{username}/friends
  2. Content-Type: application/json; charset=utf-8

Request Params

  • appkey: Appkey to which the user belongs (required)
  • json array of users username: up to 500 (required)

Request Body

  1. {
  2. "appkey":"appkey1","users":["username1","username2"]


  3. }

Example Response

Response Header

  1. HTTP/1.1 201 Created
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Delete friends across applications

  1. DELETE /v1/cross/users/{username}/friends

Example Request

Request Header

  1. DELETE /v1/cross/users/{username}/friends
  2. Content-Type: application/json; charset=utf-8

Request Params

  • appkey: The appkey to which the user belongs (required)
  • json array of users username: up to 500 (required)

Request Body

  1. {
  2. "appkey":"appkey1","users":["username1","username2"]

}

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Update friend notes across applications

  1. PUT /v1/cross/users/{username}/friends

Example Request

Request Header

  1. PUT /v1/cross/users/{username}/friends
  2. Content-Type: application/json; charset=utf-8

Request Params

  • appkey: The appkey to which the user belongs (required)
  • note_name: Indicates the list of friends to add. Format: Supported characters of byte(64) excludes “\n” “\r”.
  • others: Other note information, Format: byte(250) supports all characters, including Emoji.

Request Body

  1. [{
  2. "note_name": "new note name",
  3. "others": “好友备注文档" ,
  4. "username":"user01",
  5. "appkey":"appkey"
  6. }]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Cross-application manage chat room members

  1. POST /cross/chatroom/{room_id}/members

Request Params

  • add json array: Representing the user to add to the chat room (optional)
  • remove json array: Indicates the user to delete from the chat room (optional)
  • appkey: appkey to which the managed user belongs (required)

add/remove:at least one of the two

Example Request

  1. [{
  2. "appkey":" 4f7aef34fb361292c566a1cd",
  3. "add": [
  4. "test1",
  5. "test2"
  6. ],
  7. "remove": [
  8. "name3",
  9. "name4"
  10. ]
  11. }]

Example Response

  1. < HTTP/1.1 204 NO Content
  2. < Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Sensitive Words

Add sensitive words

  1. POST /v1/sensitiveword

Example Request

Request Header

  1. POST /v1/sensitiveword
  2. Content-Type: application/json; charset=utf-8

Request Params

  • N/A

Request Body

  • Array of Sensitive Words: A word with a length of up to 10, defaults to 100 sensitive words, and contact with business team for higher demands
  1. ["FUCK"]

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Modify sensitive words

  1. PUT /v1/sensitiveword

Example Request

Request Header

  1. PUT /v1/sensitiveword
  2. Content-Type: application/json; charset=utf-8

Request Params

  • N/A

Request Body

  • old_word: old sensitive word,
  • new_word: new sensitive word
  1. {"new_word":"fuck", "old_word":"FUCK"}

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Delete sensitive words

  1. DELETE /v1/sensitiveword

Example Request

Request Header

  1. DELETE /v1/sensitiveword
  2. Content-Type: application/json; charset=utf-8

Request Params

  • N/A

Request Body

  • word: sensitive words deleted
  1. {"word":"fuck"}

Example Response

Response Header

  1. HTTP/1.1 204 NO Content
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Get a list of sensitive words

  1. GET /v1/sensitiveword

Example Request

Request Header

  1. GET /v1/sensitiveword?start={start}&count={count}
  2. Content-Type: application/json; charset=utf-8

Request Params

  • start: start number, starting from 0
  • count: number of queries, up to 2000

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 200
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. {
  2. "start": 2,
  3. "count": 1,
  4. "words": [
  5. {
  6. "name": "fuck",
  7. "itime": "1970-01-17 16:49:11"
  8. }
  9. ],
  10. "total": 3
  11. }

Update the status of sensitive words

  1. PUT /v1/sensitiveword/status

Example Request

Request Header

  1. PUT /v1/sensitiveword/status?status=0
  2. Content-Type: application/json; charset=utf-8

Request Params

  • status: switch status of sensitive words, 1 means turn on filtering, 0 means turn off sensitive word filtering

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 204
  2. Content-Type: application/json; charset=utf-8

Response Data

  • N/A

Get the status of sensitive words

  1. GET /v1/sensitiveword/status

Example Request

Request Header

  1. GET /v1/sensitiveword/status
  2. Content-Type: application/json; charset=utf-8

Request Params

  • N/A

Request Body

  • N/A

Example Response

Response Header

  1. HTTP/1.1 200
  2. Content-Type: application/json; charset=utf-8

Response Data

  1. {"status": 1}

Overview of chat room fields

Parameter Meaning Limits of character length
name Chat room name (required) Byte(0~64)
owner_username Creator of Chat room (required) Byte (4~128)
description Chat room description (optional) Byte(250)
members_username Member list of chat room (optional)
ctime Creation time
max_member_count Maximum number of members
total_member_count Current total number
flag Forbidden signs 0 means not banned, 1 means open the ban

Chat room maintenance

Create a chat room

  1. POST /v1/chatroom/

Request Body

  1. {"owner_username":"liming", "name": "测试聊天室", "description":"测试", "members_username":[]}

Request Params

  • owner_username (required) owner the chat room
  • name (required) chat room name
  • members_username (optional) username of members
  • description (optional) Description

Example Response

  1. HTTP/1.1 201 Created
  2. Content-Type: application/json
  3. {
  4. "chatroom_id": 1000000
  5. }

Get chat room details

  1. POST /v1/chatroom/batch

Request Params

[10000001,10000002] roomid数组

Example Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8
  3. [
  4. {
  5. "id": 10000001,
  6. "owner_username": "xiaoming",
  7. "max_member_count": 10000,
  8. "appkey": "4f7aef34fb361292c566a1cd",
  9. "name": "test",
  10. "description": "test",
  11. "total_member_count": 2,
  12. "ctime": "2017-11-27 18:38:25"
  13. },
  14. {
  15. "id": 10000002,
  16. "owner_username": "xiaoming",
  17. "max_member_count": 10000,
  18. "appkey": "4f7aef34fb361292c566a1cd",
  19. "name": "test",
  20. "description": "test",
  21. "total_member_count": 2,
  22. "ctime": "2017-11-27 18:38:25"
  23. }
  24. ]

GET Get a list of user’s chat rooms

  1. GET /v1/users/{username}/chatroom

Example Request

  1. GET /v1/users/xiaoming/chatroom

Example Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8
  3. [
  4. {
  5. "id": 100000,
  6. "owner_username": "xiaoming",
  7. "max_member_count": 10000,
  8. "appkey": "4f7aef34fb361292c566a1cd",
  9. "name": "test",
  10. "description": "test",
  11. "total_member_count": 2
  12. "ctime": "2017-11-27 18:38:25"
  13. },
  14. {
  15. "id": 10000001,
  16. "owner_username": "xiaoming",
  17. "max_member_count": 10000,
  18. "appkey": "4f7aef34fb361292c566a1cd",
  19. "name": "test",
  20. "description": "test",
  21. "total_member_count": 2
  22. "ctime": "2017-11-27 18:38:25"
  23. }
  24. ]

GET Get a list of chat rooms under the app

  1. GET /v1/chatroom?start={start}&count={count}

Example Request

  1. GET /v1/chatroom?start=0&count=10

Example Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8
  3. {
  4. "total": 1,
  5. "rooms": [
  6. {
  7. "id": 62,
  8. "owner_username": "xiaoming",
  9. "max_member_count": 10000,
  10. "appkey": "4f7aef34fb361292c566a1cd",
  11. "name": "test",
  12. "description": "test"
  13. total_member_count": 11,
  14. "ctime": "2017-11-27 18:38:25"
  15. }
  16. ],
  17. "start": 0,
  18. "count": 1
  19. }

Update chat room information

  1. PUT /v1/chatroom/{room_id}

Example Request

  1. PUT /v1/chatroom/111000001

Request Body

  1. {"owner_username":"135380113231", "name": "中国人", "description":"说什么来这"}

Example Response

  1. HTTP/1.1 204
  2. Content-Type: application/json; charset=utf-8

Delete chat room

  1. DELETE /v1/chatroom/{room_id}

Example Request

  1. DELETE /v1/chatroom/100000

Example Response

  1. HTTP/1.1 204
  2. Content-Type: application/json; charset=utf-8

Modify user banned state

  1. PUT /v1/chatroom/{room_id}/forbidden/{username}?status={status}

Status 0 means not banned, 1 means open the ban (required)

Example Request

  1. PUT /v1/chatroom/100000/forbidden/caiyh?status=1

Example Response

  1. HTTP/1.1 204 OK
  2. Content-Type: application/json; charset=utf-8

Get a list of chat room members

  1. GET /v1/chatroom/{room_id}/members?start={start}&count={count}

Request Params

  • room_id

Example Response

  • username
  • ctime
  • flag
  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. {
  4. "total": 2,
  5. "users": [
  6. {
  7. "username": "13538013231",
  8. "flag": 0,
  9. "room_ctime": "2017-11-17 08:57:54",
  10. "mtime": "2017-10-30 17:24:17",
  11. "ctime": "2017-10-30 17:24:17"
  12. },
  13. {
  14. "username": "xia_12",
  15. "flag": 0,
  16. "room_ctime": "2017-11-16 19:13:07",
  17. "mtime": "2017-02-08 17:56:04",
  18. "ctime": "2017-02-08 17:56:04"
  19. }
  20. ],
  21. "count": 2,
  22. "start": 0
  23. }

Add chat room members

  1. PUT /v1/chatroom/{room_id}/members

Request Params

  • json array of username: supports up to 3000

Example Response

  1. HTTP/1.1 204
  2. Content-Type: application/json; charset=utf-8

Remove chat room members

  1. DELETE /v1/chatroom/{room_id}/members

Request Params

  • json array of username: supports up to 3000

Example Response

  1. HTTP/1.1 204
  2. Content-Type: application/json; charset=utf-8

Configuration

Set SDK-API user registration switch

Open or close the SDK-API user registration.

  1. PUT /sdkregister/status?status={status}

Example Request

  1. PUT /sdkregister/status?status=0

Request Params

JSON Array.

  • status:0 is off, indicating SDK-API registration is not provided, 1 is on

Example Response

  1. HTTP/1.1 204 Created
  2. Content-Type: application/json
  3. Response Data
  4. N/A

Get SDK-API user registration switch

  1. get /sdkregister/status

Example Request

  1. get /sdkregister/status

Example Response

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. Response Data
  4. {
  5. "status": 0
  6. }
  7. status 0为关闭,不提供SDK-API 注册功能,1为开启

HTTP return

Reference documentation of HTTP return code: HTTP-Status-Code

Example Error Response

  1. HTTP/1.1 401 Unauthorized
  2. Content-Type: application/json
  3. {
  4. "error": {
  5. "code": 899008,
  6. "message": "Basic authentication failed"
  7. }
  8. }

Definition of business error code

IM Server ErrorCode