Create an employee account
Create an employee
Section titled “Create an employee”https://gptunnel.ru/api/v1/employees/createEmployeeCreates an account with the member role in the organization associated with the API key. If you supply an email, the employee receives their sign-in details there.
If the login already belongs to a registered user outside your organization, the service sends them an invitation. The password, name, and phone number in the request do not change the existing account. Until the user accepts, only their login is visible in the employee list. The response has the same structure as for a new account, but the returned userId does not identify the invited account.
If another organization created the account, the service returns the same response without sending an invitation. The account will not appear in your employee list.
Request headers
| Parameter | Type | Description |
|---|---|---|
Authorization* | string | API key |
Request parameters
| Parameter | Type | Description |
|---|---|---|
login* | string | Employee login (any string from 1 to 255 characters) |
password* | string | Password (at least 5 characters) |
email | string | Email address, unique within the organization |
firstName | string | First name |
lastName | string | Last name |
phone | string | Phone number (any string) |
avatar | string | Avatar |
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 = { "login": "ivanov@example.com", "password": "secret123", "email": "ivanov@example.com", "firstName": "Иван", "lastName": "Иванов"}request = Request( "https://gptunnel.ru/api/v1/employees/createEmployee", 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/createEmployee' \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \ --header 'Content-Type: application/json' \ --data '{ "login": "ivanov@example.com", "password": "secret123", "email": "ivanov@example.com", "firstName": "Иван", "lastName": "Иванов"}'const key = process.env.GPTUNNEL_API_KEYif (!key) throw new Error("Set GPTUNNEL_API_KEY")
const body = { "login": "ivanov@example.com", "password": "secret123", "email": "ivanov@example.com", "firstName": "Иван", "lastName": "Иванов"}const response = await fetch("https://gptunnel.ru/api/v1/employees/createEmployee", { 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, "userId": "66a346f64dcb57627c03d596"}{ "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": 8, "message": "Employee with this login is already in the organization."}{ "code": 9, "message": "Employee with this email is already in the organization."}{ "code": 43, "message": "Too many employee creation requests, retry later."}{ "code": 1, "message": "Internal server error.", "trace_id": "66a346f64dcb57627c03d596"}