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

# Quickstart

> Get up and running with SwiftPay in 5 minutes

# Quickstart Guide

This guide will help you integrate SwiftPay into your application and start accepting payments.

## 1. Get Your API Key

<Steps>
  <Step title="Sign Up">
    Create an account at [app.swiftpay.cx](https://app.swiftpay.cx) and
    complete the onboarding process.
  </Step>

  <Step title="Get Approved">
    Wait for your business to be approved by our team. You'll receive an email
    notification.
  </Step>

  <Step title="Generate API Key">
    Navigate to **Settings → API Keys** in your dashboard and create a new API
    key.
  </Step>
</Steps>

<Warning>
  Keep your API key secure! Never expose it in client-side code or public
  repositories.
</Warning>

## 2. Create a Checkout Session

Create a checkout session to start accepting payments:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.swiftpay.cx/api/checkout/sessions \
    -H "Authorization: Bearer mp_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "items": [
        {
          "name": "Premium Plan",
          "price": 29.99,
          "quantity": 1
        }
      ],
      "customer": {
        "email": "customer@example.com"
      },
      "urls": {
        "success": "https://yoursite.com/success",
        "cancel": "https://yoursite.com/cancel"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.swiftpay.cx/api/checkout/sessions", {
     method: "POST",
     headers: {
        Authorization: "Bearer mp_live_your_api_key",
        "Content-Type": "application/json",
     },
     body: JSON.stringify({
        items: [
           {
              name: "Premium Plan",
              price: 29.99,
              quantity: 1,
           },
        ],
        customer: {
           email: "customer@example.com",
        },
        urls: {
           success: "https://yoursite.com/success",
           cancel: "https://yoursite.com/cancel",
        },
     }),
  });

  const session = await response.json();
  console.log(session.data.id); // Session ID
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.swiftpay.cx/api/checkout/sessions',
      headers={
          'Authorization': 'Bearer mp_live_your_api_key',
          'Content-Type': 'application/json'
      },
      json={
          'items': [
              {
                  'name': 'Premium Plan',
                  'price': 29.99,
                  'quantity': 1
              }
          ],
          'customer': {
              'email': 'customer@example.com'
          },
          'urls': {
              'success': 'https://yoursite.com/success',
              'cancel': 'https://yoursite.com/cancel'
          }
      }
  )

  session = response.json()
  print(session['data']['id'])
  ```
</CodeGroup>

## 3. Redirect to Checkout

Redirect your customer to the checkout page:

```javascript theme={null}
// Redirect to the checkout page
const checkoutUrl = `https://app.swiftpay.cx/checkout/${session.data.id}`;
window.location.href = checkoutUrl;
```

## 4. Handle the Result

After payment, the customer is redirected to your `success` or `cancel` URL.

<Tip>
  For production applications, always verify the payment status via webhook or
  API call instead of relying solely on the redirect.
</Tip>

## 5. Set Up Webhooks (Recommended)

Configure webhooks to receive real-time payment notifications:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.swiftpay.cx/api/webhooks \
    -H "Authorization: Bearer mp_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://yoursite.com/webhooks/swiftpay",
      "events": ["checkout.succeeded", "checkout.failed", "refund.created"]
    }'
  ```
</CodeGroup>

The response includes a `secret` that you'll use to verify webhook signatures.

## Next Steps

<CardGroup cols={2}>
  <Card title="Checkout Integration" icon="credit-card" href="/guides/checkout-integration">
    Learn about advanced checkout options
  </Card>

  <Card title="Webhooks Guide" icon="webhook" href="/guides/webhooks">
    Set up webhook handling properly
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/overview">
    Explore the complete API
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/errors">
    Handle errors gracefully
  </Card>
</CardGroup>
