Developers

Building with AI agents on the Authmarks API: setup, guardrails and workflows for Indian institutions

A practical guide for university IT cells and developer teams in India using coding agents with Authmarks: the context to give the agent, token guardrails, a sound setup checklist, two sample workflows and rules agents can follow.

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_ organisation API token)
AccessRead-only

What this guide offers: a proven pattern for letting coding agents (Claude Code, Cursor, Copilot, Codex and others) build reports and checks on top of Authmarks safely. You will see which two URLs to give the agent, which instructions keep tokens out of prompts and repositories, a checklist for a sound setup, two complete sample workflows, and a short list of rules written for the agents themselves. Since the API and the MCP server are read-only, the most an agent can do with a correctly scoped token is read data you have allowed it to read.

Whether your institution's integrations are built by the university IT cell, a small in-house team or a vendor under contract, the same pattern applies.

Give the agent the right context

Agents produce better code when they read the actual contract rather than guessing. Hand them two URLs:

URLWhat it contains
https://www.authmarks.com/api/v1/openapi.jsonThe OpenAPI 3.1 document: each endpoint, parameter, field and error.
https://www.authmarks.com/llms.txtA plain-text index of all developer pages, written for language models.

A sound 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 the agent also supports MCP, connect it using the MCP setup so that it can explore real data while writing the code.

Guardrails to put in your agent instructions

Place these in the file your agent reads on each run (CLAUDE.md, AGENTS.md, .cursor/rules, or the equivalent for 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.

Also give the agent a dedicated, read-only, expiring token that carries only the scopes the task requires. Refer to Authentication and scopes.

Healthy setup checklist

  • A separate token for each tool and each person (agent-cursor-jlee, report-nightly-ci), never a shared one.
  • Only the scopes the task requires. records_read only where student submissions are actually needed.
  • An expiry on every agent token, as short as the task permits.
  • 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 in Settings → Developers, revoking tokens that nobody uses.
  • Scheduled rotation, and rotation whenever someone with access leaves.
  • A named owner for each scheduled job, recorded alongside the job.
  • If you stream the admin audit log to a SIEM, alerts on token creation and revocation (audit stream).

Workflow 1: nightly report of unsealed submissions

Aim: each night, list submissions not yet sealed for assignments that fell due in the last seven days, and send the counts to your team, for example the faculty coordinating internal assessment for the semester.

Token scopes: assignments_read, records_read.

Prompt for 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.

A script of the kind the agent should produce:

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}")

Run it on a schedule from CI, with the token held 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

Aim: every 15 minutes, check for connections awaiting approval and for grade returns that failed in the last hour, and raise an alert if any are found.

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 is your own chat or paging webhook (Slack, Teams, PagerDuty). Resolving failed returns is explained in Troubleshooting LTI and Grades and roster.

You can ask the same question interactively through 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, observe these rules:

  1. Read https://www.authmarks.com/api/v1/openapi.json before you write API code. Do not make up endpoints or fields.
  2. The API and MCP server are read-only. They offer no way to create, modify or delete data. Do not try.
  3. Take the token only from the AUTHMARKS_TOKEN environment variable. Never print it, log it, echo it in shell commands, write 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. Use Authorization: Bearer <token>. Never place the token in a URL.
  6. Page with limit (1 to 200) and cursor until next_cursor is null. Do not construct or alter cursors.
  7. On 429, wait Retry-After seconds. Retry 503 with backoff. Do not retry 401 or 403; report which scope or token is at fault.
  8. Handle student.name and student.email as personal data. In India, the Digital Personal Data Protection Act, 2023 governs how organisations process such data, so do not copy them into logs, fixtures, issues or summaries unless the user has 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 in 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.