# Customer Sessions

Creating customer session allows customers to log in to the Portal. You can use this endpoint to generate url that customer will be redirected to. By default customer session expires after a day.

# Create Customer Session

POST https://api.tratta.io/api/v1/customer-sessions

curl https://api.tratta.io/api/v1/customer-sessions \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d customer_id="customer-uuid" \
 -d expiration_return_url="https://example.com/return-url"

# Parameters

customer_id required|string

This can be both Customer id (uuid) generated in Tratta or external Customer id external_id provided in Create Customer.

debt_account_id optional|string

This can be both Debt Account id (uuid) generated in Tratta or external Debt Account id external_id provided in Create Debt Account.

URL pointing to Debt Account detail can be generated with optional debt_account_id instead of customer_id.

valid_until optional|integer

This is how long session link should be active for in hours. session will expire after the number of hours specified. Default is 1 hour.

By default customer session expires after 24 hours from the most recent time used. Maximum time limit for session link is 90 days (2160 hours).

return_url optional|url

When customer successfully pays, they will be redirected to return_url.

expiration_return_url optional|url

If session expires, customer will be redirected from Portal to expiration_return_url specified here.

destination optional|string

Supported values:

  • accounts_list : when customer_id is present in request body.
  • accounts_list, account_checkout, account_detail : when debt_account_id is present in the request body.

# Returns

A json with data property that contains created customer session object.

  "id": "string",
  "portal_url": "url",
  "return_url": "url",
  "expiration": "ISO8601"

# Integrating Url Redirects into your App

<form method="POST" action="/create-customer-session">
  <button type="submit">Pay</button>
  1. /create-customer-session on your app's backend calls Create Customer Session
  2. Your backend redirects customer's request to portal_url from response.