Skip to content
Join our SlackContact usGet started

Create Customer Portal Session

client.CustomerPortal.NewSession(ctx, body) (*CustomerPortalNewSessionResponse, error)
post/customer-portal/sessions

Create Customer Portal Session

ParametersExpand Collapse
body CustomerPortalNewSessionParams
ReturnURL param.Field[string]

The URL to redirect customers to if they click the back button on the customer portal.

SubjectID param.Field[string]

The ID or external ID of the subject to create the customer portal session for.

ReturnsExpand Collapse
type CustomerPortalNewSessionResponse struct{…}
ExpiresAt Time

The date and time the customer portal session expires.

formatdate-time
SubjectID string

The ID of the subject for the customer portal session.

URL string

The URL to redirect to the customer portal session.

Create Customer Portal Session
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.CustomerPortal.NewSession(context.TODO(), lark.CustomerPortalNewSessionParams{
    ReturnURL: "https://example.com/dashboard",
    SubjectID: "subj_VyX6Q96h5avMho8O7QWlKeXE",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.SubjectID)
}
{
  "expires_at": "2025-11-01T16:50:13.177983+00:00",
  "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE",
  "url": "https://billing.uselark.ai/?session_id=cps_PVkgykTxbGx686bwD9Bvt8wGcyNCzxIXgQJyN1sa5SZBcRcRskrNJDOiPpRoooBKg6NiZKBrn1IMZoCT6oZOise48dqQG3Ps"
}
Returns Examples
{
  "expires_at": "2025-11-01T16:50:13.177983+00:00",
  "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE",
  "url": "https://billing.uselark.ai/?session_id=cps_PVkgykTxbGx686bwD9Bvt8wGcyNCzxIXgQJyN1sa5SZBcRcRskrNJDOiPpRoooBKg6NiZKBrn1IMZoCT6oZOise48dqQG3Ps"
}