> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Membuat obrolan grup

> Panggil API ini untuk membuat Grup Internal dan Grup Standar dengan cepat pada skenario pembuatan grup massal di perusahaan, lengkap dengan parameter permintaan dan referensi bidang respons.

Panggil API ini untuk membuat obrolan Grup Internal atau Grup Standar. Ini cocok untuk skenario ketika organisasi perlu membuat obrolan grup dengan cepat.

## Deskripsi panggilan API

Secara default, API ini hanya mendukung pembuatan Grup Internal. Untuk membuat Grup Standar, hubungi dukungan teknis agar aplikasi Anda ditambahkan ke daftar izin.

## Permintaan

### Informasi dasar

| Bidang                      | Nilai                                                                                        |
| --------------------------- | -------------------------------------------------------------------------------------------- |
| URL HTTP                    | [https://api.dingtalk.io/v1.0/im/group/create](https://api.dingtalk.io/v1.0/im/group/create) |
| Metode HTTP                 | POST                                                                                         |
| Tipe aplikasi yang didukung | appType-Aplikasi internal                                                                    |
| Izin yang diperlukan        | permission-qyapi\_chat\_manage-Izin pengelolaan informasi dasar grup DingTalk                |

### Header permintaan

| Nama                        | Tipe   | Wajib | Deskripsi                                                                                                                                                                                    |
| --------------------------- | ------ | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| x-acs-dingtalk-access-token | String | Ya    | Kredensial akses yang digunakan untuk memanggil API ini. Dapatkan melalui API [Mendapatkan access token aplikasi internal](/id/open/development/obtain-the-access-token-of-an-internal-app). |

### Isi permintaan

| Nama                | Tipe            | Wajib | Deskripsi                                                                                                                                                                                                |
| ------------------- | --------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name                | String          | Ya    | Nama grup. Panjangnya harus 1 hingga 20 karakter.                                                                                                                                                        |
| owner               | String          | Ya    | userId dari pemilik grup. Dapatkan userId melalui API Get user by mobile number.                                                                                                                         |
| ownerType           | String          | Tidak | Tipe pemilik grup.   - **emp**: Karyawan organisasi - **ext**: Kontak eksternal                                                                                                                          |
| useridlist          | Array of String | Ya    | StaffId dari para pengguna.                                                                                                                                                                              |
| conversationTag     | Long            | Tidak | Tag tipe percakapan. Default-nya adalah Grup Internal. Untuk membuat Grup Standar, hubungi dukungan teknis agar aplikasi Anda ditambahkan ke daftar izin.   - **0**: Grup Standar - **2**: Grup Internal |
| extidlist           | Array of String | Tidak | Kontak eksternal.                                                                                                                                                                                        |
| icon                | String          | Tidak | Foto profil grup. Berikan mediaId, yang dapat diperoleh melalui API [Mengunggah file media](/id/open/development/upload-media-files).                                                                    |
| managementOptions   | Object          | Tidak | Atribut tambahan untuk membuat grup.                                                                                                                                                                     |
| mentionAllAuthority | Integer         | Tidak | Cakupan penggunaan @all.   - **0** (default): Semua orang dapat menggunakannya. - **1**: Hanya pemilik grup yang dapat menggunakan @all.                                                                 |
| showHistoryType     | Integer         | Tidak | Apakah pengguna baru dapat melihat 100 pesan historis terbaru. Jika tidak diberikan, mereka tidak dapat melihatnya.   - **1**: Dapat melihat. - **0**: Tidak dapat melihat.                              |
| validationType      | Integer         | Tidak | Apakah diperlukan verifikasi untuk bergabung ke grup. - **0** (default): Tanpa verifikasi.   - **1**: Verifikasi diperlukan.                                                                             |
| searchable          | Integer         | Tidak | Apakah grup dapat dicari. - **0** (default): Tidak dapat dicari.   - **1**: Dapat dicari.                                                                                                                |
| chatBannedType      | Integer         | Tidak | Apakah akan membisukan anggota di dalam grup.   - **0** (default): Jangan bisukan. - **1**: Bisukan Semua.                                                                                               |
| managementType      | Integer         | Tidak | Tipe Kelola Grup.   - **0** (default): Semua orang dapat mengelola. - **1**: Hanya pemilik grup yang dapat mengelola.                                                                                    |

### Contoh permintaan

HTTP

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
POST /v1.0/im/group/create HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:xxxxx
Content-Type:application/json

{
  "name" : "Grup Uji",
  "owner" : "manager4220",
  "ownerType" : "emp",
  "useridlist" : [ "userId" ],
  "conversationTag" : 2,
  "extidlist" : [ "unionId" ],
  "icon" : "@mediaId",
  "managementOptions" : {
    "mentionAllAuthority" : 0,
    "showHistoryType" : 0,
    "validationType" : 0,
    "searchable" : 0,
    "chatBannedType" : 0,
    "managementType" : 0
  }
}
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>Initialize the account client with the Token</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.dingtalkim_1_0.Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkim_1_0.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.dingtalkim_1_0.Client client = Sample.createClient();
        com.aliyun.dingtalkim_1_0.models.CreateGroupHeaders createGroupHeaders = new com.aliyun.dingtalkim_1_0.models.CreateGroupHeaders();
        createGroupHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkim_1_0.models.CreateGroupRequest.CreateGroupRequestManagementOptions managementOptions = new com.aliyun.dingtalkim_1_0.models.CreateGroupRequest.CreateGroupRequestManagementOptions()
                .setMentionAllAuthority(0)
                .setShowHistoryType(0)
                .setValidationType(0)
                .setSearchable(0)
                .setChatBannedType(0)
                .setManagementType(0);
        com.aliyun.dingtalkim_1_0.models.CreateGroupRequest createGroupRequest = new com.aliyun.dingtalkim_1_0.models.CreateGroupRequest()
                .setName("Test Group")
                .setOwner("manager4220")
                .setOwnerType("emp")
                .setUseridlist(java.util.Arrays.asList(
                    "userId"
                ))
                .setConversationTag(2L)
                .setExtidlist(java.util.Arrays.asList(
                    "unionId"
                ))
                .setIcon("@mediaId")
                .setManagementOptions(managementOptions);
        try {
            client.createGroupWithOptions(createGroupRequest, createGroupHeaders, new com.aliyun.teautil.models.RuntimeOptions());
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err berisi atribut code dan message untuk membantu menemukan issue
            }

        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err berisi atribut code dan message untuk membantu menemukan issue
            }

        }        
    }
}
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys
import json

from typing import List

from alibabacloud_dingtalk.im_1_0.client import Client as dingtalkim_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.im_1_0 import models as dingtalkim__1__0_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> dingtalkim_1_0Client:
        """
        Initialize the account client with the Token
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.protocol = 'https'
        config.region_id = 'central'
        return dingtalkim_1_0Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        create_group_headers = dingtalkim__1__0_models.CreateGroupHeaders()
        create_group_headers.x_acs_dingtalk_access_token = '<your access token>'
        management_options = dingtalkim__1__0_models.CreateGroupRequestManagementOptions(
            mention_all_authority=0,
            show_history_type=0,
            validation_type=0,
            searchable=0,
            chat_banned_type=0,
            management_type=0
        )
        create_group_request = dingtalkim__1__0_models.CreateGroupRequest(
            name='Test Group',
            owner='manager4220',
            owner_type='emp',
            useridlist=[
                'userId'
            ],
            conversation_tag=2,
            extidlist=[
                'unionId'
            ],
            icon='@mediaId',
            management_options=management_options
        )
        try:
            client.create_group_with_options(create_group_request, create_group_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err berisi atribut code dan message untuk membantu menemukan issue
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        create_group_headers = dingtalkim__1__0_models.CreateGroupHeaders()
        create_group_headers.x_acs_dingtalk_access_token = '<your access token>'
        management_options = dingtalkim__1__0_models.CreateGroupRequestManagementOptions(
            mention_all_authority=0,
            show_history_type=0,
            validation_type=0,
            searchable=0,
            chat_banned_type=0,
            management_type=0
        )
        create_group_request = dingtalkim__1__0_models.CreateGroupRequest(
            name='Test Group',
            owner='manager4220',
            owner_type='emp',
            useridlist=[
                'userId'
            ],
            conversation_tag=2,
            extidlist=[
                'unionId'
            ],
            icon='@mediaId',
            management_options=management_options
        )
        try:
            await client.create_group_with_options_async(create_group_request, create_group_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err berisi atribut code dan message untuk membantu menemukan issue
                pass

if __name__ == '__main__':
    Sample.main(sys.argv[1:])
```

PHP

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dingtalk\Vim_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vim_1_0\Models\CreateGroupHeaders;
use AlibabaCloud\SDK\Dingtalk\Vim_1_0\Models\CreateGroupRequest\managementOptions;
use AlibabaCloud\SDK\Dingtalk\Vim_1_0\Models\CreateGroupRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * Initialize the account client with the Token
     * @return Dingtalk Client
     */
    public static function createClient(){
        $config = new Config([]);
        $config->protocol = "https";
        $config->regionId = "central";
        return new Dingtalk($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $createGroupHeaders = new CreateGroupHeaders([]);
        $createGroupHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $managementOptions = new managementOptions([
            "mentionAllAuthority" => 0,
            "showHistoryType" => 0,
            "validationType" => 0,
            "searchable" => 0,
            "chatBannedType" => 0,
            "managementType" => 0
        ]);
        $createGroupRequest = new CreateGroupRequest([
            "name" => "Test Group",
            "owner" => "manager4220",
            "ownerType" => "emp",
            "useridlist" => [
                "userId"
            ],
            "conversationTag" => 2,
            "extidlist" => [
                "unionId"
            ],
            "icon" => "@mediaId",
            "managementOptions" => $managementOptions
        ]);
        try {
            $client->createGroupWithOptions($createGroupRequest, $createGroupHeaders, new RuntimeOptions([]));
        }
        catch (Exception $err) {
            if (!($err instanceof TeaError)) {
                $err = new TeaError([], $err->getMessage(), $err->getCode(), $err);
            }
            if (!Utils::empty_($err->code) && !Utils::empty_($err->message)) {
                // err berisi atribut code dan message untuk membantu menemukan issue
            }
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
```

Go

```go theme={"theme":{"light":"github-light","dark":"github-dark"}}
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  dingtalkim_1_0  "github.com/alibabacloud-go/dingtalk/im_1_0"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/tea/tea"
)

// Description:
// 
// Initialize the account client with the Token
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *dingtalkim_1_0.Client, _err error) {
  config := &openapi.Config{}
  config.Protocol = tea.String("https")
  config.RegionId = tea.String("central")
  _result = &dingtalkim_1_0.Client{}
  _result, _err = dingtalkim_1_0.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  createGroupHeaders := &dingtalkim_1_0.CreateGroupHeaders{}
  createGroupHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  managementOptions := &dingtalkim_1_0.CreateGroupRequestManagementOptions{
    MentionAllAuthority: tea.Int32(0),
    ShowHistoryType: tea.Int32(0),
    ValidationType: tea.Int32(0),
    Searchable: tea.Int32(0),
    ChatBannedType: tea.Int32(0),
    ManagementType: tea.Int32(0),
  }
  createGroupRequest := &dingtalkim_1_0.CreateGroupRequest{
    Name: tea.String("Test Group"),
    Owner: tea.String("manager4220"),
    OwnerType: tea.String("emp"),
    Useridlist: []*string{tea.String("userId")},
    ConversationTag: tea.Int64(2),
    Extidlist: []*string{tea.String("unionId")},
    Icon: tea.String("@mediaId"),
    ManagementOptions: managementOptions,
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.CreateGroupWithOptions(createGroupRequest, createGroupHeaders, &util.RuntimeOptions{})
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var err = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      err = _t
    } else {
      err.Message = tea.String(tryErr.Error())
    }
    if !tea.BoolValue(util.Empty(err.Code)) && !tea.BoolValue(util.Empty(err.Message)) {
      // err berisi atribut code dan message untuk membantu menemukan issue
    }

  }
  return _err
}

func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
```

Node.js

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
'use strict';
// This file is auto-generated, don't edit it
const Util = require('@alicloud/tea-util');
const dingtalkim_1_0 = require('@alicloud/dingtalk/im_1_0');
const OpenApi = require('@alicloud/openapi-client');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * Initialize the account client with the Token
   * @return Client
   * @throws Exception
   */
  static createClient() {
    let config = new OpenApi.Config({ });
    config.protocol = 'https';
    config.regionId = 'central';
    return new dingtalkim_1_0.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let createGroupHeaders = new dingtalkim_1_0.CreateGroupHeaders({ });
    createGroupHeaders.xAcsDingtalkAccessToken = '<your access token>';
    let managementOptions = new dingtalkim_1_0.CreateGroupRequestManagementOptions({
      mentionAllAuthority: 0,
      showHistoryType: 0,
      validationType: 0,
      searchable: 0,
      chatBannedType: 0,
      managementType: 0,
    });
    let createGroupRequest = new dingtalkim_1_0.CreateGroupRequest({
      name: 'Test Group',
      owner: 'manager4220',
      ownerType: 'emp',
      useridlist: [
        'userId'
      ],
      conversationTag: 2,
      extidlist: [
        'unionId'
      ],
      icon: '@mediaId',
      managementOptions: managementOptions,
    });
    try {
      await client.createGroupWithOptions(createGroupRequest, createGroupHeaders, new Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.default.empty(err.code) && !Util.default.empty(err.message)) {
        // err berisi atribut code dan message untuk membantu menemukan issue
      }

    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
```

C#

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /// <term><b>Description:</b></term>
        /// <description>
        /// <para>Initialize the account client with the Token</para>
        /// </description>
        /// 
        /// <returns>
        /// Client
        /// </returns>
        /// 
        /// <term><b>Exception:</b></term>
        /// Exception
        public static AlibabaCloud.SDK.Dingtalkim_1_0.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
            config.Protocol = "https";
            config.RegionId = "central";
            return new AlibabaCloud.SDK.Dingtalkim_1_0.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dingtalkim_1_0.Client client = CreateClient();
            AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupHeaders createGroupHeaders = new AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupHeaders();
            createGroupHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupRequest.CreateGroupRequestManagementOptions managementOptions = new AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupRequest.CreateGroupRequestManagementOptions
            {
                MentionAllAuthority = 0,
                ShowHistoryType = 0,
                ValidationType = 0,
                Searchable = 0,
                ChatBannedType = 0,
                ManagementType = 0,
            };
            AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupRequest createGroupRequest = new AlibabaCloud.SDK.Dingtalkim_1_0.Models.CreateGroupRequest
            {
                Name = "Test Group",
                Owner = "manager4220",
                OwnerType = "emp",
                Useridlist = new List<string>
                {
                    "userId"
                },
                ConversationTag = 2,
                Extidlist = new List<string>
                {
                    "unionId"
                },
                Icon = "@mediaId",
                ManagementOptions = managementOptions,
            };
            try
            {
                client.CreateGroupWithOptions(createGroupRequest, createGroupHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
            }
            catch (TeaException err)
            {
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err berisi atribut code dan message untuk membantu menemukan issue
                }
            }
            catch (Exception _err)
            {
                TeaException err = new TeaException(new Dictionary<string, object>
                {
                    { "message", _err.Message }
                });
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err berisi atribut code dan message untuk membantu menemukan issue
                }
            }
        }

    }
}
```

## Respons

### Isi respons

| Nama               | Tipe   | Deskripsi                                                 |
| ------------------ | ------ | --------------------------------------------------------- |
| conversationTag    | Long   | Tipe grup:   - **0**: Grup Standar - **2**: Grup Internal |
| openConversationId | String | ID obrolan grup.                                          |
| chatid             | String | ID obrolan grup. Ini adalah bidang parameter lama.        |

### Contoh isi respons

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
Content-Type:application/json

{
  "conversationTag" : 2,
  "openConversationId" : "14da****2760",
  "chatid" : "chatxxxx"
}
```

### Kode error

Jika terjadi error saat memanggil API ini, cari solusinya di dokumen [Kode error global](/id/open/development/server-api-error-codes-1) berdasarkan pesan error.

| HttpCode | Kode error             | Pesan error                                            | Deskripsi                                                     |
| -------- | ---------------------- | ------------------------------------------------------ | ------------------------------------------------------------- |
| 400      | parameter.invalid      | Invalid input parameter                                | Berikan parameter wajib sesuai ketentuan API.                 |
| 400      | permession.checkFailed | Permission check failed                                | Pemeriksaan izin gagal.                                       |
| 400      | permession.checkFailed | The group owner is not within the app visibility scope | Pemilik grup tidak berada dalam cakupan visibilitas aplikasi. |
| 500      | system.error           | Try again. If it always fails, submit a ticket         | Coba lagi. Jika selalu gagal, kirim tiket.                    |
