> ## Documentation Index
> Fetch the complete documentation index at: https://developers.paysum.io/llms.txt
> Use this file to discover all available pages before exploring further.

# API quickstart

> Create an API key and send a customer to checkout in a few minutes.

This walkthrough takes you from a fresh store to a working checkout link using a single API call.

**1. Create an API key**

In the dashboard, open **Integrations** → **API keys** and select **Create API key**. Give it the `checkout_api` permission. Copy the key, which starts with `sk_`.

**2. Store the key on your server**

Keep the key in an environment variable on your backend. It must never ship to a browser or mobile app.

```bash theme={null}
PAYSUM_API_KEY=sk_your_secret_key
```

**3. Create a checkout session**

Send the items you want to charge for. The response contains a hosted checkout URL.

```bash theme={null}
curl -X POST "https://paysum.io/api/checkout-api/sessions" \
  -H "Authorization: Bearer $PAYSUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [{ "name": "Premium License", "price": 29.99, "quantity": 1 }],
    "success_url": "https://example.com/success",
    "webhook_url": "https://example.com/webhooks/checkout"
  }'
```

```js theme={null}
const response = await fetch('https://paysum.io/api/checkout-api/sessions', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PAYSUM_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    line_items: [{ name: 'Premium License', price: 29.99, quantity: 1 }],
    success_url: 'https://example.com/success',
    webhook_url: 'https://example.com/webhooks/checkout',
  }),
})
const { url } = await response.json()
```

**4. Redirect the customer**

Send the customer to the returned `url`. After paying they land on your `success_url`. To fulfil orders reliably, listen for the `checkout.session.completed` [webhook](https://docs.paysum.io/webhooks) rather than relying on the redirect.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.