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

# Create a portal session

> Create a session of the client portal, and return the URL that opens it.



## OpenAPI

````yaml https://public.leanpay.fr/openapi/leanpay_api_documentation.swagger.yaml post /clients/portal-session
openapi: 3.1.1
info:
  version: 1.0.0
  title: LeanPay Api documentation
  description: >
    ## Authentication


    Send the API key in the `Authorization` header of every request, as it is,
    without a `Bearer` prefix:


    ```

    Authorization: <API key>

    ```


    A user of the LeanPay app with the required permission creates the key in
    the app. The app shows the key only once, when it creates it: store it.


    ## Errors


    | Status | Cause |

    | --- | --- |

    | `400` | The request is invalid: body, path parameter or query parameter. |

    | `401` | The API key is missing, unknown or inactive. |

    | `404` | The id in the path matches no item, unless the route documents
    another behaviour. |

    | `429` | The rate limit is reached. |

    | `500` | Server error. |


    The body of an error is JSON and holds a human-readable explanation. Use it
    to debug, but do not parse it: rely on the status code.


    **Rate limit.** Each LeanPay account can send 150 requests per minute, all
    its API keys and all routes together. The response to a request with a valid
    API key carries these headers, except a `429`:


    | Header | Value |

    | --- | --- |

    | `X-RateLimit-Limit` | The number of requests allowed per minute. |

    | `X-RateLimit-Remaining` | The number of requests left in the current
    minute. |

    | `X-RateLimit-Reset` | The number of seconds before the count starts again.
    |


    Above the limit, the API returns `429` with only a `Retry-After` header:
    wait this number of seconds before the next request.


    ## Filtering


    Filter a list with the `s` query parameter: a JSON condition, URL-encoded.


    ```

    ?s={"field":{"$operator":value}}

    ```


    - `{"field": value}` is the same as `{"field": {"$eq": value}}`.

    - An item matches an object of several fields only if it matches all of
    them.

    - Combine conditions with `$and` and `$or`, each followed by an array of
    conditions: `{"$or":[{"name":{"$starts":"A"}},{"externalId":"EXT-1"}]}`.

    - An object that holds a non-empty `$and` takes no other key: put every
    condition inside the `$and` array. A field or an `$or` next to it returns
    `400`.

    - An item must also match a field next to `$or`.

    - `$and` and `$or` cannot be nested: a `$and` or an `$or` inside the array
    of another one returns `400`.

    - An `$or` inside a field (`{"field":{"$or":…}}`) takes one plain operator.
    Several operators, a list or a nested `$or` return `400`: use a top-level
    `$or` instead.


    | Operator | Meaning | Operand |

    | --- | --- | --- |

    | `$eq` | Equal to | A value |

    | `$ne` | Not equal to | A value |

    | `$gt` `$gte` | Greater than, greater than or equal to | A value |

    | `$lt` `$lte` | Less than, less than or equal to | A value |

    | `$between` | Between two values, both included | `[min, max]` |

    | `$cont` | Contains the text | A text |

    | `$starts` | Starts with the text | A text |

    | `$ends` | Ends with the text | A text |

    | `$in` | Equal to one of the values | A list |

    | `$notin` | Equal to none of the values | A list |

    | `$isnull` | Is null | `true` |

    | `$notnull` | Is not null | `true` |


    Add `L` to a text operator to ignore the case: `$contL`, `$startsL`,
    `$endsL`.


    | Field type | Format of the value |

    | --- | --- |

    | Date | `YYYY-MM-DD` or a full ISO 8601 date-time:
    `2026-06-01T00:00:00.000Z`. |

    | UUID | The hyphenated form the API returns: `8-4-4-4-12`. |

    | Boolean | `true` or `false`. |

    | Enumeration | One of the values the route lists. |


    A UUID, boolean or enumeration field accepts only `$eq`, `$ne`, `$in`,
    `$notin`, `$isnull` and `$notnull`, alone or inside a field-level `$or`. On
    these fields, only `$in` and `$notin` accept a list, and never a nested
    list.


    Each list route gives the fields it filters on and their operators. A field
    outside this list returns `400`. On a UUID, boolean or enumeration field, an
    operator or a value outside these lists also returns `400`. On the other
    fields, use only the operators the route gives.


    ## Pagination


    A list route returns one page of items.


    | Parameter | Default | Values |

    | --- | --- | --- |

    | `page` | `1` | The number of the page, from `1`. |

    | `limit` | `200` | The number of items per page, from `1` to `200`. |


    The response wraps the page in an envelope:


    ```

    { "data": [ … ], "count": 200, "total": 412, "page": 1, "pageCount": 3 }

    ```


    | Property | Value |

    | --- | --- |

    | `data` | The items of the page. |

    | `count` | The number of items in `data`. |

    | `total` | The number of items that match the filter, on all pages. |

    | `page` | The number of the page. |

    | `pageCount` | The number of pages. |


    A page after the last one is not an error: `data` is empty and `count` is
    `0`.


    ## Sorting


    Sort a list with `sort=field,ASC` or `sort=field,DESC`. Repeat the parameter
    to sort on several fields, in the order given:
    `?sort=updatedAt,ASC&sort=id,ASC`. Each list route gives the fields it sorts
    on and its default sort. A field outside this list returns `400`.


    Items with the same values on all the sort fields come back in no fixed
    order, and can change pages between two requests: add `sort=id,ASC` as the
    last sort field to keep their order stable. An item created, updated or
    deleted while the pages are read can still move the items of the next pages.


    ## Amounts


    All amounts are integers, in hundredths of the currency unit, whatever the
    currency: `1250` is 12.50 EUR, and `500000` is 5,000 JPY. An amount is in
    the `currency` of its item, except `defaultCurrencyAmount`, which is in the
    default currency of the account.
  contact:
    email: integration@leanpay.fr
servers:
  - url: https://api.leanpay.fr/v1/public
security: []
tags:
  - name: clients
  - name: invoices
  - name: credit-notes
  - name: misc-operations
  - name: contacts
  - name: addresses
  - name: payments
  - name: portal-payments
  - name: paybacks
  - name: links
  - name: comments
  - name: deleted-elements
  - name: reminders
  - name: client-groups
  - name: client-properties
  - name: client-payment-schedules
paths:
  /clients/portal-session:
    post:
      tags:
        - clients
      summary: Create a portal session
      description: Create a session of the client portal, and return the URL that opens it.
      operationId: createClientPortalSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateClientPortalSessionRequest'
            example:
              client:
                externalId: CLI-0042
              expiresInSeconds: 86400
      responses:
        '201':
          description: The portal session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateClientPortalSessionResponse'
              example:
                url: >-
                  https://pay.acme.com/portal/9bfc607e-4e58-4f4e-a93b-cd934958933f/auth?sessionId=24268195-51ac-4af7-843d-8ec52b4792a7&verifier=c2lnbmVkLXZlcmlmaWVy
        '404':
          description: The client referenced by `client` does not exist.
      security:
        - authorization: []
components:
  schemas:
    CreateClientPortalSessionRequest:
      type: object
      properties:
        client:
          $ref: '#/components/schemas/ClientReference'
        expiresInSeconds:
          description: >-
            Lifetime of the session, in seconds. Left out, the session never
            expires.
          type: integer
          minimum: 1
      required:
        - client
    CreateClientPortalSessionResponse:
      type: object
      properties:
        url:
          description: URL that opens the client portal.
          type: string
          format: uri
      required:
        - url
    ClientReference:
      oneOf:
        - type: object
          required:
            - id
          properties:
            id:
              description: Id of the client.
              type: string
              format: uuid
        - type: object
          required:
            - externalId
          properties:
            externalId:
              description: Id of the client outside LeanPay.
              type: string
              maxLength: 80
  securitySchemes:
    authorization:
      type: apiKey
      name: Authorization
      in: header

````

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