# Addresses

# Validation

TIP

For addresses you do not need to worry about “uniqueness” as the endpoint handles this for you. Need to link an address? Just call this endpoint and use the “id” from the returned response.

Some entities allow address inlining when creating/updating them. The following validation rules also apply when doing so. If an address is marked as nullable, the validation only triggers if any address information was specified.

{
  "street": [
    "required",
    "max:50"
  ],
  "house_number": [
    "nullable",
    "max:10"
  ],
  "box": [
    "nullable",
    "max:10"
  ],
  "city": [
    "required",
    "max:50"
  ],
  "postal_code": [
    "required",
    "max:10"
  ],
  "region": [
    "nullable",
    "max:50"
  ],
  "country_id": [
    "required",
    "id exists in countries",
  ]
}

# Create

--- ENDPOINT ---

Domain: equidata 
Url: /addresses
Method: POST

--- EXAMPLE PAYLOAD ---
{
    "street": "streetname",
    "house_number": 123,
    "box": "A",
    "city": "city",
    "postal_code": "postal",
    "region": null,
    "country_id": 123
}
--- EXAMPLE RESPONSE ---
{
    "id": 456, // when repeatedly doing this request, id is always 456
    "street": "streetname",
    "house_number": 123,
    "box": "A",
    "city": "city",
    "postal_code": "postal",
    "region": null,
    "country_id": 123
}

# Show

--- ENDPOINT ---

Domain: equidata 
Url: /addresses/124
Method: GET

--- EXAMPLE RESPONSE ---
{
    "id": 124,
    "street": "Vervoortboulevard",
    "house_number": "92",
    "box": "77",
    "city": "Wervik",
    "postal_code": "2970",
    "region": "Henegouwen",
    "country": {
        "id": 49,
        "name": "Christmas Island",
        "iso_2": "CX",
        "iso_3": "CXR"
    }
}