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

One sale, four moves.

  1. 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.
  2. 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.
  3. 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.
  4. 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.

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.

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.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.

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.

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.

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.

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.

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."
}