# Open a customer portal session

`POST /api/v1/portal-sessions`

Exactly one of `customer_id` / `customer_external_id`. Needs the `portal:write` scope. The customer must already exist.

Needs the `portal:write` scope, or a full-access key.

## Request body

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "customer_id": {
      "type": "string",
      "format": "uuid",
      "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    },
    "customer_external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "return_url": {
      "type": "string",
      "maxLength": 2048,
      "description": "Where the portal’s back link sends the payer. https (http for localhost only).",
      "example": "https://app.example.com/settings"
    }
  },
  "required": [
    "return_url"
  ]
}
```

## Responses

### 201

The session; send the payer to `url` (valid one hour).

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "object": {
          "type": "string",
          "enum": [
            "portal_session"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "return_url": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "object",
        "url",
        "expires_at",
        "return_url"
      ]
    },
    "_agent": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ok"
          ]
        },
        "next_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "summary",
        "status",
        "next_actions",
        "warnings"
      ]
    },
    "api_version": {
      "type": "string",
      "example": "2026-07-01"
    }
  },
  "required": [
    "data",
    "_agent",
    "api_version"
  ]
}
```

### 404

`not_found`: no customer with that id or external id.

### 422

`validation_failed`.
