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

# Sessions

> Maintain state and user data across Opal interactions.

Opal Sessions are long-lived stateful connections between your app and Opal.
They allow you to store user data, resume user sessions, and retrieve data later.
Sessions are created when you create an Opal Token, and when passed into Opal,
they are automatically resumed.

## Creating a new session

First, create a new Opal Token with your desired configuration. This will create a new session.

<RequestExample>
  ```bash cURL theme={null}
  curl https://production.methodfi.com/opal/token \
    -X POST \
    -H "Authorization: Bearer sk_WyZEWVfTcH7GqmPzUPk65Vjc" \
    -H "Content-Type: application/json" \
    -d '{
      "mode": "card_connect",
      "entity_id": "ent_fc92i43kc34",
      "card_connect": {
        "selection_type": "single"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "token": "otkn_THpBacqVBBrDkfqUf9htjm4QWAEJLY9a",
      "valid_until": "2025-05-08T22:21:40.312Z",
      "session_id": "osess_zde3mW34pEHqV"
    },
    "message": null
  }
  ```
</ResponseExample>

## Resuming an existing session

To resume an existing session, create a new token by passing the `session_id` from a previous session

<RequestExample>
  ```bash cURL theme={null}
  curl https://production.methodfi.com/opal/token \
    -X POST \
    -H "Authorization: Bearer sk_WyZEWVfTcH7GqmPzUPk65Vjc" \
    -H "Content-Type: application/json" \
    -d '{
      "session_id": "osess_zde3mW34pEHqV"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "token": "otkn_THpBacqVBBrDkfqUf9htjm4QWAEJLY9a",
      "valid_until": "2025-05-08T22:21:40.312Z",
      "session_id": "osess_zde3mW34pEHqV"
    },
    "message": null
  }
  ```
</ResponseExample>


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