API reference

Organizations

Organizations let a team share API keys, pool quota, and view aggregated usage. Every request still uses the same two-key auth model — orgs simply group keys and members under a billing parent.

Team plan required
Organization endpoints are gated to the Team plan (₹3,999/month). Free and Pro accounts can create personal API keys but cannot create orgs or invite teammates. Upgrade in billing.

Authentication

Org management endpoints authenticate with a Supabase access token (the JWT returned from POST /v1/auth/login), not with a mt_live_… proxy key. They mirror the auth model used by key management.

Roles

RoleCan do
ownerEverything. Created automatically for the user who calls POST /v1/orgs. Cannot be removed by other members.
adminInvite + remove members, view analytics. Cannot remove the owner.
memberView org details and analytics. Cannot manage members.

Create an organization

POST /v1/orgs creates a new org and adds the caller as owner. The slug is optional — if omitted, mintoken derives it from name (lowercased, non-word characters stripped, spaces hyphenated, max 50 chars).

curl -X POST https://api.mintoken.in/v1/orgs \
  -H "Authorization: Bearer <supabase-jwt>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme AI",
    "slug": "acme-ai"
  }'

# Response
# {
#   "id": "8a3c…",
#   "name": "Acme AI",
#   "slug": "acme-ai",
#   "owner_id": "…"
# }

Request body

FieldTypeNotes
namestringRequired. Display name shown in the dashboard.
slugstring?Optional. URL-safe identifier. Auto-generated from name if omitted.

List your organizations

GET /v1/orgs returns every org the caller belongs to, with their role per-org embedded on each row.

curl https://api.mintoken.in/v1/orgs \
  -H "Authorization: Bearer <supabase-jwt>"

# Response
# {
#   "organizations": [
#     {
#       "id": "8a3c…",
#       "name": "Acme AI",
#       "slug": "acme-ai",
#       "owner_id": "…",
#       "role": "owner"
#     }
#   ]
# }

Get an organization

GET /v1/orgs/{org_id}returns the org plus its full member list and the caller's role. Returns 403 if the caller is not a member.

curl https://api.mintoken.in/v1/orgs/<org_id> \
  -H "Authorization: Bearer <supabase-jwt>"

# Response
# {
#   "id": "8a3c…",
#   "name": "Acme AI",
#   "slug": "acme-ai",
#   "owner_id": "…",
#   "members": [
#     { "user_id": "…", "role": "owner",  "joined_at": "2026-04-12T…" },
#     { "user_id": "…", "role": "admin",  "joined_at": "2026-04-13T…" },
#     { "user_id": "…", "role": "member", "joined_at": "2026-04-15T…" }
#   ],
#   "your_role": "owner"
# }

Invite a member

POST /v1/orgs/{org_id}/members adds an existing mintoken user to the org by email. Requires the caller to be owner or admin.

curl -X POST https://api.mintoken.in/v1/orgs/<org_id>/members \
  -H "Authorization: Bearer <supabase-jwt>" \
  -H "Content-Type: application/json" \
  -d '{
    "user_email": "teammate@acme.ai",
    "role": "member"
  }'

# Response
# {
#   "message": "Member added",
#   "member": {
#     "org_id": "8a3c…",
#     "user_id": "…",
#     "role": "member"
#   }
# }
The invitee must already have an account
Mintoken doesn't send invite emails — the user you invite must first sign up at mintoken.dev/signup. The invite call looks them up by user_email and returns 404 User not found if no account exists.

Request body

FieldTypeNotes
user_emailstringRequired. Email of an existing mintoken user.
rolestringDefaults to member. Allowed: admin, member.

Remove a member

DELETE /v1/orgs/{org_id}/members/{user_id} removes a member. Requires owner or admin. The org owner cannot be removed.

curl -X DELETE \
  https://api.mintoken.in/v1/orgs/<org_id>/members/<user_id> \
  -H "Authorization: Bearer <supabase-jwt>"

# Response
# { "message": "Member removed" }
Removal is immediate and hard
Removed members instantly lose access to org analytics. Any API keys they created personally still work — org membership controls only access to org-scoped resources.

Organization analytics

GET /v1/orgs/{org_id}/analytics returns aggregated usage across every API key tied to the org. Useful for tracking team-wide spend and savings in one place — see Analytics for the per-key breakdown.

curl https://api.mintoken.in/v1/orgs/<org_id>/analytics \
  -H "Authorization: Bearer <supabase-jwt>"

# Response
# {
#   "total_requests": 14823,
#   "total_output_tokens": 2841902,
#   "total_tokens_saved": 6553201
# }

Response fields

FieldMeaning
total_requestsSum of proxy requests across every API key in the org.
total_output_tokensCompressed output tokens actually billed by the upstream provider.
total_tokens_savedTokens you would have paid for without mintoken. Uses the real uncompressed baseline where available, otherwise the standard 3.3x ratio estimate.

Errors

StatusMeaning
400 Failed to create organizationSlug collision or invalid input. Try a different name/slug.
403 Not a member of this organizationThe caller's account is not on the org's member list.
403 Must be owner or adminMember-management endpoints require an elevated role.
404 User not foundThe invited email doesn't match any mintoken account. Have them sign up first.
409 User is already a memberThe invitee is already on the org.
400 Cannot remove the organization ownerThe owner is permanent. Transfer ownership first if you need to remove them (contact support).