Get startedQuickstart
Sell your first key
with the API.
Create a product, give it keys, put it on sale, and have your server told the moment someone pays. Your store is live from day one, so one live key does every step. Once anyshop has approved your store, you check the whole flow with one real purchase, then refund it.
Step 1: Make an API key
In the dashboard, open Developers, API keys, and choose New API key. Give it products:write, stock:write, webhooks:write, checkouts:write and orders:write (it asks for your two-factor code if two-factor is on). The key is shown once; keep it in your server's environment, never in a browser or an app.
ANYSHOP_LIVE_KEY=as_live_7Fq2...Q7pXStep 2: Create the productlive key
A product starts as a draft. Its price is an integer in minor units of your store's currency: 1999 is $19.99. Send an Idempotency-Key so a retry after a timeout never makes two products.
curl https://api.anyshop.io/v1/products \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY" \
-H "Idempotency-Key: first-product-1" \
-H "Content-Type: application/json" \
-d '{
"name": "Lumen Studio Pro",
"type": "serial",
"price": 1999,
"platform": "Windows and macOS",
"delivery_instructions": "In Lumen Studio Pro, choose Help, Enter license key, and paste this key."
}'{
"object": "product",
"id": "prod_01m3rr5kmbeb2s18x1kpntjxqb",
"slug": "lumen-studio-pro",
"status": "draft",
"currency": "USD",
"variants": [
{ "id": "var_01m3rr5kmd6h0q2t8w4y9zb7ce", "name": "Standard", "price": 1999 }
],
"published_at": null
}Step 3: Add keys to its stocklive key
These are the keys your buyers get, so add real ones. Duplicates within the upload and keys already in stock are left out and counted, never added twice.
curl \
https://api.anyshop.io/v1/products/prod_01m3rr5kmbeb2s18x1kpntjxqb/stock_items \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY" \
-H "Content-Type: application/json" \
-d '{ "keys": ["LUMEN-K2LM-3F9Q", "LUMEN-P8WN-4H7R", "LUMEN-P8WN-4H7R"] }'{
"object": "stock_upload",
"product": "prod_01m3rr5kmbeb2s18x1kpntjxqb",
"livemode": true,
"submitted": 3,
"added": 2,
"repeated_in_upload": 1,
"already_in_stock": 0
}Step 4: Put it on salelive key
Publishing makes the product active. A serial key product can go on sale with no stock; it shows as sold out until keys arrive.
curl -X POST \
https://api.anyshop.io/v1/products/prod_01m3rr5kmbeb2s18x1kpntjxqb/publish \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY"Step 5: Tell anyshop where to send eventslive key
Add a webhook endpoint for order.paid and order.refunded. It must be a public https address; anyshop never follows redirects or calls private networks. The answer holds the signing secret, shown this once.
curl https://api.anyshop.io/v1/webhook_endpoints \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/anyshop",
"events": ["order.paid", "order.refunded"] }'{
"object": "webhook_endpoint",
"id": "whe_01m3rs9d2f4k6m8p0r2t4v6x8z",
"livemode": true,
"signing": "hmac",
"status": "enabled",
"secret": {
"object": "webhook_secret",
"algorithm": "hmac",
"value": "whsec_Q3s9mV1...kP4="
}
}Step 6: Verify, then act
Events are signed with Standard Webhooks, so any Standard Webhooks library checks them. Verify against the raw body, answer with a 2xx quickly, and do the slow work after. The same event can arrive twice: use its webhook-id header to do the work once.
import express from "express";
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.ANYSHOP_WEBHOOK_SECRET); // whsec_...
const app = express();
app.post("/anyshop", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body, req.headers);
} catch {
return res.sendStatus(400);
}
if (event.type === "order.paid") {
// yours: do it once per req.headers["webhook-id"]
grantAccess(event.data.buyer.email, event.data.items);
}
res.sendStatus(204);
});
app.listen(3000);Step 7: Buy it once, for reallive key
Once anyshop has approved your store, and Stripe or PayPal is connected in Settings, Payments, start a checkout for the product's variant (variants[0].id in the product you created) and your own email. The return addresses may be your store's own address, so nothing else needs setting up.
curl https://api.anyshop.io/v1/checkout_sessions \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY" \
-H "Content-Type: application/json" \
-d '{
"variant": "var_01m3rr5kmd6h0q2t8w4y9zb7ce",
"buyer_email": "you@example.com",
"success_url": "https://your-store.anyshop.io/",
"cancel_url": "https://your-store.anyshop.io/"
}'Open the session's url and pay with your own card or PayPal account. The key is delivered on the spot, the order is listed under Orders, and your server gets this:
{
"type": "order.paid",
"timestamp": "2026-10-02T14:32:05.112Z",
"data": {
"object": "order",
"id": "ord_01m3rt5x2c7q9f0a4d6k8h1n3p",
"number": 1001,
"livemode": true,
"status": "paid",
"currency": "USD",
"total": 1999,
"buyer": { "email": "you@example.com" },
"paid_with": "stripe",
"withdrawal_consent": null,
"items": [
{
"product": { "id": "prod_01m3rr5kmbeb2s18x1kpntjxqb", "name": "Lumen Studio Pro" },
"quantity": 1,
"unit_amount": 1999
}
]
}
}Step 8: Refund itlive key
Refund the order from its page in the dashboard, or with POST /v1/orders/{id}/refund and the order's ID from order.paid. With no amount it refunds the whole order, and revoke_delivered: true also takes back the key you were sent. Send an Idempotency-Key so a retry never refunds twice.
curl \
https://api.anyshop.io/v1/orders/ord_01m3rt5x2c7q9f0a4d6k8h1n3p/refund \
-H "Authorization: Bearer $ANYSHOP_LIVE_KEY" \
-H "Idempotency-Key: first-refund-1" \
-H "Content-Type: application/json" \
-d '{ "revoke_delivered": true }'{
"object": "order",
"id": "ord_01m3rt5x2c7q9f0a4d6k8h1n3p",
"number": 1001,
"livemode": true,
"status": "refunded",
"total": 1999,
"refunded": 1999
}The money goes back the way you paid, and your server gets order.refunded. Your payment provider may keep its own fee for the payment.