Node SDK.
One package for checkout, subscriptions, webhooks and license checks. Add your API key and call Skalp from any Node or edge runtime, with types for every response.
@skalpgg/sdk · API reference
npm install @skalpgg/sdkpnpm add @skalpgg/sdkyarn add @skalpgg/sdkbun add @skalpgg/sdk
- dependencies: 0
- modules: ESM, CommonJS, .d.ts
- runtimes: Node 20+, Bun, Deno, Vercel Edge, Cloudflare Workers
- license: MIT
One sale, four moves.
- Your server creates a checkout
checkout.create(): One call with the product and, if you like, the buyer's email and your own metadata. You get a URL back and send the buyer to it. - The buyer pays on Skalp
skalp.gg/pay/…: The hosted page takes card or crypto and handles VAT and the invoice. There is no code to write for this step. - Skalp sends a signed webhook
order.paid: Skalp posts the event to your URL. The Skalp-Signature header carries a timestamp and an HMAC-SHA256 of that timestamp and the exact body. Failed deliveries are retried, so expect duplicates. - You verify it and deliver
constructEvent(): constructEvent checks the signature against the raw body and returns a typed event. Narrow on event.type and hand over what was bought.
Quickstart
Put your API key in the environment and the client picks it up on its own: on a server, new Skalp() is all the setup there is. Create the key on the API keys page of your dashboard, bound to your store.
Installation
Runs on Node 20 or newer, Bun, Deno, Vercel Edge and Cloudflare Workers. No dependencies; types, ESM and CommonJS are included.
.env
SKALP_API_KEY=sk_live_xxx
SKALP_WEBHOOK_SECRET=your_webhook_secret
checkout.ts
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const session = await skalp.checkout.create({
productId: 'prod_xxx',
customerEmail: '[email protected]',
metadata: { userId: 'user_123' },
returnUrl: 'https://example.com/thanks',
})
console.log(session.url)
Response
{
"id": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"url": "https://skalp.gg/pay/b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d?token=eyJhbGciOi…",
"expiresAt": "2026-09-17T10:05:00.000Z",
"status": "pending"
}
Configuration
Every option is optional. Pass a string instead of an object to set only the API key.
apiKeystring: Your secret API key. Defaults to SKALP_API_KEY.webhookSecretstring: The signing secret of your webhook, used by webhooks.verify and webhooks.constructEvent. Defaults to SKALP_WEBHOOK_SECRET.baseUrlstring: Defaults to https://api.skalp.gg, or SKALP_API_URL when it is set.timeoutnumber: Milliseconds before a request is aborted. Default 30000.maxRetriesnumber: How many times a 429 is retried. Default 2; 0 turns retries off.fetchfunction: A fetch implementation to use instead of the global one, for tests or a proxy.dangerouslyAllowBrowserboolean: The client refuses to start in a browser while an API key is set, so the key cannot leak into a bundle. Turn this on only if exposing the key is acceptable.
lib/skalp.ts
import { Skalp } from '@skalpgg/sdk'
export const skalp = new Skalp({
apiKey: process.env.SKALP_API_KEY,
webhookSecret: process.env.SKALP_WEBHOOK_SECRET,
timeout: 10_000,
maxRetries: 3,
})
Frameworks
The same two routes in every framework: one sends the buyer to a hosted checkout, the other receives webhooks. The signature covers the exact bytes Skalp sent, so the webhook route must read the raw body. Pick your framework and the code follows.
Next.js: Server Action and route handler
A Server Component lists products, a Server Action redirects straight to the checkout, and the route handler reads the raw body with request.text().
lib/skalp.ts
import { Skalp } from '@skalpgg/sdk'
export const skalp = new Skalp()
app/actions.ts
'use server'
import { redirect } from 'next/navigation'
import { skalp } from '@/lib/skalp'
export async function buy(formData: FormData) {
const session = await skalp.checkout.create({
productId: String(formData.get('productId')),
returnUrl: 'https://example.com/thanks',
})
redirect(session.url)
}
app/page.tsx
import { skalp } from '@/lib/skalp'
import { buy } from './actions'
export default async function Page() {
const products = await skalp.products.list()
return products
.filter((product) => product.productType === 'ONE_TIME')
.map((product) => (
<form key={product.id} action={buy}>
<input type="hidden" name="productId" value={product.id} />
<button>
Buy {product.name} for {product.price} {product.currency}
</button>
</form>
))
}
app/api/webhooks/skalp/route.ts
import { skalp } from '@/lib/skalp'
export async function POST(request: Request) {
const body = await request.text()
const event = await skalp.webhooks.constructEvent(body, request.headers).catch(() => null)
if (!event) return new Response('Invalid signature', { status: 400 })
await handleSkalpEvent(event)
return new Response(null, { status: 200 })
}
Express: express.raw() before express.json()
Register the webhook route with express.raw() before app.use(express.json()). Once the JSON parser has run, the raw body is gone and the signature cannot be checked.
server.ts
import express from 'express'
import { Skalp } from '@skalpgg/sdk'
const app = express()
const skalp = new Skalp()
app.post('/webhooks/skalp', express.raw({ type: 'application/json' }), async (req, res) => {
const event = await skalp.webhooks.constructEvent(req.body, req.headers).catch(() => null)
if (!event) return res.status(400).send('Invalid signature')
await handleSkalpEvent(event)
res.sendStatus(200)
})
app.use(express.json())
app.post('/checkout', async (req, res) => {
const session = await skalp.checkout.create({
productId: req.body.productId,
returnUrl: 'https://example.com/thanks',
})
res.json({ url: session.url })
})
app.listen(3000)
NestJS: rawBody: true and a global module
Turn on rawBody in NestFactory.create, provide the client once in a global module and inject it by its class.
main.ts
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
async function bootstrap() {
const app = await NestFactory.create(AppModule, { rawBody: true })
await app.listen(3000)
}
bootstrap()
skalp.module.ts
import { Global, Module } from '@nestjs/common'
import { Skalp } from '@skalpgg/sdk'
@Global()
@Module({
providers: [{ provide: Skalp, useFactory: () => new Skalp() }],
exports: [Skalp],
})
export class SkalpModule {}
billing.controller.ts
import { BadRequestException, Body, Controller, HttpCode, Post, Req } from '@nestjs/common'
import type { RawBodyRequest } from '@nestjs/common'
import type { Request } from 'express'
import { Skalp } from '@skalpgg/sdk'
@Controller()
export class BillingController {
constructor(private readonly skalp: Skalp) {}
@Post('checkout')
async checkout(@Body('productId') productId: string) {
const { url } = await this.skalp.checkout.create({ productId })
return { url }
}
@Post('webhooks/skalp')
@HttpCode(200)
async webhook(@Req() req: RawBodyRequest<Request>) {
const event = await this.skalp.webhooks.constructEvent(req.rawBody ?? '', req.headers).catch(() => {
throw new BadRequestException('Invalid signature')
})
await handleSkalpEvent(event)
}
}
Hono: Cloudflare Workers, secrets from c.env
On Cloudflare Workers secrets live on c.env rather than process.env, so pass them to the client explicitly. On Bun or Node, new Skalp() reads the environment as usual.
src/index.ts
import { Hono } from 'hono'
import { Skalp } from '@skalpgg/sdk'
type Env = { Bindings: { SKALP_API_KEY: string; SKALP_WEBHOOK_SECRET: string } }
const app = new Hono<Env>()
app.post('/checkout', async (c) => {
const skalp = new Skalp({ apiKey: c.env.SKALP_API_KEY })
const { productId } = await c.req.json<{ productId: string }>()
const session = await skalp.checkout.create({ productId })
return c.json({ url: session.url })
})
app.post('/webhooks/skalp', async (c) => {
const skalp = new Skalp({ webhookSecret: c.env.SKALP_WEBHOOK_SECRET })
const event = await skalp.webhooks.constructEvent(await c.req.text(), c.req.raw.headers).catch(() => null)
if (!event) return c.text('Invalid signature', 400)
await handleSkalpEvent(event)
return c.body(null, 200)
})
export default app
Fastify: JSON as a string, in one plugin only
Add a string parser for application/json inside the webhook plugin only. It stays scoped to that plugin, so every other route keeps receiving parsed JSON.
server.ts
import Fastify from 'fastify'
import { Skalp } from '@skalpgg/sdk'
const app = Fastify()
const skalp = new Skalp()
app.post<{ Body: { productId: string } }>('/checkout', async (request) => {
const session = await skalp.checkout.create({ productId: request.body.productId })
return { url: session.url }
})
app.register(async (webhooks) => {
webhooks.addContentTypeParser('application/json', { parseAs: 'string' }, (_request, body, done) => done(null, body))
webhooks.post('/webhooks/skalp', async (request, reply) => {
const event = await skalp.webhooks.constructEvent(request.body as string, request.headers).catch(() => null)
if (!event) return reply.code(400).send('Invalid signature')
await handleSkalpEvent(event)
return reply.code(200).send()
})
})
await app.listen({ port: 3000 })
Reference
Every method returns a promise of the typed response. Methods that use the API key need a key bound to your store, with the scope shown next to them.
Checkout and orders
One-time purchases. Redirect the buyer to the hosted page, then confirm the payment from the order.paid webhook or by polling the session.
checkout.create(params)(checkout:write): Creates a hosted checkout for one product and returns { id, url, expiresAt, status }. Send the buyer to url. Takes productId, and optionally quantity, customerEmail, couponCode, returnUrl, customFields answers you already have, player (a name and game ids) and metadata: up to 10 string values, echoed back on the order and in webhooks.checkout.get(id)(checkout:read): The session status: pending, completed, failed or canceled. A refunded or disputed order still reads completed here; orders.get has the raw status.orders.get(id)(orders:read): The full order: raw status, amount with net, VAT, sellerPaymentFee and serviceFee (the paysafecard surcharge), buyer email, product, serialsCount for SERIAL products, and serials with the id, status and replacedById of every delivered key (never its value).orders.list(params)(orders:read): Filter by status, productId, email, identifier (one value or an array), createdAfter, createdBefore or updatedSince; page with limit (at most 100) and offset. Returns { data, total, limit, offset }.orders.cancel(id)(orders:write): Cancels a pending order and returns it. Takes the order id, not its number.orders.redeliver(id)(orders:write): Sends a completed order that was not delivered again and returns it. Takes the order id or its number.orders.replace(id, params)(orders:write): Swaps the delivered keys of a completed order. serialIds (the ids from orders.get serials) picks which keys, all by default; values supplies the new ones, the pool by default; reason is kept on the order. Returns the replacements.
orders.ts
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const session = await skalp.checkout.get('b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d')
if (session.status === 'completed') {
const order = await skalp.orders.get(session.id)
console.log(order.orderNumber, order.netAmount, order.vatAmount)
}
Response
{
"id": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"status": "completed",
"orderNumber": "SK-100234",
"amount": 24.99,
"currency": "EUR",
"completedAt": "2026-09-16T10:07:12.000Z",
"metadata": {
"userId": "user_123"
}
}
Subscriptions
Recurring products. Tie each subscription to your own user with externalCustomerId, and read what a user is entitled to at any moment with a single list call.
subscriptions.createCheckout(params)(checkout:write): A hosted checkout for a recurring product, by productId or productSlug. Pass externalCustomerId, your own user or tenant id, and every later webhook and list call carries it back as externalRef, so you never store a Skalp id.subscriptions.getCheckout(id)(checkout:read): pending, completed or expired, with subscriptionId filled in once the buyer has paid.subscriptions.list(params)(subscriptions:read): Filter by externalCustomerId, status or updatedSince; page with limit (default 50, at most 200) and offset. Returns { data, total, limit, offset }. A customer who cancelled and came back has two rows, so read the one with active: true.subscriptions.get(id)(subscriptions:read): One subscription from your store. active is true for ACTIVE, TRIALING and PAST_DUE before graceUntil.subscriptions.changePlan(id, params)(subscriptions:write): Moves the subscription to another recurring product of your store, by productId or productSlug. Skalp prorates the difference onto the next invoice, and subscription.updated fires.subscriptions.update(id, params)(subscriptions:write): Sets a new externalCustomerId on the subscription, or clears it with null. Later webhooks and list calls carry the new ref, and subscription.updated fires.subscriptions.cancel(id)(subscriptions:write): Stops billing at the end of the paid period. The customer keeps access until currentPeriodEnd, and cancelAtPeriodEnd becomes true right away.subscriptions.createUsageCharge(id, params)(subscriptions:write): Bills the subscriber once for usage outside the plan: amount, currency, description, idempotencyKey and the usage period. Resolves to { id, invoiceId, hostedUrl, amount, currency, status }. The same idempotencyKey always returns the same charge, so retrying is safe.subscriptions.listInvoices(id)(subscriptions:read): The invoices of a subscription, each with total, status, hostedUrl and pdfUrl.
subscriptions.ts
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const checkout = await skalp.subscriptions.createCheckout({
productSlug: 'pro-monthly',
externalCustomerId: currentUser.id,
customerEmail: currentUser.email,
})
const { data } = await skalp.subscriptions.list({ externalCustomerId: currentUser.id })
const subscription = data.find((s) => s.active)
if (subscription) {
await skalp.subscriptions.cancel(subscription.id)
const invoices = await skalp.subscriptions.listInvoices(subscription.id)
console.log(checkout.url, invoices[0]?.pdfUrl)
}
Response
{
"data": [
{
"id": "0c7e2b94-8d1a-4f35-b6e0-7a9c1d3e5f28",
"status": "ACTIVE",
"active": true,
"externalCustomerId": "user_123",
"externalRef": "user_123",
"productId": "6f02a1c8-2b7d-4e9a-8c31-5d4e7f9a0b12",
"productSlug": "pro-monthly",
"productName": "Pro Monthly",
"billingInterval": "MONTH",
"amount": 11.99,
"currency": "EUR",
"currentPeriodStart": "2026-09-16T10:05:00.000Z",
"currentPeriodEnd": "2026-10-16T10:05:00.000Z",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"trialEnd": null,
"graceUntil": null,
"buyerEmail": "[email protected]",
"metadata": {
"plan": "pro"
},
"createdAt": "2026-09-16T10:05:00.000Z",
"updatedAt": "2026-09-16T10:05:00.000Z"
}
],
"total": 1,
"limit": 50,
"offset": 0
}
Catalog
Products, key pools, store categories and product groups of the store your key is bound to. Reading needs products:read and every change needs products:write, which does not include reading. A new product stays a draft until submit sends it to review.
products.list(params)(products:read): Every product of your store as a full product object, newest first. Only ACTIVE ones unless you pass status: one status, or all. Without limit and offset the SDK fetches every page for you; pass either one to get a single page of up to 100. stock is the available key count for SERIAL products and null for the others.products.get(idOrSlug)(products:read): One product in any status, by id or slug. rejectionReason says why the review rejected it.products.create(params)(products:write): Creates a DRAFT from name and price plus any optional field, and fires product.created. Pass submit: true to submit it for review in the same call.products.update(idOrSlug, params)(products:write): Changes only the fields you pass; null clears comparePrice, storeCategoryId, dynamicUrl or licenseDurationDays. status takes DRAFT or ARCHIVED only, because publishing goes through submit.products.archive(idOrSlug)(products:write): Sets the product to ARCHIVED and takes it off sale. Nothing is deleted.products.submit(idOrSlug)(products:write): Sends a DRAFT or REJECTED product to review. The review sets ACTIVE or REJECTED; read the product to see which.products.stock(idOrSlug)(products:read): { available, delivered, revoked, total } for the product's key pool, without the key values.products.listSerials(idOrSlug, params)(products:write): The keys with their plain values, oldest first. Filter by status and page with limit, at most 100, and offset.products.addSerials(idOrSlug, params)(products:write): Adds keys from a serials array or a block of text, split on new lines, commas, semicolons or your own delimiter. Resolves to { added, skipped, stock }; a key the product already has is skipped.products.deleteSerial(idOrSlug, serialId)(products:write): Deletes one key that has not been sold.categories.list()(products:read): Your store categories in display order, each with its count of activeProducts.gameCatalog.get(game)(products:read): Resolves to what your connected servers of that game reported: items, vehicles, accounts and groups, each with the servers that have it. game is 'fivem', 'minecraft' or 'rust'.categories.create / update / delete(products:write): Add a category, at most 20, rename it or move it with sortOrder, or delete it. The products of a deleted category stay, without a category.groups.list() / groups.get(id)(products:read): Product groups with productIds in display order and the name, slug, status and price of each product.groups.create / update / delete(products:write): Group up to 50 products of your store. productIds on update replaces the whole list and its order.
catalog.ts
import { readFile } from 'node:fs/promises'
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const product = await skalp.products.create({
name: 'Aurora Pro key',
price: 19.5,
fulfillmentType: 'SERIAL',
})
await skalp.products.addSerials(product.id, {
text: await readFile('keys.txt', 'utf8'),
})
await skalp.products.submit(product.id)
const stock = await skalp.products.stock(product.id)
console.log(stock.available)
Response
{
"productId": "8c2f4a6e-1d3b-4f5a-9e7c-0b2d4f6a8c1e",
"available": 120,
"delivered": 0,
"revoked": 0,
"total": 120
}
Coupons, customers and support
The rest of your store: coupons, customer records, reviews and buyer conversations, and the blacklist and whitelist rules for your checkout. Each resource has its own read and write scope.
me(): The store and the API key you are using, with its scopes.coupons.list() / coupons.get(id)(coupons:read): Every coupon of your store, as one array.coupons.create / update / delete(coupons:write): A percent or fixed amount, with optional validFrom, validTo, maxUses and minPurchaseAmount. On a subscription, subscriptionDuration is ONCE, REPEATING for subscriptionMonths, or FOREVER. update takes null to clear validTo, maxUses, minPurchaseAmount, maxDiscountAmount, subscriptionMonths or description.flashSales.list(params) / flashSales.get(id)(products:read): Your flash sales, newest first. Pass productId (id or slug) for one product. remaining is the units left at the sale price, null without a limit.flashSales.create / update / end(products:write): create takes productId, discountPercent (1 to 90), endAt and optionally startAt, title and maxQuantity. update takes null to clear title or remove the limit. end stops the sale now.customers.list(params) / customers.get(id)(customers:read): Search by e-mail or name; page with limit and offset. spent has one total per currency.customers.create / update / delete(customers:write): A customer record with e-mail, name and a private note.levels.get() / levels.customer(email)(customers:read): The level ladder with any XP boost, and one buyer’s XP, level and discount. An email without an account is level 1.levels.giveXp(email, amount, reason?)(customers:write): Adds XP, or takes it away with a negative amount, and returns the buyer’s new level. customer.level_up or customer.level_down fires when the level changes.levels.setProductRule(productIds, rule)(products:write): Puts one level rule on up to 100 products, or clears it with null. Returns every product with a level rule.feedback.list / get / reply / appeal(feedback:read · feedback:write): Product reviews: filter by productId or rating, answer in public with reply, or ask Skalp to take a review down with appeal and a reason of at least 10 characters.queries.list / get / reply / close / reopen(queries:read · queries:write): Buyer conversations. reply, close and reopen return the whole conversation with its messages.blacklist / whitelist: list, add, remove(blacklist:* · whitelist:*): Rules by EMAIL, IP, COUNTRY, ISP, ASN or HOST, each list with its own read and write scope. list returns every rule as one array, and a whitelisted buyer is never blocked by a blacklist rule.
store.ts
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const { data: orders } = await skalp.orders.list({
status: 'COMPLETED',
updatedSince: lastSync,
})
await skalp.blacklist.add({
type: 'EMAIL',
value: '[email protected]',
})
const { data: open } = await skalp.queries.list({
status: 'CUSTOMER_REPLY',
})
await skalp.queries.reply(open[0].id, {
message: 'Fixed in 2.4.1, download it again.',
})
const coupon = await skalp.coupons.create({
code: 'LAUNCH20',
discountType: 'PERCENT',
discountPercent: 20,
maxUses: 100,
})
Response
{
"id": "c3a9e1f4-7b2d-4c8e-9f16-5d0a2b7e4c91",
"code": "LAUNCH20",
"description": null,
"discountType": "PERCENT",
"discountPercent": 20,
"discountAmount": null,
"productIds": [],
"validFrom": "2026-10-09T10:00:00.000Z",
"validTo": null,
"maxUses": 100,
"usedCount": 0,
"minPurchaseAmount": null,
"maxDiscountAmount": null,
"excludeSaleItems": false,
"firstOrderOnly": false,
"oneTimePerUser": false,
"isActive": true
}
Webhooks
Add a webhook URL on the Webhooks page of your dashboard and copy its secret into SKALP_WEBHOOK_SECRET. constructEvent checks the Skalp-Signature header, an HMAC-SHA256 of a timestamp and the raw body, and rejects deliveries older than five minutes. Narrow on event.type and TypeScript knows the exact shape of event.data.
webhooks.list()(webhooks:read): Your webhook endpoints with their url, events and isActive.webhooks.create(params) / webhooks.delete(id)(webhooks:write): Adds an endpoint from url and events, event names or '*' for all of them, optionally only for productIds. The signing secret comes back once, in the create response.webhooks.constructEvent(body, headers): Checks the Skalp-Signature header against the raw body and returns the parsed, typed event. Throws SkalpSignatureError when the signature does not match or the delivery is more than five minutes old. body is the raw request body as a string, Buffer or ArrayBuffer; headers is a Headers object, a Node headers object or the Skalp-Signature value itself.webhooks.verify(body, headers): The same check without parsing: resolves to true or false.
A webhook with the default events receives every purchase twice, as order.paid and as its legacy name purchase.completed. Handle order.paid only, and deduplicate on data.idempotencyKey, because failed deliveries are retried. A failed renewal ends the subscription at once unless the store gives time to pay. Either way, revoke access on subscription.canceled.
Pick an event to see the branch that handles it and the payload that arrives.
order.paid
Grant access here. The event carries the buyer, the product, license keys or serials, and idempotencyKey, so a retried delivery is easy to skip.
{
"type": "order.paid",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"orderId": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"orderNumber": "SK-100234",
"productId": "5d8e1f3a-9c2b-4e7d-b6a0-8f1c3e5d7a92",
"productName": "My Script",
"productSlug": "my-script",
"buyerId": "1a44c9e2-7b3d-4f81-9e62-0c5a8d7b3f19",
"buyerEmail": "[email protected]",
"licenseId": "e7b2c4d6-1f3a-4c5e-9b8d-2a6f0e4c8b13",
"licenseKey": "SKALP-7C2F-A91B-04DE-B83A",
"amount": 24.99,
"currency": "EUR",
"quantity": 1,
"idempotencyKey": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"steamhex": null,
"identifier": null,
"metadata": {
"userId": "user_123"
},
"licenses": [
{
"licenseId": "e7b2c4d6-1f3a-4c5e-9b8d-2a6f0e4c8b13",
"licenseKey": "SKALP-7C2F-A91B-04DE-B83A",
"productId": "5d8e1f3a-9c2b-4e7d-b6a0-8f1c3e5d7a92",
"productSlug": "my-script",
"productName": "My Script"
}
]
}
}
order.refunded
Take back what the order granted. A refund can be partial, so compare amount with the order total.
{
"type": "order.refunded",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"orderId": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"orderNumber": "SK-100234",
"refundId": "re_3Q1xKc2LmT4xYc9A",
"amount": 24.99,
"reason": "requested_by_customer"
}
}
order.disputed
A chargeback was opened. banned tells you whether Skalp has already blocked the buyer.
{
"type": "order.disputed",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"orderId": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"orderNumber": "SK-100234",
"disputeId": "c7e2a9154b3d4f8a9e612d0b7a5c8f34",
"reason": "fraudulent",
"steamHex": null,
"identifier": null,
"banned": true
}
}
subscription.created
Turn the plan on, also when status is TRIALING. externalRef is the user id you passed to createCheckout.
{
"type": "subscription.created",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"subscriptionId": "0c7e2b94-8d1a-4f35-b6e0-7a9c1d3e5f28",
"externalRef": "user_123",
"status": "ACTIVE",
"active": true,
"storeId": "9f31d2a7-4c6e-4b8a-a1f0-3e5d7c9b2a64",
"productId": "6f02a1c8-2b7d-4e9a-8c31-5d4e7f9a0b12",
"productSlug": "pro-monthly",
"productName": "Pro Monthly",
"buyerId": "1a44c9e2-7b3d-4f81-9e62-0c5a8d7b3f19",
"billingInterval": "MONTH",
"amount": 11.99,
"currency": "EUR",
"currentPeriodStart": "2026-09-16T10:05:00.000Z",
"currentPeriodEnd": "2026-10-16T10:05:00.000Z",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"trialEnd": null,
"graceUntil": null,
"metadata": {
"plan": "pro"
},
"idempotencyKey": "evt_1S8kQ2LmT4xYc9Ab"
}
}
subscription.renewed
A billing period was paid. Extend access until periodExtendedTo.
{
"type": "subscription.renewed",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"subscriptionId": "0c7e2b94-8d1a-4f35-b6e0-7a9c1d3e5f28",
"externalRef": "user_123",
"status": "ACTIVE",
"active": true,
"storeId": "9f31d2a7-4c6e-4b8a-a1f0-3e5d7c9b2a64",
"productId": "6f02a1c8-2b7d-4e9a-8c31-5d4e7f9a0b12",
"productSlug": "pro-monthly",
"productName": "Pro Monthly",
"buyerId": "1a44c9e2-7b3d-4f81-9e62-0c5a8d7b3f19",
"billingInterval": "MONTH",
"amount": 11.99,
"currency": "EUR",
"currentPeriodStart": "2026-10-16T10:05:00.000Z",
"currentPeriodEnd": "2026-11-16T10:05:00.000Z",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"trialEnd": null,
"graceUntil": null,
"metadata": {
"plan": "pro"
},
"idempotencyKey": "evt_1T2aBcLmT4xYc9Cd",
"invoiceId": "8a41c7f03e2b4d19b6a591c4e7d2f083",
"amountPaid": 11.99,
"periodExtendedTo": "2026-11-16T10:05:00.000Z"
}
}
subscription.past_due
A payment failed. With graceUntil set, a renewal failed and the store gives time to pay: keep access until graceUntil. With graceUntil null, a plan change failed: keep access until it is paid or subscription.canceled arrives.
{
"type": "subscription.past_due",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"subscriptionId": "0c7e2b94-8d1a-4f35-b6e0-7a9c1d3e5f28",
"externalRef": "user_123",
"status": "PAST_DUE",
"active": false,
"storeId": "9f31d2a7-4c6e-4b8a-a1f0-3e5d7c9b2a64",
"productId": "6f02a1c8-2b7d-4e9a-8c31-5d4e7f9a0b12",
"productSlug": "pro-monthly",
"productName": "Pro Monthly",
"buyerId": "1a44c9e2-7b3d-4f81-9e62-0c5a8d7b3f19",
"billingInterval": "MONTH",
"amount": 11.99,
"currency": "EUR",
"currentPeriodStart": "2026-09-16T10:05:00.000Z",
"currentPeriodEnd": "2026-10-16T10:05:00.000Z",
"cancelAtPeriodEnd": false,
"canceledAt": null,
"trialEnd": null,
"graceUntil": "2026-10-23T10:05:00.000Z",
"metadata": {
"plan": "pro"
},
"idempotencyKey": "evt_1T2aBdLmT4xYc9Ef",
"invoiceId": "8a41c7f03e2b4d19b6a591c4e7d2f083",
"attemptCount": 1,
"nextPaymentAttempt": "2026-10-19T10:05:00.000Z"
}
}
subscription.canceled
The subscription has ended. cancelReason tells a customer's cancellation apart from a failed payment.
{
"type": "subscription.canceled",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"subscriptionId": "0c7e2b94-8d1a-4f35-b6e0-7a9c1d3e5f28",
"externalRef": "user_123",
"status": "CANCELED",
"active": false,
"storeId": "9f31d2a7-4c6e-4b8a-a1f0-3e5d7c9b2a64",
"productId": "6f02a1c8-2b7d-4e9a-8c31-5d4e7f9a0b12",
"productSlug": "pro-monthly",
"productName": "Pro Monthly",
"buyerId": "1a44c9e2-7b3d-4f81-9e62-0c5a8d7b3f19",
"billingInterval": "MONTH",
"amount": 11.99,
"currency": "EUR",
"currentPeriodStart": "2026-09-16T10:05:00.000Z",
"currentPeriodEnd": "2026-10-16T10:05:00.000Z",
"cancelAtPeriodEnd": false,
"canceledAt": "2026-10-16T10:05:00.000Z",
"trialEnd": null,
"graceUntil": null,
"metadata": {
"plan": "pro"
},
"idempotencyKey": "evt_1T2aBeLmT4xYc9Gh",
"endedAt": "2026-10-16T10:05:00.000Z",
"cancelReason": "requested"
}
}
product.stock
The number of available keys of a product changed after a sale, an upload or a deletion. Top up the pool before stock reaches 0.
{
"type": "product.stock",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"productId": "8c2f4a6e-1d3b-4f5a-9e7c-0b2d4f6a8c1e",
"productName": "Aurora Pro key",
"productSlug": "aurora-pro-key",
"stock": 4,
"previousStock": 5,
"change": -1
}
}
webhook.test
Sent by the Test button next to your webhook in the dashboard. Not a real order.
{
"type": "webhook.test",
"timestamp": "2026-09-16T10:05:00.000Z",
"data": {
"message": "This is a test webhook from Skalp.gg",
"webhookId": "c41d8e2f-6a3b-4d9c-8e1f-7b5a2c4d6e80",
"sample": {
"orderId": "test_order_123",
"orderNumber": "SK-TEST-001",
"amount": 9.99,
"currency": "USD"
}
}
}
handle-skalp-event.ts
import type { SkalpEvent } from '@skalpgg/sdk'
export async function handleSkalpEvent(event: SkalpEvent) {
switch (event.type) {
case 'order.paid':
if (await alreadyProcessed(event.data.idempotencyKey)) return
await grantAccess(event.data.buyerEmail, event.data.licenses ?? [])
break
case 'subscription.created':
case 'subscription.renewed':
case 'subscription.updated':
await setEntitlement(event.data.externalRef, event.data.active, event.data.currentPeriodEnd)
break
case 'subscription.past_due':
await startGracePeriod(event.data.externalRef, event.data.graceUntil ?? event.data.nextPaymentAttempt)
break
case 'subscription.canceled':
await setEntitlement(event.data.externalRef, false, event.data.endedAt)
break
case 'subscription.refunded':
if (event.data.fullyRefunded) await setEntitlement(event.data.externalRef, false, null)
break
case 'subscription.disputed':
if (event.data.disputeStatus === 'open') await setEntitlement(event.data.externalRef, false, null)
break
}
}
Licenses
For software that runs on your buyer's machine, such as a Discord bot or a desktop app. No API key is involved: the license key authenticates the call. The first start binds the license to that machine's public IP, and the buyer can move it on the licenses page of their dashboard.
licenses.verify(params): Checks licenseKey from the IP the request comes from and records serverKey, a value unique to that installation, as one of its servers. serverIp only counts when you test on a local network. Resolves to { valid, error, message, license }, and an invalid license resolves normally instead of throwing.licenses.heartbeat(params): A lighter re-check for a running install: resolves to { valid: false } once the license is revoked or expired, or moves to another IP. Send it every few minutes with the same licenseKey and serverIp.licenses.validate(params): For keys sold with the "License key" delivery: checks key and binds it to hardwareId, up to the device limit of the product. Resolves to { valid, code, message, license }; code is VALID, NOT_FOUND, PRODUCT_MISMATCH, LICENSING_DISABLED, REVOKED, SUSPENDED, EXPIRED, SUBSCRIPTION_INACTIVE or DEVICE_LIMIT_REACHED. Needs the licenses:validate scope, and a key with only that scope may ship inside your app.licenses.resetDevices(params): Frees every machine a key is bound to, and binds hardwareId right away when you pass it. Needs licenses:write, so call it from your server, never from your app.
bot.ts
import { Skalp } from '@skalpgg/sdk'
const skalp = new Skalp()
const licenseKey = process.env.LICENSE_KEY!
const serverIp = await fetch('https://api.ipify.org').then((r) => r.text())
const result = await skalp.licenses.verify({
licenseKey,
serverIp,
serverKey: process.env.SERVER_KEY!,
})
if (!result.valid) {
console.error(`License check failed: ${result.error} ${result.message}`)
process.exit(1)
}
setInterval(async () => {
const { valid } = await skalp.licenses.heartbeat({ licenseKey, serverIp })
if (!valid) process.exit(1)
}, 5 * 60_000)
Response
{
"valid": true,
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…",
"expiresAt": "2026-09-16T10:15:00.000Z",
"publicKey": "-----BEGIN PUBLIC KEY-----…",
"license": {
"key": "SKALP-7C2F-A91B-04DE-B83A",
"product": "My Script",
"version": "2.4.0",
"expiresAt": null
}
}
valid: false
{
"valid": false,
"error": "SERVER_NOT_ACTIVATED",
"message": "This server connects from 198.51.100.24, which is not the IP this license runs on. Move the license to this IP in My Licenses on skalp.gg."
}
Errors and retries
When the API answers with an error, the SDK throws SkalpError. A 429 is retried on its own, up to maxRetries times, when the limit resets within 10 seconds. Network failures and timeouts reject with the runtime's own error.
statusnumber: The HTTP status, such as 400, 401, 403, 404 or 429.codestring | undefined: The Skalp error code when the API sends one, such as STORE_REQUIRED, NOT_A_SUBSCRIPTION or DUPLICATE_SUBSCRIPTION.messagestring: A readable explanation. Validation errors are joined into one line.bodyunknown: The parsed response body, as sent.
errors.ts
import { Skalp, SkalpError } from '@skalpgg/sdk'
const skalp = new Skalp({
maxRetries: 3,
timeout: 10_000,
})
try {
await skalp.checkout.create({
productId: 'prod_xxx',
})
} catch (error) {
if (!(error instanceof SkalpError)) throw error
const { status, code, message } = error
console.log(status, code, message)
}
SkalpError
{
"status": 403,
"code": "STORE_REQUIRED",
"message": "This API key is not bound to a store. Create a new key with a storeId to use the Checkout API."
}