Skip to content

Your first API call

Every call to the Yoshuko API carries your key in one header (a line of information sent before the request):

Authorization: Bearer ilk_<prefix>.<secret>

Keep the key out of your code — store it as a named value in your computer's settings for programs, outside the code. All examples in these pages read it from YOSHUKO_API_KEY:

export YOSHUKO_API_KEY="ilk_…your key…"

Ask the key who it is

GET /api/v1/agent/whoami/ needs no permission at all. It proves the key works and tells you what it may do, so an agent should call it before anything else.

curl -sS "https://www-dev.yoshuko.com/api/v1/agent/whoami/" \
  -H "Authorization: Bearer $YOSHUKO_API_KEY"

import os
import requests

response = requests.get(
    "https://www-dev.yoshuko.com/api/v1/agent/whoami/",
    headers={"Authorization": f"Bearer {os.environ['YOSHUKO_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
print(response.json())

const response = await fetch("https://www-dev.yoshuko.com/api/v1/agent/whoami/", {
  headers: { Authorization: `Bearer ${process.env.YOSHUKO_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

A working key answers 200:

{
  "org_id": "5b0c9a6e-2f4e-4d8a-9a51-1f3a0c6d2e10",
  "org_name": "Northgate Academy",
  "key_name": "Content agent",
  "scopes": {
    "courses": "edit",
    "chapters": "edit",
    "lessons": "edit",
    "org_settings": "none"
  }
}

scopes is what the key may do right now, per area: none, view (read) or edit (read and change). A person can change these at any time on the API Keys page, so read scopes again before each run rather than keeping an old copy.

If it does not work

You get It means Do this
401 (no code) The header is missing, or the key is unknown, turned off, or past its last day — the detail reads Authentication credentials were not provided. Check the header spelling and the key; create a new key if needed
401 subscription_inactive The organisation has no active paid plan Pay for a plan — see pricing
401 org_unverified The organisation has not finished verification Complete sign-up in the web app
429 More than 300 requests in an hour Wait for the number of seconds in Retry-After

The full list is in Errors and limits.

Next

Build a course with the API — a course, a chapter and a quiz in four calls.