The POST /api/v1/tests/invitations/employees endpoint sends testing invitations to employees in bulk. The request body must include non-empty employeeIds and testIds arrays. The lang parameter controls the invitation email language and the language of test-taking links.
Which endpoint is used?
Use POST /api/v1/tests/invitations/employees. The endpoint sends testing invitations to a list of employees.
| Parameter | Value |
|---|---|
| Method | POST |
| Endpoint | /api/v1/tests/invitations/employees |
| Base URL | [https://smartway.pro](https://smartway.pro) |
| Auth | Bearer token |
| Content-Type | application/json |
What is this API endpoint used for?
This endpoint is used to send testing invitations in bulk to company employees. It is used in HR integrations when an external system has a list of employees and a list of tests.
What prerequisites are required before sending the request?
-
A Bearer token with company context is required.
-
The token must include the
tests.writescope. -
At least one
employeeIdwithin the current company is required. -
At least one
testIdis required.
| Prerequisite | Description | Required |
|---|---|---|
access_token |
Bearer token with company context | Yes |
tests.write |
Scope for creating invitations | Yes |
employeeIds |
List of employee IDs | Yes |
testIds |
List of test IDs | Yes |
Which parameters must be sent in the request?
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization |
string | Yes | Bearer token in the Bearer <access_token> format |
Accept |
string | Yes | application/json |
Content-Type |
string | Yes | application/json |
Path parameters
Path parameters are absent.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
lang |
string | No | Invitation language. Supported values are uk, ru, en. If the parameter is missing or another value is sent, the server uses en. |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
employeeIds |
int64[] | Yes | List of employee IDs; must contain at least one element |
testIds |
int64[] | Yes | List of test IDs; must contain at least one element |
curl example
curl -X POST 'https://smartway.pro/api/v1/tests/invitations/employees?lang=en' \
-H 'Authorization: Bearer <access_token>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"employeeIds": [101, 102],
"testIds": [5, 200001]
}'
What response does the API return?
A successful request returns 202 Accepted.
What happens under the hood?
-
idCompanyis not sent in the body or query string: it is taken from the Bearer token. -
hrEmailis not sent by the external client: it is taken from the Bearer token. -
langaccepts onlyuk,ru,en; if it is not sent or the value is unsupported, invitations are sent in English (en). -
employeeIdsandtestIdsmust contain at least one element. -
If at least one employee is absent within the current company, the API returns
404 Not Found. -
Access requires the
tests.writescope.
Which edge cases should be considered?
| Scenario | API behaviour | Integrator action |
|---|---|---|
lang missing or unsupported |
The server uses en |
Send uk, ru or en when a specific language is required |
employeeIds is empty |
API returns 400 Bad Request |
Send at least one employeeId |
testIds is empty |
API returns 400 Bad Request |
Send at least one testId |
| At least one employee is not found in the tenant | API returns 404 Not Found |
Check that all employeeIds belong to the current company |
Which errors can the API return?
| HTTP status | Description |
|---|---|
400 Bad Request |
Missing or empty employeeIds / testIds |
401 Unauthorized |
Missing or invalid Bearer token |
403 Forbidden |
Insufficient permissions |
404 Not Found |
At least one employee is not found within the current tenant |
500 Internal Server Error |
Unexpected error |
503 Service Unavailable |
Service failure |
How to use the result in subsequent API requests?
Before sending invitations in bulk, retrieve available testId values through the test catalogue. Send employees in employeeIds and tests in testIds.
Example of getting the test catalogue:
curl -X GET 'https://smartway.pro/api/v1/tests' \
-H 'Authorization: Bearer <access_token>' \
-H 'Accept: application/json'
Which mistakes should integrators avoid?
-
Sending
idCompanyorhrEmailin the body. -
Sending empty
employeeIdsortestIdsarrays. -
Sending
employeeIdsthat do not belong to the current company. -
Expecting an error for unsupported
lang, although the API usesen. -
Calling the endpoint without the
tests.writescope.
FAQ
Which status is returned after a successful bulk send?
The API returns 202 Accepted.
Do I need to send idCompany?
No. idCompany is taken from the Bearer token.
What happens if one employee is not found?
The API returns 404 Not Found if at least one employee is not found within the current tenant.
Which arrays are required?
Non-empty employeeIds and testIds are required.
Which scope is required?
The tests.write scope is required.