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

# Customer portal

> Send a customer to a page where they manage subscriptions, payment methods and receipts.

The customer portal is an Easner-hosted page, branded with your logo and accent colour, where a paying customer can see their subscriptions and payments, download receipts, update billing details and saved payment methods, and cancel or resume a subscription. You do not build any of it. Your server asks for a link and redirects the customer to it.

> [!NOTE]
>
> **Scope:** `checkout`
>
> The portal must be turned on in Settings → Payments. If it is off, the call returns `409 portal_disabled`. Which actions customers may take (cancel, switch plans, update payment methods, see payments) are also set there.

## Create a portal session

`POST /v1/customer_portal/sessions` returns a signed link that is valid for one hour. Each call makes a new link. The route does not use `Idempotency-Key`, so do not send one.

```bash curl theme={null}
curl https://api.easner.com/v1/customer_portal/sessions \
  -H "Authorization: Bearer $EASNER_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_email": "ada@example.com",
    "return_url": "https://yoursite.com/account"
  }'
```

```js Node theme={null}
const response = await fetch("https://api.easner.com/v1/customer_portal/sessions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.EASNER_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    customer_email: user.email,
    return_url: "https://yoursite.com/account",
  }),
});
const portal = await response.json();
// res.redirect(303, portal.url)
```

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

response = requests.post(
    "https://api.easner.com/v1/customer_portal/sessions",
    headers={
        "Authorization": f"Bearer {os.environ['EASNER_SECRET_KEY']}",
    },
    json={"customer_email": user_email, "return_url": "https://yoursite.com/account"},
    timeout=30,
)
portal = response.json()
```

```php PHP theme={null}
<?php
$ch = curl_init("https://api.easner.com/v1/customer_portal/sessions");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("EASNER_SECRET_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "customer_email" => $userEmail,
        "return_url" => "https://yoursite.com/account",
    ]),
]);
$portal = json_decode(curl_exec($ch), true);
```

```ruby Ruby theme={null}
require "net/http"
require "json"

uri = URI("https://api.easner.com/v1/customer_portal/sessions")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch('EASNER_SECRET_KEY')}"
request["Content-Type"] = "application/json"
request.body = { customer_email: user_email, return_url: "https://yoursite.com/account" }.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
portal = JSON.parse(response.body)
```

```json theme={null}
{
  "object": "customer_portal.session",
  "url": "https://pay.easner.com/lumen/account?token=…&return_url=https%3A%2F%2Fyoursite.com%2Faccount",
  "customer": "0b9f1c2e-5a7d-4e1b-9c3a-2f6d8e4b7a10",
  "return_url": "https://yoursite.com/account",
  "expires_at": "2026-10-09T11:00:00.000Z",
  "livemode": false
}
```

Redirect the customer to `url` straight away. Do not store it or email it: it is a credential that expires in one hour.

| Field | Type | Notes |
| - | - | - |
| `customer_email` | string | Find the customer by email. Use this when you do not store the Checkout customer id |
| `customer` | string | A Checkout customer id (a UUID), or an email address. Send this or `customer_email` |
| `return_url` | string | Optional. Shows a "Back to your site" link. A full `https://` address on a website you added for Checkout (`http://localhost` in test when listed) |

The customer must already exist: a customer is created when someone pays you through Checkout or a payment link in the same mode. An unknown customer is `404 customer_not_found`. A `return_url` on a website you have not listed is `400 return_url_not_allowed` on live keys (test keys allow any https origin and loopback without listing), and a malformed one is `400 invalid_return_url`.

## What the customer can do

The link opens a **read-only** session. To change anything (cancel, resume, change plan, update a payment method or billing details) the portal asks the customer for a fresh six-digit code sent to their email. That keeps a leaked link from being used to change an account. Receipts download as PDFs.

On a per-seat subscription, the customer can also change the number of seats. The sheet shows the charge, or the credit for removed seats, before they confirm, and asks for the same six-digit code. You allow this in Settings, **Payments** tab, **Customer portal**, with **Change seats**.

A subscription that started without a card shows **Add a card**. Adding one during the trial means the first payment is taken when the trial ends. Adding one after a trial ended (the subscription is `paused`) resumes it and takes the first payment right then. See [Start a trial without a card](https://docs.easner.com/subscriptions.md#start-a-trial-without-a-card).

Portal links created from the API are not the same as the "Manage your payments" links Easner emails to customers.

## Test and live

A test key opens test customers. A live key opens live customers. The same email can be a customer in both modes. Test portal pages show test payments only.

## Errors

| Status | `code` | When |
| - | - | - |
| 400 | `invalid_request` | Body is not a JSON object, or neither `customer` nor `customer_email` was sent |
| 400 | `invalid_email` | The email is not valid |
| 400 | `invalid_return_url` | `return_url` is not a full https address |
| 400 | `return_url_not_allowed` | `return_url` is not on one of your allowed websites on live keys (test keys allow any https origin and loopback without listing) |
| 404 | `customer_not_found` | No such customer in this mode |
| 409 | `portal_disabled` | The portal is off in Settings → Payments |

Full list: [Errors](https://docs.easner.com/errors.md).

> [card] [Refunds](https://docs.easner.com/refunds.md)
>
> Refund a payment from your server.


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