sherwood
developers<- back

plug into the grid.

build on sherwood. shared auth, optional credits, zero headaches.

{ }

free apps

Just want shared sign-in? Use the Clerk auth keys below. your users get one account across all Sherwood apps. No API key needed, no credits, completely free.

.env
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZW5nYWdpbmctYnVsbGZyb2ctNDguY2xlcmsuYWNjb3VudHMuZGV2JA CLERK_JWKS_URL=https://engaging-bullfrog-48.clerk.accounts.dev/.well-known/jwks.json
$

paid apps

Want to charge for features? Add the Sherwood credit API. Users buy credits on Sherwood and spend them in your app. You earn 85% of net revenue from every credit spent. Start in test mode, go live when ready.

scroll down to get started ↓

1. Get Your API Key

Sign in to generate an API key.

sign in first, king.

2. Add to Your App

Add these environment variables. The Clerk keys let your users sign in with their Sherwood account (same account, same credits everywhere). The API key authenticates your server.

.env
# Sherwood Credit API SHERWOOD_API_URL=https://www.sherwood.app SHERWOOD_API_KEY=kv_your_key_here # Clerk Auth (shared with Sherwood, same user accounts) NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZW5nYWdpbmctYnVsbGZyb2ctNDguY2xlcmsuYWNjb3VudHMuZGV2JA CLERK_JWKS_URL=https://engaging-bullfrog-48.clerk.accounts.dev/.well-known/jwks.json

The Clerk publishable key is safe to share, it's already public in the frontend. Your users sign in once and their credits work across all Sherwood-powered apps.

3. Check Balance

Before a paid action, check the user's balance (or just attempt to spend. it'll return 402 if insufficient).

curl
curl "https://www.sherwood.app/api/credits/balance?user_id=user_abc123" \ -H "x-api-key: $SHERWOOD_API_KEY" # Response: # { "user_id": "user_abc123", "balance": 20, "lifetime": 50 }

4. Spend Credits

When a user does a paid action (generate, refresh, etc.), spend credits via the API.

curl
curl -X POST "https://www.sherwood.app/api/credits/spend" \ -H "x-api-key: $SHERWOOD_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"user_abc123","amount":2,"description":"generate report"}' # Success (200): # { "ok": true, "balance": 18, "spent": 2, "transaction_id": "tx-..." } # Insufficient credits (402): # { "error": "insufficient credits", "balance": 0, "required": 2 }

5. Handle Low Credits

When a spend returns 402, let users buy credits without leaving your app. Call the checkout API from your backend, then redirect to Stripe.

your backend
// 1. Fetch available packs (optional — or just hardcode pack IDs) const packsRes = await fetch("https://www.sherwood.app/api/credits/checkout-for-app", { headers: { "x-api-key": SHERWOOD_API_KEY }, }); const { packs } = await packsRes.json(); // 2. When user picks a pack, create a Stripe checkout const checkoutRes = await fetch("https://www.sherwood.app/api/credits/checkout-for-app", { method: "POST", headers: { "x-api-key": SHERWOOD_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ user_id: clerkUserId, email: userEmail, pack_id: "pack_5", // or pack_11, pack_35 success_url: "https://yourapp.com/page?purchased=1", cancel_url: "https://yourapp.com/page?cancelled=1", }), }); const { url } = await checkoutRes.json(); // 3. Redirect user to Stripe res.redirect(url); // 4. After payment, Stripe sends user to your success_url // Re-check balance there. credits are added via webhook within seconds

No Stripe account needed on your end. Sherwood handles the payment and credits the user automatically.

6. or just use the SDK

Don't want to build your own credit UI? Drop in one script tag and the SDK handles everything: balance checks, a first-time tutorial for new users, credit pack selection, and Stripe checkout. The tutorial only shows once per user.

step 1: your backend creates a session token

your server
// Your backend calls this to get a short-lived token // NEVER put your API key in frontend code const res = await fetch("https://www.sherwood.app/api/credits/session-token", { method: "POST", headers: { "x-api-key": process.env.SHERWOOD_API_KEY, // server-side only! "Content-Type": "application/json", }, body: JSON.stringify({ user_id: clerkUserId, email: userEmail, }), }); const { token } = await res.json(); // Pass 'token' to your frontend

step 2: frontend uses the session token

html
<script src="https://www.sherwood.app/sdk/sherwood-credits.js"></script> <script> // sessionToken came from your backend (see step 1) const credits = new SherwoodCredits({ sessionToken: "{{ sessionToken }}", // short-lived, safe for browser }); // When user clicks a paid button: credits.spend({ amount: 2, actionLabel: "Generate report", description: "generated monthly report", onSuccess: (result) => { console.log("Credits spent!", result.balance); }, onCancel: () => { console.log("User cancelled"); }, successUrl: window.location.href + "?purchased=1", }); </script>

What the SDK does automatically:

Checks the user's credit balance
Shows a first-time tutorial explaining credits (only once)
If balance is low, shows credit packs to buy
Handles Stripe checkout and redirect
Auto-completes the action after purchase
Shows "powered by Sherwood" badge

you get paid.

Every credit spent in your app earns you 85% of net revenue. Sherwood keeps 15% as a platform fee. Payouts happen monthly once you hit $100 USD minimum via Stripe Connect.

View my apps & earnings →