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

# Create a Payment Session

<Info>
  Before you integrate, you need a Privex Pay merchant account with API credentials. See Account setup to create your account and retrieve your API key.
</Info>

## Integration options

<CardGroup cols={3}>
  <Card title="REST API" icon="webhook">
    Make direct HTTP requests to the Privex Pay API. Works with any language or framework.
  </Card>

  <Card title="Plugins" icon="plug">
    Install a pre-built plugin for your e-commerce platform — no custom code required.
  </Card>
</CardGroup>

## How to integrate

<Steps>
  <Step title="Get your API credentials">
    Log in to your Privex Pay dashboard, navigate to **Settings → API keys**, and copy your secret key. Keep this value private — never expose it in client-side code.
  </Step>

  <Step title="Add Privex Pay to your codebase" stepNumber={2}>
    Follow the code examples in this page or in your chosen documentation to create a payment session and redirect your customer to the hosted checkout.
  </Step>

  <Step title="Go live" stepNumber={3}>
    Verify that your checkout flow completes end to end, then start accepting real payments.
  </Step>
</Steps>

#

#

# **Authentication**

Pass your API key in the `x-api-key` header on every request. Keys start with `pp_live_` and are created in the dashboard under **Developers → API Keys**.

```text theme={null}
x-api-key: pp_live_your_api_key
```

## API integration

Send a `POST` with an `items` array. Each item needs a `name`, `amount` (per unit, in dollars), and optional `quantity` (defaults to 1). The total is computed automatically. Pass a single item for a one-product checkout, or many for a multi-line cart — same endpoint.

###

### Create a payment session

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.privexpay.com/api-checkouts \
    --header 'x-api-key: pp_live_your_api_key' \
    --header 'Content-Type: application/json' \
    --data '{
      "items": [
        { "name": "Pro plan", "amount": 49.99, "quantity": 1 },
        { "name": "Add-on seat", "amount": 9.99, "quantity": 2 }
      ],
      "currency": "USD",
      "success_url": "https://yoursite.com/thank-you",
      "active": true
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.privexpay.com/api-checkouts', {
    method: 'POST',
    headers: {
      'x-api-key': 'pp_live_your_api_key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      items: [
        { name: 'Pro plan',    amount: 49.99, quantity: 1 },
        { name: 'Add-on seat', amount: 9.99,  quantity: 2 },
      ],
      currency: 'USD',
      success_url: 'https://yoursite.com/thank-you',
      active: true,
    }),
  });

  const { data } = await response.json();
  window.location.href = data.checkout_url;
  ```
</CodeGroup>

The API responds with a session object that includes a `checkout_url`. Redirect your customer to this URL to complete payment on the Privex Pay hosted checkout page.

```javascript Response theme={null}
{
  "data": {
    "id": "b3f1c2d4-7e8a-4d2b-9f1c-1234567890ab",
    "merchant_id": "a1b2c3d4-...-uuid",
    "product_name": "Pro plan + 1 more",
    "amount": 69.97,
    "currency": "USD",
    "items": [
      { "name": "Pro plan", "amount": 49.99, "quantity": 1 },
      { "name": "Add-on seat", "amount": 9.99, "quantity": 2 }
    ],
    "active": true,
    "created_at": "2026-05-11T12:00:00Z",
    "checkout_url": "https://privexpay.com/pay/b3f1c2d4-7e8a-4d2b-9f1c-1234567890ab"
  }
}
```

##

###

##

##
