# Create customer portal session
Source: https://docs.lomi.africa/api/customers/CustomersController_createPortalSession

Create customer portal session

***

title: "Create customer portal session"
description: "Create customer portal session"
full: true
method: post
path: /customers/{id}/portal
operationId: CustomersController\_createPortalSession
-----------------------------------------------------

## Overview

Create customer portal session

Returns a short-lived URL so the customer can manage subscriptions and payment methods in the hosted portal.

### When to use this

Use from your app when a logged-in buyer opens “Manage billing” without building portal UI yourself.

### See also

[Portal audit log](/api/customers/CustomersController_getPortalAudit) · [List subscriptions](/api/subscriptions/SubscriptionsController_findAll)

## Authentication

Merchant routes require an API key in the `X-API-KEY` header (see [Integration overview](/api)). Use a **test** key against `https://sandbox.api.lomi.africa` and a **live** key against `https://api.lomi.africa`.

## Endpoint

`POST /customers/{id}/portal`

Base URLs:

* `https://sandbox.api.lomi.africa`
* `https://api.lomi.africa`

## Request

### Path parameters

| Name | Required | Schema | Description    |
| ---- | -------- | ------ | -------------- |
| `id` | Yes      | -      | UUID du client |

### Query parameters

*No query parameters.*

### Request body

JSON request payload.

Schema: `object`

| Field                       | Required | Type                                                                 | Description |
| --------------------------- | -------- | -------------------------------------------------------------------- | ----------- |
| `return_url`                | No       | `string`                                                             | -           |
| `flow_type`                 | No       | `enum ("portal_home", "subscription_cancel", "subscription_manage")` | -           |
| `flow_subscription_id`      | No       | `string`                                                             | -           |
| `flow_after_completion_url` | No       | `string`                                                             | -           |

Example body:

```json
{
  "return_url": "string",
  "flow_type": "portal_home",
  "flow_subscription_id": "string"
}
```

## Responses

| Status | Description                |
| ------ | -------------------------- |
| `201`  | Created successfully       |
| `401`  | Invalid or missing API key |
| `404`  | Resource not found         |

## Errors

Errors follow the standard JSON error format (status code and machine-readable message). Validate inputs before calling; **401** indicates a missing/invalid key, **404** a missing resource for this organization, **429** rate limiting. For safe retries on create-style calls, send an idempotency key when your flow supports it.

## Example

```bash
curl -sS -X POST "https://sandbox.api.lomi.africa/customers/value/portal" \
  -H "X-API-KEY: $LOMI_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"return_url":"string","flow_type":"portal_home","flow_subscription_id":"string"}'
```

## OpenAPI

* **operationId**: `CustomersController_createPortalSession`
* **Operation**: `POST /customers/{id}/portal`

Full schemas and **Try it**: [API reference](/api). Machine-readable contract: repo `apps/docs/openapi.json`.
