# Retrieve a portal session

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


This API retrieves a portal session using `portal_session_id` as a path parameter.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/portal_sessions/portal___test__KyVnGlSBWm8Rw2NP \
     -u {site_api_key}:
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = PortalSession.Retrieve("portal___test__KyVnGlSBWm8Rw2NP").Request();

PortalSession portalSession = result.PortalSession;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    portalsessionAction "github.com/chargebee/chargebee-go/v3/actions/portalsession"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := portalsessionAction.Retrieve("portal___test__KyVnGlSBWm8Rw2NP").Request()
    if err != nil {
        fmt.Println(err)
    } else {
        PortalSession := res.PortalSession
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.PortalSessionRetrieveRequest{
    Id : "portal___test__KyVnGlSBWm8Rw2NP",
}
  res, err := client.PortalSession.Retrieve(req)
      if err != nil {
        fmt.Println(err)
    } else {
        PortalSession := res.PortalSession
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = PortalSession.retrieve("portal___test__KyVnGlSBWm8Rw2NP").request();

        PortalSession portalSession = result.portalSession();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.portalSession.PortalSession;
import com.chargebee.v4.models.portalSession.params.PortalSessionRetrieveParams;
import com.chargebee.v4.models.portalSession.responses.PortalSessionRetrieveResponse;

public class PortalSessionRetrieve {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        PortalSessionRetrieveResponse response = client.portalSessions().retrieve("portal___test__KyVnGlSBWm8Rw2NP");

        PortalSession portalSession = response.getPortalSession();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.portalSession.retrieve("portal___test__KyVnGlSBWm8Rw2NP");

    console.log(result);
    const portalSession = result.portal_session;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->portalSession()->retrieve("portal___test__KyVnGlSBWm8Rw2NP");
$portalSession = $result->portal_session;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.PortalSession.retrieve("portal___test__KyVnGlSBWm8Rw2NP")
portal_session = response.portal_session
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::PortalSession.retrieve("portal___test__KyVnGlSBWm8Rw2NP")

portal_session = result.portal_session
```

## Sample Response

```json
{
  "portal_session": {
    "access_url": "https://yourapp.chargebeeportal.com/portal/access/__test__v3rABlcM6Cvfhcu6LGIMnNmp9sTPHcuGKcu",
    "created_at": 1517505972,
    "customer_id": "__test__KyVnHhSBWm8QH2sR",
    "expires_at": 1517506272,
    "id": "portal___test__KyVnGlSBWm8Rw2NP",
    "linked_customers": [
      {
        "customer_id": "__test__KyVnHhSBWm8QH2sR",
        "email": "duncan@user.com",
        "has_active_subscription": false,
        "has_billing_address": false,
        "has_payment_method": false,
        "object": "linked_customer"
      },
      {..}
    ],
    "login_at": 1517505972,
    "login_ipaddress": "127.0.0.1",
    "object": "portal_session",
    "redirect_url": "https://cbdemo.com:8080",
    "status": "activated",
    "token": "__test__v3rABlcM6Cvfhcu6LGIMnNmp9sTPHcuGKcu"
  }
}
```

## URL Format

**GET** https://[site].chargebee.com/api/v2/portal_sessions/{portal-session-id}

## Returns

- `portal_session` (Portal session object)
  Resource object representing portal\_session
