채널 생성

Create Channel

POST https://api.talkplus.io/v1.4/api/channels/create

  • data의 경우, 최대 5개의 key-value pair를 입력할 수 있습니다. key의 최대 size는 128자 이고 최대 value size는 1024자입니다. Key, value 둘 다 문자열이어야 합니다.

Headers

Request Body

{
  "channel": {
    "id": "channel123",
    "name": "MyFirstChannel",
    "ownerId": "user123",
    "type": "private",
    "imageUrl": "image url",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "privateTag": "",
    "privateData": "",
    "memberCount": 2,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "john",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "data": {},
        "memberInfo": {},
        "lastReadAt": 1583924400,
        "lastSentAt": 1583924400,
        "updatedAt": 1583924400,
        "createdAt": 1583921400
      },
      {
        "id": "user456",
        "username": "james",
        "profileImageUrl": "http://cnd.test.com/456.jpg",
        "data": {},
        "memberInfo": {},
        "lastReadAt": 1583924400,
        "lastSentAt": 1583924400,
        "updatedAt": 1583924400,
        "createdAt": 1583921400
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 1583924400,
    "createdAt": 1583921400,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": {
      "id": "sdf2l5s9j",
      "channelId": "channel123",
      "userId": "user456",
      "username": "myUsername",
      "profileImageUrl": "http://cdn.test.com/123.jpg",
      "type": "message",
      "text": "Hello world",
      "translations": {},
      "data": {
        "customField": "customData"
      },
      "createdAt": 1583921400
    }
  }
}

  • 채널 타입의 경우 private, public, invitationOnly, broadcast, super_broadcast, super_private, super_public 타입을 지원합니다.

  • type members 필드는 필수 입니다.

  • ownerId 필드는 실제로 존재하는 사용자 ID를 넣어야 합니다. (대시보드의 어드민 계정의 ID는 여기에 사용할 수 없습니다)

  • invitationOnly 타입의 경우 invitationCode도 추가적으로 필수 필드입니다.

  • PRIVATE 타입의 경우 채널 id와 참여 사용자(targetIds)가 동일한 경우 reuseChannel 파라미터를 true로 설정하여 기존 생성된 채널을 재사용할 수 있습니다. 이는 1:1 대화를 구현하는데 유용하게 사용할 수 있습니다.

  • PUBLIC, SUPER_PUBLIC 타입 채널에 ban당하지 않은 사용자는 누구나 가입할 수 있습니다.

  • INVITATION_ONLY 타입의 경우 invitationCode를 제공해야 채널 가입이 가능합니다.

  • BROADCAST, SUPER_BROADCAST 타입의 경우:

    • 채널 owner가 메시지 발송 시 채널 멤버 모두에게 메시지가 발송됩니다.

    • 채널 owner가 아닌 채널 멤버가 메시지 발송 시 채널 owner에게만 메시지가 전달됩니다.

    • 채널 생성 시, ownerId를 반드시 지정해 주어야 합니다.

  • SUPER_BROADCAST, SUPER_PRIVATE, SUPER_PUBLIC 타입의 경우,

    • 최대 멤버 제한수를 100명 이상으로 설정할 수 있습니다.

    • 최대 멤버 제한수를 -1로 설정하면 멤버를 무제한으로 추가할 수 있습니다.

    • members와 bannedUsers 필드에 사용자 정보가 채워져서 내려오는 일반 채널과 달리:

      • members와 bannedUsers 필드는 빈 상태로 내려옵니다.

SUPER 채널 타입 예제

{
  "channel": {
    "id": "channel123",
    "name": "MyFirstChannel",
    "ownerId": "user123",
    "type": "private",
    "imageUrl": "image url",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "privateTag": "",
    "privateData": "",
    "memberCount": 2,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "updatedAt": 1583924400,
    "createdAt": 1583921400,
    "unreadCount": 1,
    "lastReadAt": 1583914400,
    "lastMessage": {
      "id": "sdf2l5s9j",
      "channelId": "channel123",
      "userId": "user456",
      "username": "myUsername",
      "profileImageUrl": "http://cdn.test.com/123.jpg",
      "type": "message",
      "text": "Hello world",
      "translations": {},
      "data": {
        "customField": "customData"
      },
      "reactions": {"happy": ["user1"]},
      "createdAt": 1583921400
    }
  }
}

Last updated