# 🚧 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 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.

return_url optional|url

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

# 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.