The POST /api/v1/tests/invitations/candidates endpoint creates an HR testing invitation for a candidate. The request body must include first name, surname, email, gender and a list of testIds; sendCopyToHr is optional. The lang parameter controls the invitation email language and the language of the test-taking link.
Which endpoint is used?
Use POST /api/v1/tests/invitations/candidates. The endpoint creates a candidate invitation to take one or more tests.
| Parameter | Value |
|---|---|
| Method | POST |
| Endpoint | /api/v1/tests/invitations/candidates |
| 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 an HR testing invitation to a candidate. It is used in recruitment integrations when an external system sends candidate data and the list of tests to be taken.
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 active
testIdavailable to the current company is required.
| Prerequisite | Description | Required |
|---|---|---|
access_token |
Bearer token with company context | Yes |
tests.write |
Scope for creating invitations | Yes |
testIds |
List of active 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 |
|---|---|---|---|
name |
string | Yes | Candidate first name |
surname |
string | Yes | Candidate surname |
email |
string | Yes | Candidate email |
gender |
string | Yes | Only Male or Female are allowed |
testIds |
int64[] | Yes | List of test IDs; must contain at least one element |
sendCopyToHr |
boolean | No | If true, the server additionally sends a copy of the invitation to the HR email from the token |
curl example
curl -X POST 'https://smartway.pro/api/v1/tests/invitations/candidates?lang=en' \
-H 'Authorization: Bearer <access_token>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "Ivan",
"surname": "Petrenko",
"email": "candidate@company.test",
"gender": "Male",
"testIds": [5, 200001],
"sendCopyToHr": true
}'
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, the invitation is sent in English (en). -
genderaccepts onlyMaleorFemale. -
testIdsmust contain at least one element. -
Before creating the invitation, the server checks each
testId: the test must exist and be active. -
If the request contains multiple invalid
testIds, the API returns one400 Bad Requestlisting all problematic elements. -
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 |
gender is not Male or Female |
API returns 400 Bad Request |
Send only Male or Female |
testIds is empty |
API returns 400 Bad Request |
Send at least one testId |
One or more testIds do not exist or are inactive |
API returns one 400 Bad Request listing all problematic testId values |
Pre-check testIds through the catalogue or test details |
Which errors can the API return?
| HTTP status | Description |
|---|---|
400 Bad Request |
Missing required parameter, gender is not Male / Female, or at least one testId does not exist or is inactive |
401 Unauthorized |
Missing or invalid Bearer token |
403 Forbidden |
Insufficient permissions |
500 Internal Server Error |
Unexpected error |
503 Service Unavailable |
Service failure |
Error response example:
{
"type": "https://smartway.pro/problems/public-api",
"title": "Bad Request",
"status": 400,
"detail": "Candidate invitation contains invalid testIds: testId 2 does not exist; testId 3 is inactive.",
"instance": "/api/v1/tests/invitations/candidates"
}
How to use the result in subsequent API requests?
Before creating the invitation, retrieve available testId values through the test catalogue. Send the returned testIds in the request body as the testIds array.
Example of getting the test catalogue before creating an invitation:
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
gendervalues other thanMaleorFemale. -
Sending an empty
testIdsarray. -
Using inactive or non-existent
testIds. -
Expecting an error for unsupported
lang, although the API usesen.
FAQ
Which status is returned after a successful invitation?
The API returns 202 Accepted.
Do I need to send idCompany?
No. idCompany is taken from the Bearer token.
Where does HR email come from?
hrEmail is taken from the Bearer token; the external client does not send it.
Which values does gender support?
Only Male and Female are allowed.
What happens if several testIds are invalid?
The API returns one 400 Bad Request with all problematic elements listed.