直达内容

批量发送加密消息

POST /encrypted_messages

批量创建加密消息接口

信息
  1. 最多创建 100 条消息
  2. 兼容不加密消息

API 端点 URL

 https://api.mixin.one/encrypted_messages

授权和其他选项

授权
Authorized
限制No limitation

请求体

[
{ message object },
{ message object },
...
]
信息

message object 是 JSON 结构, 请参照里面的类型 Message Category.

请求示例

curl -i -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" https://api.mixin.one/encrypted_messages --data PAYLOAD

请求返回值是一个数组, 如果 state 是 FAILED, sessions 会返回正确的数组值:

Response
{
"data": [
{
"type": "message",
"message_id": "43d61dcd-e413-450d-80b8-101d5e903357",
"recipient_id": "43d61dcd-e413-450d-80b8-101d5e903357",
"state": "SUCCESS", // SUCCESS or FAILED
"sessions": [
{
"type": "session",
"session_id": "43d61dcd-e413-450d-80b8-101d5e903357",
"public_key": "Axajf..EXfa",
},
]
},
...
]
}

加密数据的格式

  version || session size || sender public key || encrypted message key for receiver session 1 || encrypted message key for receiver session 2 || nonce || encrypted message data
  1. version 1 byte and session size (2 bytes) in LittleEndian format,
  2. sender public key is bot's curve25519 public key
  3. encrypted message key for receiver session = session id || AESCBC(message key, shared secret key, iv)
  4. shared secret key = ECDH(sender private key, receiver session public key)
  5. message key uses to encrypt the message data