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

# Buat Sesi Portal Pelanggan

> Buat sesi Portal Pelanggan untuk pelanggan tertentu.



## OpenAPI

````yaml post /customers/{customer_id}/customer-portal/session
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.105.11
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /customers/{customer_id}/customer-portal/session:
    post:
      tags:
        - Customers
      operationId: create_customer_portal_session
      parameters:
        - name: send_email
          in: query
          description: If true, will send link to user.
          required: false
          schema:
            type: boolean
          style: form
        - name: return_url
          in: query
          description: >-
            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.
          required: false
          schema:
            type: string
          style: form
        - name: customer_id
          in: path
          description: Customer Id
          required: true
          schema:
            type: string
          example: cus_TV52uJWWXt2yIoBBxpjaa
      responses:
        '200':
          description: Successfully send email to customer (if they exist)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCustomerPortalSessionResponse'
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            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);
        - lang: Python
          source: |-
            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)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tcustomerPortalSession, err := client.Customers.CustomerPortal.New(\n\t\tcontext.TODO(),\n\t\t\"cus_TV52uJWWXt2yIoBBxpjaa\",\n\t\tdodopayments.CustomerCustomerPortalNewParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customerPortalSession.Link)\n}\n"
        - lang: Java
          source: >-
            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");
                }
            }
        - lang: Kotlin
          source: >-
            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")
            }
        - lang: Ruby
          source: >-
            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)
        - lang: PHP
          source: |-
            <?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();
            }
        - lang: C#
          source: >-
            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);
        - lang: Rust
          source: |-
            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(())
            }
components:
  schemas:
    CreateCustomerPortalSessionResponse:
      type: object
      required:
        - link
      properties:
        link:
          type: string
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````