Invite Members¶
POST /api/v1/workspace/member/batch_invitation
Overview¶
Invite users to the current workspace in batches by email and preset their roles.
Before Calling and Usage Steps¶
Prepare an email array, a non-empty roleUUIDs, and method=email. API Key invitations use OpenAPI mode and do not require a front-end CAPTCHA; however, the workspace member limit, invitation frequency, and assignable role scope are still validated. The role list containing wsAdmin does not mean the current identity can necessarily invite administrators; only owner/wsAdmin identities can do so. Custom roles that only have invitation permission are also subject to assignable scope restrictions. Invitation emails are sent asynchronously, which does not mean the email has been received or the user has joined. Cached invitation links are valid for 24 hours; inviting the same pending-response email again invalidates the old invitation. Email addresses pending approval are skipped; however, the current waitAuditEmail may also include email addresses that were previously only pending response and have been resent this time. This field alone cannot be used to determine approval status or whether an email was sent; combine it with the invitation record status in the console. If the site disables invitations or does not support the current email method, the API can still successfully return a message; do not rely only on HTTP 200. Processing of member relationships, roles, tokens, caches, and similar items may be persisted in steps; after an exception or timeout, first read the member and role status, then decide whether to retry.
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or enter: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace. |
Body Request Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| to[*] | string | A single string identifier in the array. Example: xxx@guance.comHow to obtain or enter: Enter the real email address of the person to invite; replace the example address. The user does not need to be registered. |
|
| roleUUIDs[*] | string | A single string identifier in the array. Example: readOnlyHow to obtain or enter: Obtain an available role in the current workspace from content.data[].uuid in the role list. Built-in identifiers: wsAdmin (administrator), general (standard member), and readOnly (read-only member); identifiers starting with role_ are custom roles. |
|
| to | array | Y | Array of email addresses to invite; required. Remove empty values and validate email addresses before sending; do not pass null. Allows null: True Example: ["xxx@guance.com"]How to obtain or enter: Enter the real email address of the person to invite; replace the example address. The user does not need to be registered. |
| roleUUIDs | array | Y | Array of role UUIDs to assign uniformly to all invitees; must not be empty. owner is not allowed; wsAdmin can be invited only by owner/wsAdmin identities; other roles must not have tokenRead/tokenReplace permissions. Allows null: False Example: ["readOnly"]How to obtain or enter: Obtain an available role in the current workspace from content.data[].uuid in the role list. Built-in identifiers: wsAdmin (administrator), general (standard member), and readOnly (read-only member); identifiers starting with role_ are custom roles. |
| method | string | Y | Invitation method; required. Currently only email is supported. Allows null: False Allowed values: ['email'] Example: emailHow to obtain or enter: For the current public API, always enter email. |
Additional Parameter Notes¶
The API does not return invitation links or account UUIDs; after members actually join, obtain UUIDs from the member list. Although a historical declaration allows null for to, the current implementation requires a traversable email array, so clients should pass an array as shown in the example.
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/workspace/member/batch_invitation' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"to":["xxx@guance.com"],"roleUUIDs":["readOnly"],"method":"email"}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content.waitAuditEmail | array<string> |
The current response contains email addresses associated with historical pending-approval or pending-response invitation records; it may include email addresses that were resent this time. It cannot be used alone to determine pending approval or whether an email was sent. |
| content.waitAuditEmail[] | string | A single email address associated with historical invitation records; it cannot be used alone to determine approval or sending status. |
| content.message | string | Description when invitations are not enabled or the current method is not supported; this branch does not necessarily return waitAuditEmail. |
| content.declaration | object or null | Public workspace declaration. |
{
"code": 200,
"content": {
"waitAuditEmail": [],
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
When the site has not enabled invitations, the response may be:
{
"code": 200,
"content": {
"message": "服务未启用",
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | A request field is missing, or a field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Invalid request JSON syntax | Request JSON format error | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The JSON top level is not an object | Invalid format in part of the JSON file | Submit a single JSON object. |
| 406 | ft.InvalidEmail | to contains an invalid email address | Invalid email address | Correct it according to the email format and remove empty values. |
| 400 | ft.RoleUUIDNullError | roleUUIDs is empty | The role UUID list is empty | Select at least one role available in the current workspace. |
| 400 | ft.RoleInvitationWsAdminPermissionError | The invitation role includes owner | The role of an invited member cannot be owner | Use the dedicated owner transfer process; do not set an owner through invitations. |
| 400 | ft.RoleInvitationPermissionError | A target role other than wsAdmin has Token read or replace permissions | Inviting roles with Token view or Token modify permissions is prohibited | Select an invitation role without these permissions, and adjust it according to the authorization process after the member joins. |
| 400 | ft.MemberRoleNotFound | The target role does not exist, has been deleted, or does not apply to the current workspace | The specified member role was not found in the current workspace | Select again from the role list. |
| 403 | ft.Forbidden | The current inviting identity cannot assign the selected role, or a non-owner/wsAdmin is inviting an administrator | You do not have permission to perform this operation | Use an identity with the appropriate authorization scope, or select a role that you can assign. |
| 403 | ft.ForbiddenFreeEditionLimit | The number of workspace members has reached the limit for the current plan | The Free Plan workspace {} has reached its limit ({}), and new members cannot be created. Upgrade to the Commercial Plan to remove the limit | Check the member count and workspace plan. |
| 400 | ft.InvitationEmailTooMany | The number of this request plus existing sends exceeds the current site's invitation frequency limit | Your invitation email count has exceeded the default maximum ({} emails) within a single hour. Please try again later | Reduce the batch size and retry after the frequency window ends; the default is 20 email addresses per workspace per hour, and the site configuration can override it. |
| 404 | ft.MemberAlreadyExistsInWorkspace | The invited email address is already a regular member directly associated with the current workspace | These members already exist in the workspace | Remove existing members from the request; to adjust roles, use member modification. |
| 500 | ft.InternalServerError | Data saving, associated resource processing, or cache processing failed | Internal error | First verify the current member and permission status, then decide whether to retry; if the failure persists, provide the traceId and a redacted request. |