Notify Certificate Code
curl --request POST \
--url 'https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"user_email": "<string>"
}
'import requests
url = "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY="
payload = { "user_email": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({user_email: '<string>'})
};
fetch('https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"user_email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"user_email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"credits": 123,
"status": "created",
"sent_to": "<string>",
"user_id": 123,
"created_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"activated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}API Reference
Notify Certificate Code
Report a certificate code as sent to a recipient or activated by them.
Called by the external agent that distributes codes:
>>> POST /certificate-codes/HAIQU2026HAVEFUN00/notify
>>> {"status": "sent", "user_email": "participant@example.com"}
Repeating a notification is not an error — the first ``sent_at`` /
``activated_at`` timestamp is kept, and only the recipient is refreshed.
``activated`` requires a ``user_email`` that belongs to an existing Haiqu
user; the code is linked to that user. ``sent`` accepts any recipient,
including none.
Args:
code (str): The certificate code (case-insensitive).
notification (CertificateCodeNotifyModel): Reported status and the email the
code was sent to / activated by (required for ``activated``).
Returns:
CertificateCodeModel: The updated code.
Raises:
HTTPException: Raised with ``404`` when the code does not exist or when
``activated`` names an email with no Haiqu user, or with ``409`` when
the reported status would undo a later one.
POST
/
certificate-codes
/
{code}
/
notify
Notify Certificate Code
curl --request POST \
--url 'https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"user_email": "<string>"
}
'import requests
url = "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY="
payload = { "user_email": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({user_email: '<string>'})
};
fetch('https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"user_email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"user_email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/certificate-codes/{code}/notify?HAIQU_API_KEY=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"credits": 123,
"status": "created",
"sent_to": "<string>",
"user_id": 123,
"created_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"activated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
APIKeyQueryAPIKeyHeader
Path Parameters
Body
application/json
Response
Successful Response
The Pydantic model for a certificate code stored in the DB.
Lifecycle of a certificate (invitation) code.
Available options:
created, sent, activated