Skip to content
POST{BASE_URL}/wx-api/api/room/create
写操作实测 2026-09-11JSON · Bearer App Token · body appid

创建客户群

创建一个新的(空)客户群,返回新群 roomId 与邀请卡片信息;随后用 addMember 拉人。

说明与注意

  • body 只需 appid 即建客户群;返回 {url(邀请链接),title, content, imgUrl(默认群头像),roomId}。建群后用 addMember 拉人。

请求参数

参数必填类型说明
appidstring实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx

请求示例

http
POST {BASE_URL}/wx-api/api/room/create
Authorization: Bearer <你的 App Token>
Content-Type: application/json

{
  "appid": "we_xxxxxxxxxxxxxxx"
}
bash
curl -X POST '{BASE_URL}/wx-api/api/room/create' \
  -H 'Authorization: Bearer <你的 App Token>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "appid": "we_xxxxxxxxxxxxxxx"
}'
python
import requests

url = "{BASE_URL}/wx-api/api/room/create"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
  "appid": "we_xxxxxxxxxxxxxxx"
}"""

resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

String url = "{BASE_URL}/wx-api/api/room/create";
String body = "{\n" +
    "  \"appid\": \"we_xxxxxxxxxxxxxxx\"\n" +
    "}";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
    .header("Authorization", "Bearer <你的 App Token>")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
php
<?php

$url = '{BASE_URL}/wx-api/api/room/create';
$body = <<<'JSON'
{
  "appid": "we_xxxxxxxxxxxxxxx"
}
JSON;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer <你的 App Token>',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

响应示例

json
{
  "code": 0,
  "data": {
    "url": "https://work.weixin.qq.com/wework_admin/room/join/wx?invite_source=146&vcode=…",
    "title": "邀请你加入企业微信群聊",
    "content": "张**在企业微信中邀请你加入群聊,用正式的名片聊工作",
    "imgUrl": "http://rescdn.qqmail.com/node/ww/wwmng/…/DefaultGroupAvatar.png",
    "roomId": 10745787645721636
  },
  "detail": "",
  "message": "ok",
  "time": "2026-09-11 20:00:00"
}

响应字段

响应字段(10 项)
字段类型说明
codeint64统一封套状态码:0=成功,负数=失败
dataobject业务数据
data.urlstring链接 / 资源地址
data.titlestring标题
data.contentstring消息内容;文本为数组、媒体为对象;未解析的消息为 {msgType, hex}(hex=protobuf 原始十六进制)
data.imgUrlstring群头像 url(与列表项 roomUrl 同源)
data.roomIdint64群会话 id;非群消息为 0
detailstring附加明细,通常为空
messagestring文案:成功为 ok;失败形如 -码|描述
timestring服务端处理时间 YYYY-MM-DD HH:MM:SS

下一步