# 🚧 Locations

Locations allow you to represent Creditors, Collectors or Portfolios.

# Create Location

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

curl https://api.tratta.io/api/v1/locations \
 -H "Authorization: Bearer eyJ0eXA3asdk..." \
 -d name="Location Name"

# Parameters


name required|string

Name of the Location.

external_id optional|string

External id of location representing Creditor, Collector or Portfolio in your system.

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

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

# Returns


A json with data property that contains created location object.

{
  "id": "string",
  "name": "string",
  "external_id": "string",
  "children": [
    {
        "id": "string",
        "name": "string",
        "external_id": null
    },
    ...
  ],
  "parent": {
      "id": "string",
      "name": "string",
      "external_id": null
  },
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Update Location

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

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

# Parameters


name string

Name of the Location.

external_id string

External id of location representing Creditor, Collector or Portfolio in your system.

parent_id required|string

Uuid or external id of the parent location. Allows you to create a tree like parent-child association between locations.

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

# Returns


A json with data property that contains created location object.

{
  "id": "string",
  "name": "string",
  "external_id": "string",
  "children": [
    {
        "id": "string",
        "name": "string",
        "external_id": null
    },
    ...
  ],
  "parent": {
      "id": "string",
      "name": "string",
      "external_id": null
  },
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Get Location

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

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

# Parameters


id required_if:external_id missing|string

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

# Returns


A json with data property that contains created location object.

{
  "id": "string",
  "name": "string",
  "external_id": "string",
  "children": [
    {
        "id": "string",
        "name": "string",
        "external_id": null
    },
    ...
  ],
  "parent": {
      "id": "string",
      "name": "string",
      "external_id": null
  },
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# List Locations

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

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

# Returns


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

{
  "id": "string",
  "name": "string",
  "external_id": "string",
  "children": [
    {
        "id": "string",
        "name": "string",
        "external_id": null
    },
    ...
  ],
  "parent": {
      "id": "string",
      "name": "string",
      "external_id": null
  },
  "metadata": [{
    "attribute": "key",
    "value": "value"
  }, {
    "attribute": "key1",
    "value": "value"
  }]
}

# Delete Location

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

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

# Parameters


id required_if:external_id missing|string

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

# Returns


{
  "success": "boolean"
}