Developers

Building with AI agents on the Authmarks API: setup, guardrails and workflows for campus IT

A hands-on guide for Canadian college and university teams pairing coding agents with Authmarks: the context to give an agent, token guardrails, a healthy setup checklist, two sample workflows and rules written for agents.

Published 2026-11-26 · 6 min read

Machine-readable APIhttps://www.authmarks.com/api/v1/openapi.json
Developer page indexhttps://www.authmarks.com/llms.txt
MCP endpointhttps://www.authmarks.com/api/mcp
AuthBearer token (amk_ organization API token)
AccessRead-only

What this page gives you: a proven pattern for letting coding agents (Claude Code, Cursor, Copilot, Codex and the like) build reports and checks on Authmarks without putting anything at risk. It covers the two URLs to give the agent, the instructions that keep tokens out of prompts and repositories, a checklist for a healthy setup, two full sample workflows and a short set of rules addressed to agents themselves. The API and the MCP server are both read-only, so the most an agent can do with a properly scoped token is read data you have chosen to let it read.

Give the agent the right context

An agent writes better code when it reads the actual contract rather than guessing at it. Hand it these two URLs:

URLWhat it is
https://www.authmarks.com/api/v1/openapi.jsonThe OpenAPI 3.1 document, covering every endpoint, parameter, field and error.
https://www.authmarks.com/llms.txtA plain-text index of all the developer pages, written with language models in mind.

A solid opening prompt:

We are building an internal report on top of the Authmarks REST API.
Read https://www.authmarks.com/api/v1/openapi.json and https://www.authmarks.com/llms.txt first.
The API is read-only. The token is in the AUTHMARKS_TOKEN environment variable and the
organisation id in AUTHMARKS_ORG. Never print, log or hard-code the token.

If your agent can also use MCP, hook it up using the MCP setup so it can look at real data while it writes the code.

Guardrails to put in your agent instructions

Place these in whatever file your agent reads on every run (CLAUDE.md, AGENTS.md, .cursor/rules, or the equivalent in your tool):

## Authmarks API rules
- Base URL: https://www.authmarks.com/api/v1/orgs/$AUTHMARKS_ORG. Contract: https://www.authmarks.com/api/v1/openapi.json
- Read the token from the AUTHMARKS_TOKEN environment variable. Never ask for it, print it, log it,
  paste it into a prompt, write it to a file or commit it.
- Never put the token in browser or client-side code.
- The API is read-only (GET/HEAD). Do not write code that expects to change Authmarks data.
- Page with `limit` (max 200) and `next_cursor` until it is null. Never build cursors.
- On 429, wait the Retry-After seconds. Retry 503 with backoff. Do not retry 401/403.
- Treat student names and emails as personal data: do not print them in logs or test fixtures.
- Ids are opaque strings. Timestamps are ISO 8601 UTC.

Then give the agent its own read-only, expiring token that holds only the scopes the task calls for. See Authentication and scopes.

Healthy setup checklist

  • One token for each tool and each person (agent-cursor-jlee, report-nightly-ci), never a shared token.
  • Just the scopes the job requires. Grant records_read only where the job needs student submissions.
  • An expiry on every agent token, kept as short as the job allows.
  • Tokens kept in environment variables or a secrets manager, never in code, prompts or chat.
  • .env listed in .gitignore, plus a secret-scanning rule for amk_[A-Za-z0-9_-]{43}.
  • A monthly review of last used under Settings → Developers, revoking any token nobody touches.
  • Rotation on a set schedule and whenever someone with access leaves.
  • A named owner for every scheduled job, recorded beside the job.
  • If the admin audit log streams to a SIEM, alerts on token creation and revocation (audit stream).

Student names and email addresses that pass through these jobs are personal information. At a Canadian institution, PIPEDA and provincial laws such as Ontario's FIPPA or Quebec's Law 25 generally govern how that information is handled, and your privacy office decides what that means for logs, test data and AI tools.

Workflow 1: nightly report of unsealed submissions

Goal: each night, list the submissions not yet sealed for assignments that came due in the last seven days, and send the counts to your team.

Token scopes: assignments_read, records_read.

What to ask the agent:

Write a Python script, report_unsealed.py, that:
1. Lists all assignments (page through next_cursor, limit=200).
2. Keeps assignments whose due_at is within the last 7 days.
3. For each, lists all submissions and counts sealed vs not sealed.
4. Prints one line per assignment: title, due date, sealed count, unsealed count.
Use requests. Read AUTHMARKS_TOKEN and AUTHMARKS_ORG from the environment.
Honor Retry-After on 429. Do not print student emails.

The kind of script the agent should come back with:

import os
import time
from datetime import datetime, timedelta, timezone

import requests

BASE = f"https://www.authmarks.com/api/v1/orgs/{os.environ['AUTHMARKS_ORG']}"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['AUTHMARKS_TOKEN']}"


def pages(path):
    cursor = None
    while True:
        response = session.get(f"{BASE}{path}", params={"limit": 200, "cursor": cursor}, timeout=30)
        if response.status_code == 429:
            time.sleep(int(response.headers.get("Retry-After", "60")))
            continue
        response.raise_for_status()
        body = response.json()
        yield from body["data"]
        cursor = body["next_cursor"]
        if not cursor:
            return


def parse(ts):
    return datetime.fromisoformat(ts.replace("Z", "+00:00")) if ts else None


now = datetime.now(timezone.utc)
for assignment in pages("/assignments"):
    due = parse(assignment["due_at"])
    if due is None or not (now - timedelta(days=7) <= due <= now):
        continue
    sealed = unsealed = 0
    for submission in pages(f"/assignments/{assignment['id']}/submissions"):
        if submission["sealed"]:
            sealed += 1
        else:
            unsealed += 1
    print(f"{assignment['title']}\tdue {due:%Y-%m-%d}\tsealed {sealed}\tunsealed {unsealed}")

Schedule it in CI, keeping the token as an encrypted CI secret:

# .github/workflows/authmarks-nightly.yml
on:
  schedule: [{ cron: "0 6 * * *" }]
jobs:
  report:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install requests && python report_unsealed.py
        env:
          AUTHMARKS_TOKEN: ${{ secrets.AUTHMARKS_TOKEN }}
          AUTHMARKS_ORG: ${{ vars.AUTHMARKS_ORG }}

Workflow 2: LMS health check that alerts on failed grade returns

Goal: every 15 minutes, check for connections still waiting for approval and for grade returns that failed during the past hour, and raise an alert if there are any. Handy for a campus team supporting D2L Brightspace, Canvas or Moodle.

Token scope: lms_read alone.

// lms-health.mjs  (Node.js 18+)
const BASE = `https://www.authmarks.com/api/v1/orgs/${process.env.AUTHMARKS_ORG}`;
const headers = { Authorization: `Bearer ${process.env.AUTHMARKS_TOKEN}` };
const since = Date.now() - 60 * 60 * 1000;

async function get(path) {
  const response = await fetch(`${BASE}${path}`, { headers });
  if (!response.ok) {
    throw new Error(`${path}: HTTP ${response.status}`);
  }
  return response.json();
}

const problems = [];
const connections = await get("/lms-connections");

for (const connection of connections.data) {
  if (connection.status === "pending") {
    problems.push(`${connection.label}: waiting for approval since ${connection.created_at}`);
  }
  if (connection.status !== "active") continue;

  // Do not assume an order: filter by time on every page.
  let cursor = null;
  do {
    const query = new URLSearchParams({ limit: "200" });
    if (cursor) query.set("cursor", cursor);
    const page = await get(`/lms-connections/${connection.id}/grade-returns?${query}`);
    for (const ret of page.data) {
      if (ret.status === "failed" && Date.parse(ret.created_at) >= since) {
        problems.push(`${connection.label}: grade return ${ret.id} failed at ${ret.created_at}`);
      }
    }
    cursor = page.next_cursor;
  } while (cursor);
}

if (problems.length > 0) {
  await fetch(process.env.ALERT_WEBHOOK_URL, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text: `Authmarks LMS health:\n${problems.join("\n")}` }),
  });
  process.exitCode = 1;
}

ALERT_WEBHOOK_URL points to your own chat or paging webhook (Slack, Teams, PagerDuty). How to fix failed returns is explained in Troubleshooting LTI and Grades and roster.

You can ask the same question interactively over MCP: "List grade returns that failed in the last hour for every active connection."

For agents: rules to follow

If you are an AI agent working with Authmarks, keep to these rules:

  1. Read https://www.authmarks.com/api/v1/openapi.json before you write any API code. Do not make up endpoints or fields.
  2. The API and the MCP server are read-only. Nothing can be created, changed or deleted through them, so do not try.
  3. Take the token only from the AUTHMARKS_TOKEN environment variable. Never print it, log it, echo it in shell commands, save it to files, put it in commits or ask the user to paste it into the conversation.
  4. Never put the token in browser, mobile or extension code.
  5. Send Authorization: Bearer <token>. Never place the token in a URL.
  6. Page using limit (1 to 200) and cursor until next_cursor is null. Never construct or alter cursors.
  7. On 429, wait for Retry-After seconds. Retry 503 with backoff. Never retry 401 or 403; tell the user which scope or token is at fault.
  8. Handle student.name and student.email as personal information. Keep them out of logs, fixtures, issues and summaries unless the user asked for them.
  9. Treat ids as opaque strings and timestamps as ISO 8601 UTC.
  10. The API returns no scores or percentages. Do not infer or describe any about a student's writing.
  11. If a scope is missing, tell the user which scope to add, and that an owner or admin creates tokens under Settings → Developers.

Sources

Change notes

  • 2026-11-26 — First published.

Spotted an error? Email sales@authmarks.com and we will correct the page and date the correction.