# 🚧 Customers

Customers represent Debtors. You can attach one or more Debt Accounts to the Customer. Creating Customers allows them to login to the Portal and pay off Debt.

# Create Customer

POST https://api.tratta.io/api/v1/customers

curl https://api.tratta.io/api/v1/customers \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d name="Customer Name" \
 -d email="test@email.com"

# Parameters


name required|string

Name of the customer. For example, first name and last name or company name.

email string|email

Email of the customer.

external_id optional|string

External id of customer in the 3rd party application.

phone optional|string

Phone number of customer.

Whether this is the primary address of customer

address optional

  • name optional|string
  • line1 optional|string
  • line2 optional|string
  • city optional|string
  • postal_code optional|string
  • state optional|string
  • country optional|string
  • is_primary optional|boolean

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

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

# Returns

A json with data property that contains created customer object.

{
  "id": "string",
  "external_id": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "address": [{
    "name": "string",
    "city" : "string",
    "postal_code" : "string",
    "country" : "string",
    "line1" : "string",
    "line2" : "string",
    "state" : "string",
    "is_primary": "boolean"
  }],
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Update Customer

PUT https://api.tratta.io/api/v1/customers/{id|external_id}

curl https://api.tratta.io/api/v1/customers/{id|external_id} \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d name="Updated Customer Name" \
 -X PUT

# Parameters


name string

Name of the customer. For example, first name and last name or company name.

email string|email

Email of the customer.

external_id string

External id of customer in the 3rd party application.

phone string

Phone number of customer.

primary_address object

  • name string
  • line1 string
  • line2 string
  • city string
  • postal_code string
  • state string
  • country string

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 customer object will be deleted.

# Get Customer

GET https://api.tratta.io/api/v1/customers/{id|external_id}

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

# Parameters

id required_if:external_id missing|string

Uuid of customer provided from Tratta when Creating Customer 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 customer provided by you through external_id parameter when Creating Customer object. This url parameter is required only if the id wasn't provided instead.

# Returns

A json with data property that contains created customer object.

{
  "id": "string",
  "external_id": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "addresses": [
    {
      "name": "string",
      "city": "string",
      "postal_code": "string",
      "country": "string",
      "line1": "string",
      "line2": "string",
      "state": "string",
      "is_primary": "boolean"
    }
  ],
  "metadata": [
    {
      "attribute": "key",
      "value": "value"
    },
    {
      "attribute": "key1",
      "value": "value"
    }
  ]
}

# List Customers

GET https://api.tratta.io/api/v1/customers

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

# Returns

A json with data property that contains array of customer objects.

{
  "id": "string",
  "external_id": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "addresses": [
    {
      "name": "string",
      "city": "string",
      "postal_code": "string",
      "country": "string",
      "line1": "string",
      "line2": "string",
      "state": "string",
      "is_primary": "boolean"
    }
  ],
  "metadata": [
    {
      "attribute": "key",
      "value": "value"
    },
    {
      "attribute": "key1",
      "value": "value"
    }
  ]
}

# Create Customer Address

GET https://api.tratta.io/api/v1/customers/{id/external_id}/addresses

curl https://api.tratta.io/api/v1/customers/{id/external_id}/addresses \
 -H "Authorization: Bearer eyJ0eXA3asdk..."
 -d name="Updated Address Name" \
 -d is_primary=false \
 -X POST

# Parameters

name optional|string

country optional|string

city optional|string

state optional|string

postal_code required|string

line1 optional|string

line2 optional|string

is_primary optional|string

is_primary determines if this the primary address of the customer. Defaults to false, but set to true when creating the first address for the customer. A customer can have only one primary address at any given time.

# Returns

{
    "id": "string",
    "name": "string",
    "city": "string",
    "postal_code": "string",
    "country": "string",
    "line1": "string",
    "line2": "string",
    "state": "string",
    "is_primary": "boolean"
}

# List customer addresses

GET https://api.tratta.io/api/v1/customers/{id/external_id}/addresses

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

# Parameters

id required_if:external_id missing|string

Uuid of customer provided from Tratta when Creating Customer object. This url parameter is required only if the external_id wasn't provided instead.

[
    {
        "id": "string",
        "name": "string",
        "city": "string",
        "postal_code": "string",
        "country": "string",
        "line1": "string",
        "line2": "string",
        "state": "string",
        "is_primary": "boolean"
    },
    {...}
]

# Update Customer Address

PUT https://api.tratta.io/api/v1/customers/{id/external_id}/addresses/{addressId}

curl https://api.tratta.io/api/v1/customers/{id/external_id}/addresses/{addressId} \
 -H "Authorization: Bearer eyJ0eXA3asdk..."

# Parameters

id required_if:external_id missing|string

Uuid of customer provided from Tratta when Creating Customer object. This url parameter is required only if the external_id wasn't provided instead.

addressId required

uuid of address provided by Tratter when Creating Customer object,

 -d name="Updated Address Name" \
 -d is_primary=true \
 -X PUT
{
    "id": "string",
    "name": "string",
    "city": "string",
    "postal_code": "string",
    "country": "string",
    "line1": "string",
    "line2": "string",
    "state": "string",
    "is_primary": "boolean"
}

# Delete Customer Address

DELETE https://api.tratta.io/api/v1/customers/{id/external_id}/addresses/{addressId}

curl https://api.tratta.io/api/v1/customers/{id/external_id}/addresses/{addressId} \
 -H "Authorization: Bearer eyJ0eXA3asdk..."

# Parameters

id required_if:external_id missing|string

Uuid of customer provided from Tratta when Creating Customer object. This url parameter is required only if the external_id wasn't provided instead.

addressId required

uuid of address provided by Tratter when Creating Customer object,

# Returns

{
  "success": "boolean"
}

# Delete Customer

DELETE https://api.tratta.io/api/v1/customers/{id/external_id}

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

# Returns

{
  "success": "boolean"
}