Skip to main content

Get Billing Info

GET /billing
Get the current billing status for your tenant.
curl https://api.meshai.dev/billing \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": {
    "plan": "professional",
    "active_agents": 47,
    "agent_limit": 100,
    "billing_period_start": "2026-03-01T00:00:00Z",
    "billing_period_end": "2026-03-31T23:59:59Z",
    "monthly_cost_usd": 799.00,
    "features": {
      "anomaly_detection": true,
      "governance_policies": "unlimited",
      "hitl_approvals": true,
      "risk_classification": true,
      "audit_trail_retention_days": 365,
      "eu_ai_act_compliance": "basic",
      "fria_support": false,
      "incident_reporting": false,
      "sso": false
    },
    "payment_method": {
      "type": "card",
      "last_four": "4242",
      "expiry": "12/2027"
    }
  }
}

Checkout (Change Plan)

POST /billing/checkout
Initiate a plan change. Returns a checkout URL for payment if upgrading, or confirms the downgrade if moving to a lower tier.
curl -X POST https://api.meshai.dev/billing/checkout \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "plan": "enterprise" }'
{
  "success": true,
  "data": {
    "action": "upgrade",
    "from_plan": "professional",
    "to_plan": "enterprise",
    "prorated_amount_usd": 1200.00,
    "checkout_url": "https://checkout.meshai.dev/session/cs_abc123",
    "expires_at": "2026-03-17T11:00:00Z"
  }
}
{
  "success": true,
  "data": {
    "action": "downgrade",
    "from_plan": "professional",
    "to_plan": "starter",
    "effective_date": "2026-04-01T00:00:00Z",
    "message": "Downgrade will take effect at the start of the next billing cycle. Ensure you have 25 or fewer active agents by then."
  }
}
Valid plan values: starter, professional, enterprise. For Enterprise Plus, contact sales.

Webhook

POST /billing/webhook
Endpoint for payment provider webhooks (Stripe). This endpoint is called by the payment provider, not by your application.

Webhook Events

EventDescription
checkout.completedPayment successful, plan upgraded
invoice.paidMonthly invoice paid
invoice.payment_failedPayment failed — retry scheduled
subscription.canceledSubscription canceled

Verifying Webhooks

MeshAI verifies webhook signatures automatically. If you’re self-hosting, configure the webhook signing secret in your environment:
STRIPE_WEBHOOK_SECRET=whsec_...

Webhook Payload Example

{
  "event": "checkout.completed",
  "tenant_id": "tnt_abc123",
  "plan": "enterprise",
  "amount_usd": 1999.00,
  "timestamp": "2026-03-17T10:30:00Z"
}