Skip to main content
Follow this guide when you want your server to create Kyren Pay checkout sessions through the API. If you want to learn the dashboard first, start with Dashboard overview.

Prerequisites

  • A Kyren Pay merchant account (sign up here)
  • Your API key (found in the Developer section of your dashboard)
  • A product created in the dashboard or through the Products API
  • A server-side environment where your API key can be stored securely
  • A Webhook endpoint for payment notifications before you go live

Step 1: Get your API Key

After signing up, navigate to Dashboard > Developer and copy your API key.
  • Live key: kyren_live_xxxxxxxxxxxx — use this for production
Keep your API keys secure. Never expose them in client-side code or public repositories.

Step 2: Create a Product

Create a product that represents what you’re selling:
curl -X POST https://api.kyren.top/v1/products \
  -H "Content-Type: application/json" \
  -H "x-api-key: kyren_live_xxxxxxxxxxxx" \
  -d '{
    "name": "1000 AI Credits",
    "description": "Top up 1000 credits for AI API usage",
    "price": "9.99",
    "currency": "USD"
  }'
Save the id from the response — you’ll need it to create checkout sessions.

Step 3: Create a Checkout Session

When a customer wants to pay, create a checkout session:
curl -X POST https://api.kyren.top/v1/checkouts \
  -H "Content-Type: application/json" \
  -H "x-api-key: kyren_live_xxxxxxxxxxxx" \
  -d '{
    "productId": "prod_abc123",
    "successUrl": "https://yoursite.com/success",
    "cancelUrl": "https://yoursite.com/cancel",
    "displayMerchantName": "Campaign Store"
  }'
Use displayMerchantName when this checkout should show a campaign, store, or app name that differs from your account name. The response includes a url field — redirect your customer to this URL to complete payment.

Step 4: Redirect to Checkout

Redirect the customer to the checkout URL returned in Step 3. They will see a hosted payment page where they can choose their preferred payment method.
// Example: redirect in your web app
window.location.href = checkoutResponse.data.url;

Step 5: Handle the Webhook

After payment is completed, Kyren Pay sends a webhook to your server:
// Express.js example
app.post('/webhooks/kyren', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.headers['x-kyren-signature'];
  const timestamp = req.headers['x-kyren-timestamp'];
  const payload = req.body.toString();

  // Verify the signature (see Webhook Signatures for details)
  if (!verifySignature(payload, signature, timestamp)) {
    return res.status(400).send('Invalid signature');
  }

  const event = JSON.parse(payload);

  if (event.type === 'order.paid') {
    const orderId = event.data.order_id;
    const amount = event.data.amount;
    // Fulfill the order in your system
    console.log(`Payment received: ${amount} ${event.data.currency}`);
  }

  res.status(200).send('OK');
});
Configure your webhook URL in Dashboard > Developer > Webhook Settings.

What’s Next?

Authentication

Learn about API authentication in detail

Webhook Signatures

Implement secure webhook verification

Testing

Test safely with Kyren-issued staging credentials or low-risk live checks

Code Examples

See examples in Python, Node.js, Go, and more