Assignments
Create an assignment
Idempotently assigns a published scenario to a learner. Email failure does not roll back the assignment.
POST
https://dash.trainertwin.com/api/v1
/
assignments
Create an assignment
curl --request POST \
--url https://dash.trainertwin.com/api/v1/assignments \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "user_123",
"scenario": "react-mock-interview"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({userId: 'user_123', scenario: 'react-mock-interview'})
};
fetch('https://dash.trainertwin.com/api/v1/assignments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://dash.trainertwin.com/api/v1/assignments"
payload = {
"userId": "user_123",
"scenario": "react-mock-interview"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"assignment": {
"id": "assignment_123",
"assignedAt": "2023-11-07T05:31:56Z",
"userId": "user_123",
"scenario": "react-mock-interview"
},
"created": true,
"emailSent": true,
"practiceUrl": "<string>"
}{
"assignment": {
"id": "assignment_123",
"assignedAt": "2023-11-07T05:31:56Z",
"userId": "user_123",
"scenario": "react-mock-interview"
},
"created": true,
"emailSent": true,
"practiceUrl": "<string>"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}Authorizations
Organization API key generated in Dashboard → account menu → Developer API (dash.trainertwin.com/developer).
Body
application/json
⌘I
Create an assignment
curl --request POST \
--url https://dash.trainertwin.com/api/v1/assignments \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "user_123",
"scenario": "react-mock-interview"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({userId: 'user_123', scenario: 'react-mock-interview'})
};
fetch('https://dash.trainertwin.com/api/v1/assignments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://dash.trainertwin.com/api/v1/assignments"
payload = {
"userId": "user_123",
"scenario": "react-mock-interview"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"assignment": {
"id": "assignment_123",
"assignedAt": "2023-11-07T05:31:56Z",
"userId": "user_123",
"scenario": "react-mock-interview"
},
"created": true,
"emailSent": true,
"practiceUrl": "<string>"
}{
"assignment": {
"id": "assignment_123",
"assignedAt": "2023-11-07T05:31:56Z",
"userId": "user_123",
"scenario": "react-mock-interview"
},
"created": true,
"emailSent": true,
"practiceUrl": "<string>"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}{
"error": "Resource not found"
}