You can invite candidates using following API endpoint:
https://api.hackerearth.com/partner/hackerearth/cancel-invite/
The client authentication is done using your unique client_id and client_secret.
You can refer to your Dashboard settings, for client_id and client_secret under API details.
client_id and client_secret should be passed through the body.
Type: String
Description: client_id is a 67 character random key that serves as an identification for a particular client and must be provided when communicating with the API as a parameter to the API endpoint.
Example: d8a20ae8e475209er4b1faa72ede88a174423cc2029c.api.hackerearth.com
Type: String
Description: client_secret is a 40 character random key that serves as an identification for a particular client and must be provided when communicating with the API as a parameter to the API endpoint.
Example: 2b0ff29f4f8751487540604cdab5611e6135f41c
Candidates invites can be cancelled only for published tests.
client_id, client_secret, test_id and emails are the required parameters for making request to this API endpoint.
All the requests to the API must be made using POST request method.
client_id and client_secret are explained above.
Type: Integer
Description: test_id is a unique integer for your test. Refer to this article for a better understanding. In this article, Recruiter API ID is the test_id.
Example: 5841
Type: List
Description: emails is a list/array which contains emails.
Example: ["foo@bar.com", "bob@alice.com", "hacker@hackerearth.com"]
Sample request using python
#!/usr/bin/env python
import json
import requests
CLIENT_ID = "d8a20ae8e475209e0eb1faa72ede88a174423cc2029c.api.hackerearth.com"
CLIENT_SECRET = "2b0ff29f4f8751487450604cdab5611e6135f41c"
TEST_ID = 53
payload = {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'test_id': TEST_ID,
'emails': ['foo@bar.com', 'alice@bob.com', 'yet@another.email']
}
r = requests.post("https://api.hackerearth.com/partner/hackerearth/cancel-invite/", data=json.dumps(payload))
print r.json()
Using cURL
curl --data '{
"client_id": "7ece23094df344eb6f29d60ee415fcdca3885b71af70.api.hackerearth.com",
"client_secret": "639110ecf3aeb333498c948e3442376253b208c6",
"test_id": 57,
"emails": ["foo@bar.com", "alice@bob.com", "yet@another.email"],
}' https://api.hackerearth.com/partner/hackerearth/cancel-invite/
Response returned will be in JSON format.
Sample response
{
"emessage": [],
"ecode": [],
"mcode": "SUCCESS",
"message": "Request successful",
"cancelled_invites_count": 1,
"cancelled_emails": [
"satheesh@hackerearth.com"
]
"invalid_emails": [],
"candidates_already_completed": [],
}
Type : String
Description: Message code abbreviated as mcode.
Type: String
Description: A message for user regarding the success of request.
message and mcode are related to each other according to the following table:
mcode | message |
---|---|
SUCCESS | Request successful |
FAILED | Request failed |
Type: List
Description: Error codes abbreviated as ecode.
Type: List
Description: A message explaining the error occurred during request processing.
emessage and ecode are related to each other according to the following table:
ecode | emessage |
---|---|
AUTHFAILED | Authentication Failed. |
ARGMISSING | Request argument missing. |
BADDATA | |
TESTNOTFOUND | Test not found. |
TESTNOTPUBLISHED | Test not published. |
EVENTFINISHED | Test has ended. |
INVALIDEMAIL | Invalid email(s) exist. |
LIMITEXCEEDED | Client exceeded its request limit. Please contact support@hackerearth.com. |
RATELIMITEXCEEDED | The rate at which the API requests are made has reached. Please try again after one minute. |
BUYCREDITS | You do not have sufficient credits to invite candidates, please purchase more credits. |
TESTTAKEN | Candidate(s) have taken the test |
ACCESSERROR | You are not authorized to access this feature. Please contact support@hackerearth.com. |
Type: List
Description: An array of invalid emails
Example:
"invalid_emails": [
"itsnotanemail",
"another@@wrongemail",
"wrong@again"
]
Type: List
Description: This list contains emails of candidates who have taken the test from the emails provided. The candidates are not invited again.
Example:
"candidates_already_completed": [
"particip@ted.com"
]
Type: Integer
Description: Count of number of candidates for whom the invites are cancelled.
Example:
"cancelled_invites_count": 1
Sample response for emails with invalid emails:
{
"invalid_emails": [
"notanemailaddress"
],
"candidates_already_completed": [],
"message": "Request successful",
"cancelled_invites_count": 1,
"cancelled_emails": [
"satheesh@hackerearth.com"
]
"ecode": [
"INVALIDEMAIL"
],
"emessage": [
"Invalid email(s) exist."
],
"mcode": "SUCCESS"
}
If you have provided wrong client_id or client_secret, the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"AUTHFAILED"
],
"emessage": [
"Authentication Failed."
],
"mcode": "FAILED"
}
If mandatory POST arguments are not provided, the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"ARGMISSING"
],
"emessage": [
"Request argument missing: 'emails'"
],
"mcode": "FAILED"
}
or
{
"message": "Request failed",
"ecode": [
"ARGMISSING"
],
"emessage": [
"Request argument missing: 'test_id'"
],
"mcode": "FAILED"
}
If wrong test_id is provided, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"TESTNOTFOUND"
],
"emessage": [
"Test not found."
],
"mcode": "FAILED"
}
If test is not published, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"TESTNOTPUBLISHED"
],
"emessage": [
"Test is not published."
],
"mcode": "FAILED"
}
If the test is ended, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"EVENTFINISHED"
],
"emessage": [
"Test has ended."
],
"mcode": "FAILED"
}
If user is not authorized to access the test, then the JSON response returned will look like:
{
"message": "Request failed",
"ecode": [
"ACCESSERROR"
],
"emessage": [
"You are not authorized to access this feature. Please contact support@hackerearth.com."
],
"mcode": "FAILED"
}
If the limit of API requests (15000 requests) is reached, then the JSON response that is returned is as follows:
{
"message": "Request failed",
"ecode": [
"LIMITEXCEEDED"
],
"emessage": [
"The limit of the API requests has been reached. Contact support@hackerearth.com."
],
"mcode": "FAILED"
}
If the rate (60 per min or 10000 per day) at which API requests are made by a specific user is reached, then the JSON response that is returned is as follows:
{
"message": "Request failed",
"ecode": [
"RATELIMITEXCEEDED"
],
"emessage": [
"The rate at which the API requests are made has reached. Please try again after some time."
],
"mcode": "FAILED"
}
and if any other issue occurred do reach us out at api@hackerearth.com