MyClaude Docs
MyClaude Docs

Getting Started

Buyers

Creators

CLI

API

Agent Integration

Developers

ContributingSelf-HostingWebhooks & IntegrationDesign System ReferenceData Model ReferenceAdmin Panel

Security

Legal

Developers

Webhooks & Integration

Reference for Stripe webhook events, payload handling, idempotency, rate limits across all 26 API routes, and integration points for CLI and MCP.

ReferenceUpdated 2026-03-26

Reference for Stripe webhook events, integration points, and rate limits across all API routes.

Stripe webhooks

MyClaude listens for Stripe events at a single endpoint:

POST /api/stripe/webhooks

This endpoint is exempt from CSRF origin checks and Bearer token auth. It authenticates exclusively via Stripe webhook signature verification.

Handled events

EventAction
checkout.session.completedCreates order, updates product stats, credits XP to buyer and seller
charge.refundedMarks order as refunded, reverses seller revenue and stats, notifies seller
account.updatedUpdates seller stripeOnboarded status when charges_enabled becomes true

All other event types are acknowledged with 200 and silently ignored.

Webhook security

Signature verification

Every incoming webhook is verified using stripe.webhooks.constructEvent() with the STRIPE_WEBHOOK_SECRET. Requests with missing or invalid signatures receive 400 and are not processed.

Request arrives
    |
    v
Extract stripe-signature header
    |
    v
constructEvent(body, signature, secret)
    |-- Invalid --> 400 (no retry)
    |-- Valid   --> Process event

Idempotency

Order creation uses the Stripe session ID as the Firestore document ID. This guarantees idempotency:

  • First delivery: transaction creates the order document
  • Retry delivery: transaction reads the existing document, detects duplicate, skips creation
  • No duplicate orders, no duplicate stat increments

The check runs inside a Firestore transaction, so concurrent webhook retries are also safe.

Atomic order creation

The checkout.session.completed handler executes a single Firestore transaction that atomically:

  1. Creates the orders/{sessionId} document
  2. Increments products/{id}.stats.purchaseCount
  3. Increments users/{sellerId}.stats.totalRevenue and stats.totalSales, adds 50 XP
  4. Increments users/{buyerId}.stats.productsBought, adds 10 XP

If any step fails, the entire transaction rolls back. Stripe receives 503, which triggers automatic retry with exponential backoff.

Price verification

The webhook handler re-reads the product price from Firestore and cross-checks against session.amount_total. If a price change occurred between checkout creation and webhook delivery, the discrepancy is logged but the order is still created using Stripe's authoritative amount (what was actually charged).

Platform fee is recalculated server-side at 8% of the actual charged amount -- never from client metadata.

Refund handling

The charge.refunded handler:

  1. Looks up the order by stripePaymentIntentId
  2. Runs an atomic transaction: sets status: "refunded", decrements seller revenue and sales count, decrements buyer purchase count
  3. Creates a notification in the seller's notifications subcollection (fire-and-forget, outside transaction)

Already-refunded orders are skipped (idempotent).

Integration points

CLI (myclaude)

The myclaude CLI communicates with dedicated API routes optimized for terminal output.

CLI commandAPI routeAuth
myclaude searchGET /api/cli/products/searchNone
myclaude publishPOST /api/cli/products/createRequired
myclaude whoamiGET /api/cli/auth/profileRequired

All CLI commands support a --json flag for machine-readable output, suitable for piping into jq or downstream scripts.

MCP server

MyClaude exposes tools via Model Context Protocol for agent integration. Agents can search products, read metadata, and trigger installations through MCP tool calls. See the MCP Tool Schemas reference for the full tool catalog.

Docs A-Surface

Requests to /docs.md or /docs/{slug}.md are rewritten to return raw Markdown content from the documentation system. This enables AI agents to fetch docs context without parsing HTML.

Rate limits

All routes are rate-limited per IP address within a 60-second window. Two strategies exist:

StrategyOn limit exceededOn limiter failure
Standard429Fail-open (allows request)
Strict429Fail-closed (503)

Complete rate limit table

RouteMethodLimitStrategyAuth
/stripe/checkoutPOST10/minStrictRequired
/stripe/connectPOST5/minStrictRequired
/stripe/webhooksPOST----Stripe signature
/stripe/callbackGET----Redirect
/products/downloadPOST30/minStrictRequired
/products/uploadPOST10/minStrictRequired
/products/scanPOST10/minStrictRequired
/products/likePOST30/minStrictRequired
/products/reviewsGET30/minStandardOptional
/products/reviewsPOST5/minStrictRequired
/products/self-approvePOST20/minStrictRequired
/users/update-profilePOST5/minStrictRequired
/users/followPOST30/minStrictRequired
/users/delete-accountDELETE1/minStrictRequired
/reportsPOST10/minStrictRequired
/messagesGET60/minStandardRequired
/messagesPOST20/minStrictRequired
/messages/{id}GET60/minStandardRequired
/admin/products/{id}/approvePOST10/minStrictAdmin
/admin/products/{id}/removePOST10/minStrictAdmin
/admin/reportsGET30/minStandardAdmin
/admin/reports/{id}/resolvePOST10/minStrictAdmin
/admin/users/{id}/banPOST5/minStrictAdmin
/cli/products/searchGET30/minStandardNone
/cli/auth/profileGET30/minStandardRequired
/cli/products/createPOST5/minStrictRequired

Rate limit response

When a rate limit is exceeded, the API returns:

HTTP/1.1 429 Too Many Requests
Retry-After: 42

{
  "error": "Too many requests"
}

The Retry-After header indicates seconds until the window resets.

Error codes

All API errors follow a consistent JSON format:

{
  "error": "Human-readable error message"
}
StatusMeaningCommon causes
400Bad RequestMissing parameters, invalid metadata, business rule violation
401UnauthorizedMissing or expired Bearer token
403ForbiddenInsufficient permissions, banned user, CSRF origin mismatch
404Not FoundResource does not exist or is unpublished
409ConflictDuplicate purchase, duplicate review, username taken
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected failure
503Service UnavailableDependency down, or strict rate limiter failure

For the full error taxonomy, see /specs/error-codes.yaml in the repository.

Related pages

  • API Overview -- Base URL, auth model, endpoint groups
  • Payments API -- Checkout and Connect endpoint details
  • Security Model -- Architecture-level security controls
  • MCP Tool Schemas -- Agent integration reference
  • Self-Hosting -- Deployment and webhook configuration

Self-Hosting

Deploy your own MyClaude marketplace instance with Firebase, Stripe Connect, Cloudflare R2, and Vercel or a standalone Node.js server.

Design System Reference

Complete reference for MyClaude's design system: color tokens, typography scale, surfaces, glow shadows, motion, z-index, spacing, component inventory, and the token-only enforcement policy.

On this page

Stripe webhooksHandled eventsWebhook securitySignature verificationIdempotencyAtomic order creationPrice verificationRefund handlingIntegration pointsCLI (myclaude)MCP serverDocs A-SurfaceRate limitsComplete rate limit tableRate limit responseError codesRelated pages