Add employees to a team
Add employees to a team
Section titled “Add employees to a team”POST
https://gptunnel.ru/api/v1/employees/addEmployeesToTeamAdds employees to the team identified by its ID. The API processes each employee login independently. Employees can belong to multiple teams. Adding someone to a team preserves their membership in other teams.
If an employee already belongs to the team, the API still counts that login in added. An unknown team ID returns HTTP 404 before any logins are processed.
Request headers
| Parameter | Type | Description |
|---|---|---|
Authorization* | string | API key |
Request parameters
| Parameter | Type | Description |
|---|---|---|
teamId* | string | Team ID |
logins* | string[] | Array of 1 to 25 employee logins. |
Error reasons in failedLogins:
Error reasons
| Parameter | Type | Description |
|---|---|---|
not_found | string | No employee in the organization has this login |
forbidden | string | You cannot manage an employee with a higher role than yours or manage your own account |
error | string | Unforeseen processing error |
Example request
Section titled “Example request”Set GPTUNNEL_API_KEY and replace the placeholders with values for your organization.
import jsonimport osfrom urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")if not key: raise SystemExit("Set GPTUNNEL_API_KEY")
body = { "teamId": "66a346f64dcb57627c03d596", "logins": [ "ivanov", "petrov" ]}request = Request( "https://gptunnel.ru/api/v1/employees/addEmployeesToTeam", method="POST", headers={ "Authorization": key, "Content-Type": "application/json", }, data=json.dumps(body).encode("utf-8"),)with urlopen(request, timeout=30) as response: print(json.load(response))curl --request POST \ --url 'https://gptunnel.ru/api/v1/employees/addEmployeesToTeam' \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \ --header 'Content-Type: application/json' \ --data '{ "teamId": "66a346f64dcb57627c03d596", "logins": [ "ivanov", "petrov" ]}'const key = process.env.GPTUNNEL_API_KEYif (!key) throw new Error("Set GPTUNNEL_API_KEY")
const body = { "teamId": "66a346f64dcb57627c03d596", "logins": [ "ivanov", "petrov" ]}const response = await fetch("https://gptunnel.ru/api/v1/employees/addEmployeesToTeam", { method: "POST", headers: { Authorization: key, "Content-Type": "application/json", }, body: JSON.stringify(body),})if (!response.ok) throw new Error(await response.text())console.log(await response.json())Example response
Section titled “Example response”{ "code": 0, "teamId": "66a346f64dcb57627c03d596", "added": 1, "failed": 1, "failedLogins": [ { "login": "petrov", "reason": "not_found", "message": "Employee not found in the organization." } ]}{ "code": 3, "message": "Invalid input, check schema issues.", "details": []}{ "error": { "message": "Unauthorized", "type": "unauthorized_request_error", "param": null, "code": null }}{ "code": 7, "message": "Not allowed to perform this action for the organization."}{ "code": 13, "message": "This section is not available from a personal account. Use a business organization API key."}{ "code": 11, "message": "Team not found in the organization."}{ "code": 1, "message": "Internal server error.", "trace_id": "66a346f64dcb57627c03d596"}