Vai al contenuto principale
POST
/
customers
/
{customer_id}
/
customer-portal
/
session
JavaScript
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});

const customerPortalSession = await client.customers.customerPortal.create(
  'cus_TV52uJWWXt2yIoBBxpjaa',
);

console.log(customerPortalSession.link);
import os
from dodopayments import DodoPayments

client = DodoPayments(
bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"), # This is the default and can be omitted
)
customer_portal_session = client.customers.customer_portal.create(
customer_id="cus_TV52uJWWXt2yIoBBxpjaa",
)
print(customer_portal_session.link)
package main

import (
"context"
"fmt"

"github.com/dodopayments/dodopayments-go"
"github.com/dodopayments/dodopayments-go/option"
)

func main() {
client := dodopayments.NewClient(
option.WithBearerToken("My Bearer Token"),
)
customerPortalSession, err := client.Customers.CustomerPortal.New(
context.TODO(),
"cus_TV52uJWWXt2yIoBBxpjaa",
dodopayments.CustomerCustomerPortalNewParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", customerPortalSession.Link)
}
package com.dodopayments.api.example;

import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.customers.CustomerPortalSession;
import com.dodopayments.api.models.customers.customerportal.CustomerPortalCreateParams;

public final class Main {
private Main() {}

public static void main(String[] args) {
DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

CustomerPortalSession customerPortalSession = client.customers().customerPortal().create("cus_TV52uJWWXt2yIoBBxpjaa");
}
}
package com.dodopayments.api.example

import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.customers.CustomerPortalSession
import com.dodopayments.api.models.customers.customerportal.CustomerPortalCreateParams

fun main() {
val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

val customerPortalSession: CustomerPortalSession = client.customers().customerPortal().create("cus_TV52uJWWXt2yIoBBxpjaa")
}
require "dodopayments"

dodo_payments = Dodopayments::Client.new(
bearer_token: "My Bearer Token",
environment: "test_mode" # defaults to "live_mode"
)

customer_portal_session = dodo_payments.customers.customer_portal.create("cus_TV52uJWWXt2yIoBBxpjaa")

puts(customer_portal_session)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Dodopayments\Client;
use Dodopayments\Core\Exceptions\APIException;

$client = new Client(
bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
environment: 'test_mode',
);

try {
$customerPortalSession = $client->customers->customerPortal->create(
'cus_TV52uJWWXt2yIoBBxpjaa', returnURL: 'return_url', sendEmail: true
);

var_dump($customerPortalSession);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using DodoPayments.Client;
using DodoPayments.Client.Models.Customers.CustomerPortal;

DodoPaymentsClient client = new();

CustomerPortalCreateParams parameters = new()
{
CustomerID = "cus_TV52uJWWXt2yIoBBxpjaa"
};

var customerPortalSession = await client.Customers.CustomerPortal.Create(parameters);

Console.WriteLine(customerPortalSession);
use dodopayments::Client;

#[tokio::main]
async fn main() -> dodopayments::Result<()> {
let client = Client::from_env()?;
let customer_id = "customer_id";
let result = client
.customers()
.customer_portal()
.create()
.customer_id(customer_id)
.query(serde_json::json!({}))
.await?;
println!("{result:?}");
Ok(())
}
curl --request POST \
--url https://test.dodopayments.com/customers/{customer_id}/customer-portal/session \
--header 'Authorization: Bearer <token>'
{
  "link": "<string>"
}

Autorizzazioni

Authorization
string
header
obbligatorio

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Parametri del percorso

customer_id
string
obbligatorio

Customer Id

Parametri della query

send_email
boolean

If true, will send link to user.

return_url
string

Optional return URL for this session. Overrides the business-level default. This URL will be shown as a "Return to {business}" back button in the portal.

Risposta

Successfully send email to customer (if they exist)

Ultima modifica il 1 aprile 2026