Skip to content
  • There are no suggestions because the search field is empty.

Common k12panel API workflows

Examples of common workflows with the k12panel API

Copy-paste recipes for the most common tasks. Examples use curl and Python; set KEY to your API key and PANEL to your panel domain first.

export KEY="k12_live_xxxxxxxxxxxx_yyyy..."
export PANEL="https://<your-panel-domain>"

Check a repaired device back out to a teacher

# 1. Find the asset by serial -> read its id from the response
curl -H "Authorization: Bearer $KEY" "$PANEL/api/public/v1/assets?serial=5CD1234XYZ"

# 2. Check it out to the teacher by email (no pre-lookup of the person needed)
curl -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"person": {"email": "jsmith@school.org"}}' \
  "$PANEL/api/public/v1/assets/4021/checkout"

Check a device back in

curl -X POST -H "Authorization: Bearer $KEY" \
  "$PANEL/api/public/v1/assets/4021/checkin"

List everything currently checked out (for a nightly report)

curl -H "Authorization: Bearer $KEY" \
  "$PANEL/api/public/v1/assets?checked_out=true&page_size=200"

Results are paged; follow the next link in the response until it is null.

Update an asset's site and notes

curl -X PATCH -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"notes": "Returned from repair", "site": {"name": "Middle School"}}' \
  "$PANEL/api/public/v1/assets/4021"

You can identify the site by name here too — the same lookup rules apply.

See what a person has checked out

# Find the person, then list their assets
curl -H "Authorization: Bearer $KEY" "$PANEL/api/public/v1/people?email=jsmith@school.org"
curl -H "Authorization: Bearer $KEY" "$PANEL/api/public/v1/people/3087/assets"

Python example

import requests

PANEL = "https://<your-panel-domain>"
KEY = "k12_live_xxxxxxxxxxxx_yyyy..."
session = requests.Session()
session.headers["Authorization"] = f"Bearer {KEY}"

# Find an asset by serial
assets = session.get(f"{PANEL}/api/public/v1/assets", params={"serial": "5CD1234XYZ"}).json()
asset_id = assets["results"][0]["id"]

# Check it out to a teacher by email
r = session.post(
    f"{PANEL}/api/public/v1/assets/{asset_id}/checkout",
    json={"person": {"email": "jsmith@school.org"}},
)
if r.status_code == 200:
    print("Checked out to", r.json()["checked_out_to"]["email"])
elif r.status_code == 409 and r.json()["error"] == "ambiguous_reference":
    # More than one person matched — pick the right one and retry with an id
    for candidate in r.json()["candidates"]:
        print(candidate["id"], candidate["first_name"], candidate["last_name"], candidate["org_unit"])

See Handling errors for the full list of responses, and the interactive reference at $PANEL/api/public/v1/docs for every field.