Create an activity
curl --request POST \
--url https://api.example.com/v1/activities \
--header 'Content-Type: application/json' \
--data '
{
"lesson_id": "<string>",
"type": {},
"variant": "<string>",
"prompt": "<string>",
"difficulty": {},
"count": 123,
"questions": [
{}
]
}
'import requests
url = "https://api.example.com/v1/activities"
payload = {
"lesson_id": "<string>",
"type": {},
"variant": "<string>",
"prompt": "<string>",
"difficulty": {},
"count": 123,
"questions": [{}]
}
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({
lesson_id: '<string>',
type: {},
variant: '<string>',
prompt: '<string>',
difficulty: {},
count: 123,
questions: [{}]
})
};
fetch('https://api.example.com/v1/activities', 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/v1/activities",
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([
'lesson_id' => '<string>',
'type' => [
],
'variant' => '<string>',
'prompt' => '<string>',
'difficulty' => [
],
'count' => 123,
'questions' => [
[
]
]
]),
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/v1/activities"
payload := strings.NewReader("{\n \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\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/v1/activities")
.header("Content-Type", "application/json")
.body("{\n \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/activities")
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 \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_bodyActivities
Create an activity
Create a single activity by type. Async — the body is generated by the AI unless you pass questions explicitly.
POST
/
v1
/
activities
Create an activity
curl --request POST \
--url https://api.example.com/v1/activities \
--header 'Content-Type: application/json' \
--data '
{
"lesson_id": "<string>",
"type": {},
"variant": "<string>",
"prompt": "<string>",
"difficulty": {},
"count": 123,
"questions": [
{}
]
}
'import requests
url = "https://api.example.com/v1/activities"
payload = {
"lesson_id": "<string>",
"type": {},
"variant": "<string>",
"prompt": "<string>",
"difficulty": {},
"count": 123,
"questions": [{}]
}
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({
lesson_id: '<string>',
type: {},
variant: '<string>',
prompt: '<string>',
difficulty: {},
count: 123,
questions: [{}]
})
};
fetch('https://api.example.com/v1/activities', 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/v1/activities",
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([
'lesson_id' => '<string>',
'type' => [
],
'variant' => '<string>',
'prompt' => '<string>',
'difficulty' => [
],
'count' => 123,
'questions' => [
[
]
]
]),
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/v1/activities"
payload := strings.NewReader("{\n \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\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/v1/activities")
.header("Content-Type", "application/json")
.body("{\n \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/activities")
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 \"lesson_id\": \"<string>\",\n \"type\": {},\n \"variant\": \"<string>\",\n \"prompt\": \"<string>\",\n \"difficulty\": {},\n \"count\": 123,\n \"questions\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_bodyBody
See The Activity object for the
full enum.
Required for
type: "quiz".Free-text instruction. Defaults to a sensible derivation from the
lesson context.
easy | intermediate | hard.For quiz-like activities, number of questions to generate.
Pass explicit questions to skip AI generation.
Examples
// AI-generated 5-item true/false quiz
await hk.activities.create({
lesson_id: "lsn_123",
type: "quiz",
variant: "true_false",
count: 5,
difficulty: "intermediate",
});
// Hand-authored short-answer
await hk.activities.create({
lesson_id: "lsn_123",
type: "short_answer",
questions: [{ prompt: "Define proper time in three sentences." }],
});
// Generate a 5-min audio recap
await hk.activities.create({
lesson_id: "lsn_123",
type: "podcast",
});
// AI-generated 5-item true/false quiz
$hk->activities->create([
'lesson_id' => 'lsn_123',
'type' => 'quiz',
'variant' => 'true_false',
'count' => 5,
'difficulty' => 'intermediate',
]);
// Hand-authored short-answer
$hk->activities->create([
'lesson_id' => 'lsn_123',
'type' => 'short_answer',
'questions' => [['prompt' => 'Define proper time in three sentences.']],
]);
// Generate a 5-min audio recap
$hk->activities->create([
'lesson_id' => 'lsn_123',
'type' => 'podcast',
]);
Returns
An Activity inai_status: "pending"
unless you passed questions explicitly.⌘I