← Back to blog

Teams API: Shared Credits, Team Keys & Audit Trail

October 9, 2026 · Eric · 9 min read

One API key works beautifully for one person. The moment a second person joins — a contractor automating invoices, an analyst running OCR batches, an ops engineer firing webhook tests at 2 a.m. — the solo model breaks in three predictable ways: everybody shares one credential, nobody can tell whose traffic caused the bill, and there is no ceiling on what any single caller can burn.

Agent Media Tools solves that with a Teams workspace: seats with roles, a pooled credit balance, team-owned agent keys with their own monthly caps, and an audit trail you can read over the API. This guide walks the whole surface with curl and Python — every endpoint below is verified against the shipped code.

What a team actually gets

The pricing page lists Teams at $24/month for five members. Under the hood that maps to concrete, queryable limits — not marketing copy:

Two credentials, two jobs

This is the part that trips people up, so let's be explicit. The Teams API uses two different credential types:

CredentialUsed forHeader
Session cookieAdministering the team (invites, roles, keys, billing, audit)Cookie: connect.sid=…
Team API key (mt_…)Agents actually calling tools — debits the shared poolAuthorization: Bearer mt_…

Team keys can spend the pool, but they cannot administer the team. Membership routes require a signed-in session, which is why a leaked production key can never invite a stranger or create new keys. That asymmetry is deliberate.

For session-authenticated writes, the service checks the request's Origin (or Referer) header — there is no separate CSRF token to fetch. A plain curl call that sends no origin header is accepted; if you do send one, it has to match the site host, or you'll get 403 Cross-site request rejected.

Step 1: Sign in and read the workspace

Log in once and let curl keep the cookie in a jar:

curl -s -c teams.cookies -X POST https://agentmediatools.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username":"you@example.com","password":"••••••••"}'

# {"success":true,"user":{"username":"…","display_name":"…","daily_limit":1000}}

Login accepts either a username or an email address. Now describe the workspace:

curl -s -b teams.cookies https://agentmediatools.com/api/teams/current

The response is a single object with everything the dashboard renders — and everything a script needs to reconcile:

{
  "success": true,
  "team": {
    "id": 12,
    "name": "Media Ops",
    "role": "owner",
    "owner_user_id": 41,
    "seat_limit": 5,
    "members": [
      { "id": 41, "username": "eric", "email": "…", "role": "owner",  "joined_at": "2026-10-09 16:02:10" },
      { "id": 57, "username": "dana", "email": "…", "role": "member", "joined_at": "2026-10-09 16:20:44" }
    ],
    "invites": [
      { "id": 3, "email": "contractor@example.com", "role": "member",
        "expires_at": "2026-10-16 16:31:02", "created_at": "2026-10-09 16:31:02" }
    ],
    "can_manage": true,
    "current_user_id": 41
  }
}

Two details worth noting. First, the invites array is only populated for owners and admins — a member sees [], not an error. Second, if the account isn't in a team, the response is {"success":true,"team":null}, so your script can branch without catching an exception.

A Teams subscription creates its workspace automatically when the subscription activates, so most people never touch the creation endpoint. If you have a Teams plan but no team row — for example after a support-side cleanup — this exists:

curl -s -b teams.cookies -X POST https://agentmediatools.com/api/teams \
  -H "Content-Type: application/json" -d '{"name":"Media Ops"}'

It returns 403 unless the account's plan is teams and 409 if the account is already in a team.

Step 2: Invite teammates

Invitations are email-bound, token-based, and expire after seven days. Owners and admins can send them; the endpoint is rate-limited to 20 per hour per account.

curl -s -b teams.cookies -X POST https://agentmediatools.com/api/teams/invites \
  -H "Content-Type: application/json" \
  -d '{"email":"contractor@example.com","role":"member"}'

# 201 {"success":true,"invite":{"email":"contractor@example.com","role":"member","expires_in_days":7}}

Valid roles on an invite are admin or member — you can't invite a second owner. The recipient gets an email with a link to /teams?invite=…; accepting it consumes a seat and requires that they sign in with the invited address:

curl -s -b invitee.cookies -X POST https://agentmediatools.com/api/teams/invites/accept \
  -H "Content-Type: application/json" \
  -d '{"token":"TOKEN_FROM_THE_EMAIL"}'

Failure modes are explicit, which makes them easy to handle in a script: 409 Team seat limit reached (5) when occupied seats plus pending invites hit the cap, 409 A pending invitation already exists for that email, 403 Sign in with the invited email address, or 404 Invitation is invalid or expired. Revoke a pending invite before it's accepted with:

curl -s -b teams.cookies -X DELETE https://agentmediatools.com/api/teams/invites/3

Step 3: Manage roles and removal

Promote someone to admin (owner session required), then demote or remove them the same way:

curl -s -b teams.cookies -X PATCH https://agentmediatools.com/api/teams/members/57 \
  -H "Content-Type: application/json" -d '{"role":"admin"}'

curl -s -b teams.cookies -X DELETE https://agentmediatools.com/api/teams/members/57

Owners and admins can both remove plain members, but only the owner can remove or alter another admin — an admin can't quietly evict a peer. The owner row itself is protected: role updates skip it and deletion refuses it. Renaming the workspace is a one-liner, with the name validated between 2 and 80 characters:

curl -s -b teams.cookies -X PATCH https://agentmediatools.com/api/teams/current \
  -H "Content-Type: application/json" -d '{"name":"Media Ops (EU)"}'

Step 4: Create team keys with their own caps

This is where the shared pool meets least-privilege. Team keys are ordinary agent keys (mt_ prefix) attached to the team, and each one carries a monthly credit cap of its own:

curl -s -b teams.cookies -X POST https://agentmediatools.com/api/teams/keys \
  -H "Content-Type: application/json" \
  -d '{"name":"invoice-pipeline","monthly_credit_limit":100}'

# 201 {"success":true,"key":"mt_…","prefix":"mt_ab12cd","name":"invoice-pipeline",
#      "monthly_credit_limit":100,"note":"Shown once. Store securely."}

The full key is returned exactly once — store it in your secret manager, not in a shell history file. Caps must be a whole number between 0 and 500, and a team can hold at most 20 active keys. Adjust a cap or revoke a key as your fleet changes:

curl -s -b teams.cookies -X PATCH https://agentmediatools.com/api/teams/keys/9 \
  -H "Content-Type: application/json" -d '{"monthly_credit_limit":250}'

curl -s -b teams.cookies -X DELETE https://agentmediatools.com/api/teams/keys/9

Revocation is soft: the key stops authenticating but its row survives, which keeps the credit history attributable. One gotcha worth internalizing — team keys do not appear in the personal key list at GET /api/agent/keys. If you build a key inventory, read it from GET /api/teams/credits.

Step 5: Watch the pool

The credits endpoint returns three useful arrays in one call: the pool balance, the team keys, and the most recent 100 credit movements.

curl -s -b teams.cookies https://agentmediatools.com/api/teams/credits
{
  "success": true,
  "credits": { "team_id": 12, "balance": 1240, "rollover_cap": 1500,
               "expires_at": null, "updated_at": "2026-10-09 16:44:03" },
  "keys": [
    { "id": 9, "key_prefix": "mt_ab12cd", "name": "invoice-pipeline",
      "is_active": true, "team_monthly_credit_limit": 100,
      "created_at": "2026-10-09 16:40:11", "last_used_at": "2026-10-09 16:41:52" }
  ],
  "usage": [
    { "id": 501, "key_id": 9, "amount": 3, "kind": "debit",
      "created_at": "2026-10-09 16:41:52",
      "key_name": "invoice-pipeline", "key_prefix": "mt_ab12cd" }
  ]
}

Every member (not just admins) can read this, so a teammate can always self-check their own headroom. When a team key calls a paid tool, the charge hits the shared pool and is recorded against that key. Two guards fire before anything is debited:

Failed jobs refund the charge back to the pool, so you're not billed twice for a retry. If you want the same kind of hard guard on the personal side, the per-key spend policy adds allow-lists and ceilings to ordinary agent keys.

A Python reporting script

Here's the whole workflow as an operator script: sign in, print per-key consumption for the month, and flag any key that is close to its cap.

import os, requests
from datetime import datetime, timedelta

BASE = "https://agentmediatools.com"
s = requests.Session()
r = s.post(f"{BASE}/api/login", json={
    "username": os.environ["AMT_EMAIL"],
    "password": os.environ["AMT_PASSWORD"],
}, timeout=15)
r.raise_for_status()

data = s.get(f"{BASE}/api/teams/credits", timeout=15).json()
team = data["credits"]
print(f"pool: {team['balance']} / rollover cap {team['rollover_cap']}")

month_start = datetime.utcnow().replace(day=1, hour=0, minute=0, second=0)
spend = {}
for row in data["usage"]:
    when = datetime.strptime(row["created_at"], "%Y-%m-%d %H:%M:%S")
    if when < month_start:
        continue
    delta = row["amount"] if row["kind"] == "debit" else -row["amount"]
    spend[row["key_id"]] = spend.get(row["key_id"], 0) + delta

for key in data["keys"]:
    used = spend.get(key["id"], 0)
    cap = key["team_monthly_credit_limit"]
    flag = "  <-- near cap" if cap and used >= cap * 0.8 else ""
    print(f"{key['name'] or key['key_prefix']:<24} {used:>4}/{cap:<4} "
          f"{'active' if key['is_active'] else 'revoked'}{flag}")

Because usage rows are capped at the most recent 100, this is a monitoring view rather than an accounting ledger — if you need exact monthly totals at high volume, aggregate on your side as the data comes in.

Audit: who changed what

Owners and admins can pull the team's change history. Events are newest-first, capped at the latest 100, and cover the operations that actually matter for an incident review:

curl -s -b teams.cookies https://agentmediatools.com/api/teams/audit
{
  "success": true,
  "events": [
    { "id": 88, "actor_user_id": 41, "action": "team_key.created",
      "target_user_id": null, "detail": "mt_ab12cd", "created_at": "2026-10-09 16:40:11" },
    { "id": 87, "actor_user_id": 41, "action": "member.joined",
      "target_user_id": 57, "detail": null, "created_at": "2026-10-09 16:20:44" }
  ]
}

The action vocabulary is small and stable: team.created, team.renamed, invite.created, invite.revoked, member.joined, member.role_changed, member.removed, and team_key.created. Note that detail can carry an invited email address, so treat the audit feed as internal data when you forward it into a logging pipeline.

Shared monitoring rides along

Teams also changes what the Agent QA monitor endpoints return. Pass team_id on create, list, run, or delete and the monitor belongs to the workspace instead of one person — with a 100-monitor ceiling for the team and failure emails routed to the owners and admins. The monitor mechanics themselves are covered in the Agent QA guide; the team angle is simply that access is scoped, and members can view and run what admins configure.

Honest boundaries

If you're deciding which side of the line a workload belongs on: personal automation and one-person pipelines stay on ordinary keys with the spend policy, while anything two or more humans need to share, cap, and review belongs in a team workspace with its own keys and audit trail.

Set up your team workspace

Invite your team, mint capped keys for each pipeline, and watch the shared pool from the dashboard or the API.

Open Teams