# Customer Portal

The Customer Portal enables platforms and marketplaces to direct sub accounts to a self-service interface for `account_onboarding` and `account_management`.
This functionality is accessed using the `account_link` endpoint, which generates a secure, one-time-use session URL.

---

## CustomerPortalAccountLink object

| Property | Type | Description |
|----------|------|-------------|
| object | string | Always returns "CustomerPortalAccountLink". |
| link | string | One-time-use session URL for initiating the Customer Portal. |
| created_at | timestamp | One-time-use session URL for initiating the Customer Portal. |
| expires_at | timestamp | ISO 8601 timestamp when the link will expire (5 minutes from creation). |

Example Object:

```json
{
  "object": "CustomerPortalAccountLink",
  "created_at": "2025-16-17T17:30:30Z",
  "expires_at": "2025-16-17T17:35:30Z",
  "link": "https://app.easypost.com/customer-portal/onboarding?session_id={SESSION_ID}"
}
```

---

**Production Only**

## Creating a Portal Session

### Example: POST /customer_portal/account_link

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/customer_portal/account_link \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "session_type": "account_management",
    "user_id": "user_...",
    "refresh_url": "https://example.com/refresh",
    "return_url": "https://example.com/return",
    "metadata": {"target": "wallet"}
  }'
```

This endpoint generates a one-time Customer Portal URL. The integrator must redirect the sub account user to this URL within the expiration window.

---

## Handling redirects

- **Refresh URL:** Redirected here if the session link has expired or has already been used. Should trigger a new `POST /customer_portal/account_link` call.
- **Return URL:** Redirected here when the session ends. Session outcome is not included; use webhooks or fetch account status via API.

---

## Additional resources

- Get started with Forge
- Forge Help Center