{
  "name": "LanXin IM API",
  "version": "1.0.0",
  "basePath": "/api/v1",
  "authentication": {
    "tokenEndpoint": {
      "method": "POST",
      "path": "/im/auth/token",
      "body": ["appKey", "appSecret", "userId"],
      "response": ["token", "tokenType", "expiresIn", "userId"],
      "serverSideOnly": true,
      "warning": "appSecret must never be sent to a browser"
    },
    "authenticatedRequests": {
      "header": "X-Token",
      "alternative": "Authorization: Bearer <token>"
    }
  },
  "responseEnvelope": {
    "success": { "code": 0, "msg": "成功", "data": {} },
    "error": { "code": 40001, "msg": "错误说明", "data": null }
  },
  "endpoints": [
    { "id": "auth.token", "method": "POST", "path": "/im/auth/token", "body": ["appKey", "appSecret", "userId"], "auth": false, "serverSideOnly": true },
    { "id": "user.register", "method": "POST", "path": "/im/users/register", "body": ["userId", "nickname?", "avatarUrl?", "profile?"], "auth": true },
    { "id": "user.get", "method": "GET", "path": "/im/users/:userId", "auth": true },
    { "id": "user.update", "method": "PATCH", "path": "/im/users/profile", "body": ["nickname?", "avatarUrl?", "profile?"], "auth": true },

    { "id": "friend.applications", "method": "GET", "path": "/im/friends/applications", "query": ["status?", "limit?"], "auth": true },
    { "id": "friend.apply", "method": "POST", "path": "/im/friends/applications", "body": ["userId", "message?"], "auth": true },
    { "id": "friend.accept", "method": "POST", "path": "/im/friends/applications/:id/accept", "auth": true },
    { "id": "friend.refuse", "method": "POST", "path": "/im/friends/applications/:id/refuse", "auth": true },
    { "id": "friend.list", "method": "GET", "path": "/im/friends", "query": ["limit?"], "auth": true },
    { "id": "friend.remove", "method": "DELETE", "path": "/im/friends/:userId", "auth": true },

    { "id": "blacklist.list", "method": "GET", "path": "/im/blacklist", "query": ["limit?"], "auth": true },
    { "id": "blacklist.add", "method": "POST", "path": "/im/blacklist", "body": ["userId"], "auth": true },
    { "id": "blacklist.remove", "method": "DELETE", "path": "/im/blacklist/:userId", "auth": true },

    { "id": "conversation.list", "method": "GET", "path": "/im/conversations", "query": ["limit?"], "auth": true },
    { "id": "conversation.get", "method": "GET", "path": "/im/conversations/:conversationNo", "auth": true },
    { "id": "conversation.hide", "method": "DELETE", "path": "/im/conversations/:conversationNo", "auth": true },
    { "id": "conversation.read", "method": "POST", "path": "/im/conversations/:conversationNo/read", "body": ["messageNo?"], "auth": true },

    { "id": "group.create", "method": "POST", "path": "/im/groups", "body": ["name", "memberIds?", "avatarUrl?", "maxMembers?", "joinMode?", "announcement?", "settings?"], "auth": true },
    { "id": "group.update", "method": "PATCH", "path": "/im/groups/:no", "body": ["name?", "avatarUrl?", "announcement?", "joinMode?", "maxMembers?", "settings?"], "auth": true },
    { "id": "group.disband", "method": "POST", "path": "/im/groups/:no/disband", "auth": true },
    { "id": "group.addMembers", "method": "POST", "path": "/im/groups/:no/members", "body": ["userIds"], "auth": true },
    { "id": "group.removeMember", "method": "DELETE", "path": "/im/groups/:no/members/:userId", "auth": true },
    { "id": "group.quit", "method": "POST", "path": "/im/groups/:no/quit", "auth": true },

    { "id": "message.send", "method": "POST", "path": "/im/messages", "body": ["conversationNo|toUserId", "type", "content", "clientMessageId?", "replyToMessageNo?", "searchText?"], "auth": true },
    { "id": "message.history", "method": "GET", "path": "/im/messages/history/:conversationNo", "query": ["beforeSequence?", "limit?"], "auth": true },
    { "id": "message.search", "method": "GET", "path": "/im/messages/search", "query": ["q", "limit?"], "auth": true },
    { "id": "message.revoke", "method": "POST", "path": "/im/messages/:messageNo/revoke", "auth": true },
    { "id": "message.read", "method": "POST", "path": "/im/messages/:messageNo/read", "auth": true },
    { "id": "message.delete", "method": "DELETE", "path": "/im/messages/:messageNo", "auth": true },
    { "id": "upload", "method": "POST", "path": "/im/upload", "contentType": "multipart/form-data", "body": ["file"], "auth": true },
    { "id": "broadcast", "method": "POST", "path": "/im/broadcast", "body": ["eventType?", "payload?"], "auth": true }
  ],
  "messageTypes": ["text", "image", "file", "audio", "video", "location", "card", "custom"],
  "websocket": {
    "upgradeUrl": "wsUrl?token=<X-Token>",
    "authenticationTiming": "HTTP upgrade",
    "postOpenAuthMessage": false,
    "incomingEnvelope": { "event": "message.created", "payload": {} },
    "clientMessages": [
      { "type": "ping" },
      { "type": "subscribe", "conversations": ["c_123"] },
      { "type": "unsubscribe", "conversations": ["c_123"] }
    ],
    "pong": { "event": "pong", "timestamp": 0 }
  },
  "webhooks": {
    "headers": ["Content-Type: application/json", "X-IM-Event", "X-IM-Event-Id"],
    "signed": false,
    "timeoutSeconds": 10,
    "maxAttempts": 8,
    "successStatus": "2xx"
  },
  "limits": {
    "normalRequestsPerIpRouteMinute": 300,
    "tokenRequestsPerIpRouteMinute": 20,
    "maximumPageSize": 100,
    "maximumUploadBytesDefault": 104857600
  }
}
