Mixin Developer

Create a GROUP or CONTACT conversation.

POST /conversations
category String: “GROUP” or “CONTACT”
conversation_id String: UUID, generated by client, notice if category is “CONTACT” you much use “UniqueConversationId” to generate.
participants JSON Array, contains action, role, user_id
action String: “ADD”, “REMOVE”, “JOIN”, “EXIT”, “ROLE”
role String: “” or “ADMIN”
user_id String: UUID

Normal UUID for a “GROUP” conversation, but unique UUID for “CONTACT” conversation.

 func UniqueConversationId(userId, recipientId string) string {
    minId, maxId := userId, recipientId
    if strings.Compare(userId, recipientId) > 0 {
      maxId, minId = userId, recipientId
    }
    h := md5.New()
    io.WriteString(h, minId)
    io.WriteString(h, maxId)
    sum := h.Sum(nil)
    sum[6] = (sum[6] & 0x0f) | 0x30
    sum[8] = (sum[8] & 0x3f) | 0x80
    return uuid.FromBytesOrNil(sum).String()
  }
// cURL Example
curl -i -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MzQyNTAwNTYsImlhdCI6MTUyNjQ3NDA1NiwianRpIjoiMmUyMTFmMmQtOTNmZC00ODBiLWIxMDctZGNmMzg3NTZmZDdhIiwic2lkIjoiMTM4NDMyNmQtMTQzNi00NWI2LWI3NGQtY2ZhNjNkNDM2ZmRmIiwic2lnIjoiODZhMWYxMmFhYjQ0MGE5NmM3NWM1NmY2ZDI2Mzk3NTIxNWJlZDE2YjI4YmYxZTk4MTc4NGRjODVhNzc2M2I2OSIsInVpZCI6IjhkY2Y4MjNkLTllYjMtNGRhMi04NzM0LWYwYWFkNTBjMGRhNiJ9.b8jI-GwGqQhOu2B1vMtB5zox8O9OAuzrHZssw8LtLhTdMnskut3zi0WWkiUPQ8gyTGxzIUlkQC1gFOR0Ul4adZHaGGQ9T77RQecpEnDBGA26zdWCn2IygKDCjOEO-i9xHa8uNCqPLhyEdShSEZk3dEFiw0eZ2fjbyWiVzRKupwo" "https://api.mixin.one/conversations" -X POST --data '{"category":"GROUP","conversation_id":"928c5c40-769c-3e97-8387-fb1ae0645311","participants":[{"action":"ADD","role":"","user_id":"e8e5b807-fa8b-455a-8dfa-b189d28310ff"}]}'
// Sample Response
{  
  "data":{  
    "type":"conversation",
      "conversation_id":"928c5c40-769c-3e97-8387-fb1ae0645311",
      "creator_id":"8dcf823d-9eb3-4da2-8734-f0aad50c0da6",
      "category":"GROUP",
      "name":"",
      "icon_url":"",
      "announcement":"",
      "created_at":"2018-05-16T12:34:44.134238105Z",
      "code_id":"d8244b92-30e9-44b5-bfb0-ce597c788125",
      "code_url":"https://mixin.one/codes/d8244b92-30e9-44b5-bfb0-ce597c788125",
      "mute_until":"2018-05-16T12:34:44.143010035Z",
      "participants":[  
      {  
        "type":"participant",
        "user_id":"8dcf823d-9eb3-4da2-8734-f0aad50c0da6",
        "role":"OWNER",
        "created_at":"2018-05-16T12:34:44.134238105Z"
      },
      {  
        "type":"participant",
        "user_id":"e8e5b807-fa8b-455a-8dfa-b189d28310ff",
        "role":"",
        "created_at":"2018-05-16T12:34:44.149277666Z"
      }
      ]
  }
}