> ## 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.

# 社内グループ管理者の一括設定

> 組織構成の変更に伴い、グループ管理者を再設定する場合などに利用します。

本インターフェースを呼び出すことで、社内グループ内のユーザーを一括で管理者に設定したり、一括で管理者権限を解除したりできます。本インターフェースは、社内グループの規模が大きく、管理効率を高めるためにグループ管理者を一括で調整する必要があるシーン、または組織構成の変更に伴いグループ管理者を再設定する必要があるシーンに適しています。

## 権限

この API を呼び出すには、以下のいずれかの権限が必要です。

| アプリタイプ       | 対応可否 | 権限                       | API Explorer デバッグ                                                                                       |
| ------------ | ---- | ------------------------ | ------------------------------------------------------------------------------------------------------- |
| 社内アプリ        | 対応   | DingTalk グループベーシック情報管理権限 | [API Explorer](https://open-dev.dingtalk.io/apiExplorer#/?devType=org\&api=im_1.0%23ChatSubAdminUpdate) |
| サードパーティ社内アプリ | 未対応  | 未対応                      | 未対応                                                                                                     |
| サードパーティ個人アプリ | 未対応  | 未対応                      | 未対応                                                                                                     |

## HTTP メソッド

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

{
  "openConversationId" : "String",
  "userIds" : [ "String" ],
  "role" : Integer
}
```

## Header パラメータ

| 名前                          | タイプ    | 必須 | 説明                                                                                                                                         |
| --------------------------- | ------ | -- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| x-acs-dingtalk-access-token | String | 必須 | このインターフェースを呼び出すためのアクセス認証情報です。[社内アプリの access\_token を取得](/ja/open/development/obtain-the-access-token-of-an-internal-app) インターフェースから取得できます。 |

## Body パラメータ

| 名前                 | タイプ             | 必須 | 説明                                                                                                                                              |
| ------------------ | --------------- | -- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| openConversationId | String          | 必須 | オープングループ ID。[グループチャットの作成](/ja/open/development/create-common-group-new-version-v2) インターフェースを呼び出して openConversationId パラメータの値を取得できます。            |
| userIds            | Array of String | 必須 | 社員の userid リストです。[部門ユーザーの userid リストを取得](/ja/open/development/query-the-list-of-department-userids) インターフェースを呼び出して userid\_list パラメータの値を取得できます。 |
| role               | Integer         | 必須 | 設定タイプ。値：   - **2**：管理者として追加 - **3**：管理者を削除                                                                                                      |

## レスポンスパラメータ

| 名前      | タイプ    | 説明                                            |
| ------- | ------ | --------------------------------------------- |
| success | String | 呼び出しが成功したかどうか：   - **true**：成功 - **false**：失敗 |

## サンプル

### リクエスト例

HTTP

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

{
  "openConversationId" : "cidVwhxxxx=",
  "userIds" : [ "wZxxxxGJGy" ],
  "role" : 2
}
```

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>Token を使用してアカウント Client を初期化します</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.ChatSubAdminUpdateHeaders chatSubAdminUpdateHeaders = new com.aliyun.dingtalkim_1_0.models.ChatSubAdminUpdateHeaders();
        chatSubAdminUpdateHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkim_1_0.models.ChatSubAdminUpdateRequest chatSubAdminUpdateRequest = new com.aliyun.dingtalkim_1_0.models.ChatSubAdminUpdateRequest()
                .setOpenConversationId("cidVwhxxxx=")
                .setUserIds(java.util.Arrays.asList(
                    "wZxxxxGJGy"
                ))
                .setRole(2);
        try {
            client.chatSubAdminUpdateWithOptions(chatSubAdminUpdateRequest, chatSubAdminUpdateHeaders, 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 には code と message の属性が含まれており、開発時の問題特定に役立ちます
            }

        } 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 には code と message の属性が含まれており、開発時の問題特定に役立ちます
            }

        }        
    }
}
```

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:
        """
        Token を使用してアカウント Client を初期化します
        @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()
        chat_sub_admin_update_headers = dingtalkim__1__0_models.ChatSubAdminUpdateHeaders()
        chat_sub_admin_update_headers.x_acs_dingtalk_access_token = '<your access token>'
        chat_sub_admin_update_request = dingtalkim__1__0_models.ChatSubAdminUpdateRequest(
            open_conversation_id='cidVwhxxxx=',
            user_ids=[
                'wZxxxxGJGy'
            ],
            role=2
        )
        try:
            client.chat_sub_admin_update_with_options(chat_sub_admin_update_request, chat_sub_admin_update_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err には code と message の属性が含まれており、開発時の問題特定に役立ちます
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        chat_sub_admin_update_headers = dingtalkim__1__0_models.ChatSubAdminUpdateHeaders()
        chat_sub_admin_update_headers.x_acs_dingtalk_access_token = '<your access token>'
        chat_sub_admin_update_request = dingtalkim__1__0_models.ChatSubAdminUpdateRequest(
            open_conversation_id='cidVwhxxxx=',
            user_ids=[
                'wZxxxxGJGy'
            ],
            role=2
        )
        try:
            await client.chat_sub_admin_update_with_options_async(chat_sub_admin_update_request, chat_sub_admin_update_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err には code と message の属性が含まれており、開発時の問題特定に役立ちます
                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\ChatSubAdminUpdateHeaders;
use AlibabaCloud\SDK\Dingtalk\Vim_1_0\Models\ChatSubAdminUpdateRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * Token を使用してアカウント Client を初期化します
     * @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();
        $chatSubAdminUpdateHeaders = new ChatSubAdminUpdateHeaders([]);
        $chatSubAdminUpdateHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $chatSubAdminUpdateRequest = new ChatSubAdminUpdateRequest([
            "openConversationId" => "cidVwhxxxx=",
            "userIds" => [
                "wZxxxxGJGy"
            ],
            "role" => 2
        ]);
        try {
            $client->chatSubAdminUpdateWithOptions($chatSubAdminUpdateRequest, $chatSubAdminUpdateHeaders, 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 には code と message の属性が含まれており、開発時の問題特定に役立ちます
            }
        }
    }
}
$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:
// 
// Token を使用してアカウント Client を初期化します
// 
// @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
  }

  chatSubAdminUpdateHeaders := &dingtalkim_1_0.ChatSubAdminUpdateHeaders{}
  chatSubAdminUpdateHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  chatSubAdminUpdateRequest := &dingtalkim_1_0.ChatSubAdminUpdateRequest{
    OpenConversationId: tea.String("cidVwhxxxx="),
    UserIds: []*string{tea.String("wZxxxxGJGy")},
    Role: tea.Int32(2),
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.ChatSubAdminUpdateWithOptions(chatSubAdminUpdateRequest, chatSubAdminUpdateHeaders, &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 には code と message の属性が含まれており、開発時の問題特定に役立ちます
    }

  }
  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 {

  /**
   * Token を使用してアカウント Client を初期化します
   * @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 chatSubAdminUpdateHeaders = new dingtalkim_1_0.ChatSubAdminUpdateHeaders({ });
    chatSubAdminUpdateHeaders.xAcsDingtalkAccessToken = '<your access token>';
    let chatSubAdminUpdateRequest = new dingtalkim_1_0.ChatSubAdminUpdateRequest({
      openConversationId: 'cidVwhxxxx=',
      userIds: [
        'wZxxxxGJGy'
      ],
      role: 2,
    });
    try {
      await client.chatSubAdminUpdateWithOptions(chatSubAdminUpdateRequest, chatSubAdminUpdateHeaders, new Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.default.empty(err.code) && !Util.default.empty(err.message)) {
        // err には code と message の属性が含まれており、開発時の問題特定に役立ちます
      }

    }    
  }

}

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>Token を使用してアカウント Client を初期化します</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.ChatSubAdminUpdateHeaders chatSubAdminUpdateHeaders = new AlibabaCloud.SDK.Dingtalkim_1_0.Models.ChatSubAdminUpdateHeaders();
            chatSubAdminUpdateHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkim_1_0.Models.ChatSubAdminUpdateRequest chatSubAdminUpdateRequest = new AlibabaCloud.SDK.Dingtalkim_1_0.Models.ChatSubAdminUpdateRequest
            {
                OpenConversationId = "cidVwhxxxx=",
                UserIds = new List<string>
                {
                    "wZxxxxGJGy"
                },
                Role = 2,
            };
            try
            {
                client.ChatSubAdminUpdateWithOptions(chatSubAdminUpdateRequest, chatSubAdminUpdateHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
            }
            catch (TeaException err)
            {
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err には code と message の属性が含まれており、開発時の問題特定に役立ちます
                }
            }
            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 には code と message の属性が含まれており、開発時の問題特定に役立ちます
                }
            }
        }

    }
}
```

### レスポンス例

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

{
  "success" : "true"
}
```

## エラーコード

| HttpCode | エラーコード                                      | エラーメッセージ               | 説明                     |
| -------- | ------------------------------------------- | ---------------------- | ---------------------- |
| 400      | invalidParameter.openConversationId.invalid | 無効なチャット ID             | 無効なチャット ID             |
| 400      | invalidParameter.orgId.invalid              | 無効な組織ID                | 無効な組織ID                |
| 400      | invalid.staffid                             | 無効な userId             | 無効な userId             |
| 400      | subadmin.exceed                             | 管理者数が上限を超えています         | 管理者数が上限を超えています         |
| 400      | invalidParamter.role                        | 無効な role               | 無効な role               |
| 400      | staff.not.found                             | 社員が存在しません              | 社員が存在しません              |
| 400      | permession.checkFailed                      | グループ作成者がアプリの可視範囲内にいません | グループ作成者がアプリの可視範囲内にいません |
| 400      | group.diaband                               | グループは既に解散されています        | グループは既に解散されています        |
| 500      | system.error                                | システムエラー                | システムエラー                |
