# 🚧 Debt Accounts

Debt Accounts represent Debt to be paid off by Customers. You can attach one or more Debt Accounts to single Customer. Debt Account can be attached to Location.

# Create Debt Account

POST https://api.tratta.io/api/v1/debt-accounts

curl https://api.tratta.io/api/v1/debt-accounts \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d customer_id="customer-uuid" \
 -d balance=10000

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

location_id required|string

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

location_name required / optional|string

Required only if the location location_id you provide does not exist in the system. In that case Location will be automatically created and name is required so we can set it properly.

external_id optional|string

External debt account id generated in the 3rd party application.

billing_type optional|array

This determines the payment option that will be specified in the return_url property when creating Customer Session.

Signifies the type of payment. Supported values:

  • one-time
  • full-payment
  • payment-plan
value return url
one-time {portal_url}/one-time/amount
full-payment {portal_url}/payment
payment-plan {portal_url}/payment-plan/frequency
  • If nothing is specified, all payment options will be displayed.
  • If two (2) options are specified, those 2 options will displayed.

external_account_number optional|string

External account number associated with debt account.

payment_plan optional|object

Specifies payment plan that will be created for Debt account.

{
  "payment_plan": {
    "frequency": "weekly",
    "recurring_day": "monday",
    "amount": "1000"
  }
}

Supported frequencies:

  • weekly
  • every_other_week
  • monthly

Supported weekly and every_other_week recurring days:

  • monday
  • tuesday
  • wednesdy
  • thursday
  • friday
  • saturday
  • sunday

Supported monthly recurring days:

  • 1st
  • 15th
  • last_day

Checkout the Payment Plan for more information on the Payment Plan object.

balance required|number:cents

Debt amount placed on Tratta. This amount is usually static. It can be referred to as original balance or full balance owed prior to any payments made.

current_balance optional|number:cents

Refers to the total unpaid amount minus any payments, also referred to as outstanding balance. If current_balance is not specified it will be set to balance value.

metadata optional|key:max:255|value:max:255

Json object of key value pairs for meta data you may want to attach to debt account object.

status

Current state of the debt account. Accepted values:

  • active : Customer is able to do everything normally.
  • archived : Account hidden from customer dashboard. Customer cannot make payment to this account.
  • closed: No payments accepted to this specific account, but customer can login and view.
  • locked : Customer can't view or pay to this specific account.
  • paid_off : Debt account has been fully paid off.

🚧 Status effects are currently Work in progress.

external_status optional|string

External status of the debt account

# Returns


A json with data property that contains created debt account object.

{
  "id": "string",
  "customer": "object",
  "billing_type": "array",
  "balance": "float",
  "current_balance": "float",
  "external_company_id": "string",
  "created_at": "timestamp",
  "rules": "",
  "location": "object",
  "locations": "array",
  "transactions": "array",
  "payment_plan": "object",
  "charges": "array",
  "external_account_number": "string",
  "external_status": "string",
  "location": "object",
  "status": "string",
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Update Debt Account

PUT https://api.tratta.io/api/v1/debt-accounts/{id|external_id}

curl https://api.tratta.io/api/v1/debt-accounts/{id|external_id} \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d customer_id="customer-uuid" \
 -d balance=10000
 -X PUT

# Parameters


external_id optional|string

External debt account id generated in the 3rd party application.

billing_type optional|array

Signifies the type of payment. Accepted values:

  • one-time
  • full-payment
  • payment-plan

external_account_number optional|string

External account number associated with debt account.

balance required|number:cents

Debt amount placed on Tratta. This amount is usually static. It can be referred to as original balance or full balance owed prior to any payments made.

current_balance optional|number:cents

Refers to the total unpaid amount minus any payments, also referred to as outstanding balance. If current_balance is not specified it will be set to balance value.

metadata optional|key:max:255|value:max:255

Key value pairs can be updated, when you PUT to the key a different value. When you PUT an empty value to existing key, it will be deleted. When you put and empty value to whole metadata, all of the metadata associated with debt account object will be deleted.

status

Current state of the debt account. Accepted values:

  • active : Customer is able to do everything normally.
  • archived : Account hidden from customer dashboard. Customer cannot make payment to this account.
  • closed: No payments accepted to this specific account, but customer can login and view.
  • locked : Customer can't view or pay to this specific account.
  • paid_off : Debt account has been fully paid off.

🚧 Status effects are currently Work in progress.

external_status optional|string

External status of the debt account

# Returns


A json with data property that contains created debt account object.

{
  "id": "string",
  "customer": "object",
  "billing_type": "array",
  "balance": "float",
  "current_balance": "float",
  "external_company_id": "string",
  "created_at": "timestamp",
  "rules": "",
  "location": "object",
  "locations": "array",
  "transactions": "array",
  "payment_plan": "object",
  "charges": "array",
  "external_account_number": "string",
  "external_status": "string",
  "location": "object",
  "status": "string",
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Get Debt Account

GET https://api.tratta.io/api/v1/debt-accounts/{id|external_id}

curl https://api.tratta.io/api/v1/debt-accounts/{id|external_id} \
 -H "Authorization: Bearer eyJ0eXA3asdk..."

# Parameters


id required_if:external_id missing|string

Uuid of debt account provided from Tratta when Creating Debt Account object. This url parameter is required only if the external_id wasn't provided instead.

external_id required_if:id missing|string

External id of debt account provided by you through external_id parameter when Creating Debt Account object. This url parameter is required only if the id wasn't provided instead.

# Returns


A json with data property that contains created debt account object.

{
  "id": "string",
  "customer": "object",
  "billing_type": "array",
  "balance": "float",
  "current_balance": "float",
  "external_company_id": "string",
  "created_at": "timestamp",
  "rules": "",
  "location": "object",
  "locations": "array",
  "transactions": "array",
  "payment_plan": "object",
  "charges": "array",
  "external_account_number": "string",
  "external_status": "string",
  "location": "object",
  "status": "string",
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# List Debt Accounts

GET https://api.tratta.io/api/v1/debt-accounts

curl https://api.tratta.io/api/v1/debt-accounts \
 -H "Authorization: Bearer eyJ0eXA3asdk..."

# Returns


A json with data property that contains array of debt account objects.

{
  "id": "string",
  "customer": "object",
  "billing_type": "array",
  "balance": "float",
  "current_balance": "float",
  "external_company_id": "string",
  "created_at": "timestamp",
  "rules": "",
  "location": "object",
  "locations": "array",
  "transactions": "array",
  "payment_plan": "object",
  "charges": "array",
  "external_account_number": "string",
  "external_status": "string",
  "location": "object",
  "status": "string",
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Delete Debt Account

DELETE https://api.tratta.io/api/v1/debt-accounts/{id/external_id}

curl https://api.tratta.io/api/v1/debt-accounts \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -X DELETE

# Parameters


id required_if:external_id missing|string

Uuid of debt account provided from Tratta when Creating Debt Account object. This url parameter is required only if the external_id wasn't provided instead.

external_id required_if:id missing|string

External id of debt account provided by you through external_id parameter when Creating Debt Account object. This url parameter is required only if the id wasn't provided instead.

# Returns


{
  "success": "boolean"
}