> For the complete documentation index, see [llms.txt](https://api.epixelsoftware.help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.epixelsoftware.help/user-address.md).

# User Address

## Get Address Details

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/get/address/`

This API endpoint will give you the user address details.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

{% tabs %}
{% tab title="200 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserAddress": {
            "address": "<address>",
            "city": "<city>",
            "postcode": "<postcode>",
            "phone": "<phone_number>",
            "state": {
                "id": <state_id>,
                "name": <state_name>
            },
            "country": {
                "id": <country_id>,
                "name": <country_name>,
                "sortname": <country_short_name_code>
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
​var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/address/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

#### **PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/get/address/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## Update Address Details

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/manage/address/`

This API endpoint will update user address details.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

#### Request Body

| Name                                       | Type   | Description                                                                                                |
| ------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------- |
| country<mark style="color:red;">\*</mark>  | string | <p>country id</p><p><a data-mention href="/pages/-MLubYbkIUjQIB9ta-sz">/pages/-MLubYbkIUjQIB9ta-sz</a></p> |
| address<mark style="color:red;">\*</mark>  | string | address                                                                                                    |
| city<mark style="color:red;">\*</mark>     | string | city                                                                                                       |
| postcode<mark style="color:red;">\*</mark> | string | postcode                                                                                                   |
| phone<mark style="color:red;">\*</mark>    | string | phone number                                                                                               |
| state<mark style="color:red;">\*</mark>    | string | <p> state id</p><p><a data-mention href="/pages/-MLucOCnGnt1gwEl_mE1">/pages/-MLucOCnGnt1gwEl\_mE1</a></p> |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/manage/address/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'address': '<address>',
    'city': '<city>',
    'phone': '<phone>',
    'postcode': '<postcode>'
    'state': '<state_id>',
    'country': '<country_id>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/manage/address/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('address' => '<address>','city' => '<city>','phone' => '<phone>','postcode' => '<postcode>','state' => '<state_id>','country' => '<country_id>',)
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field                          | Description                                                                       |
| ----------- | ---------------- | ------------------------------ | --------------------------------------------------------------------------------- |
| 400         | Validation Error | phone                          | Phone number must be entered in the formate: '99999999'. Up to 15 digits allowed. |
| 400         | Validation Error | postcode                       | The postcode is not valid for \<country\_name>.                                   |
| 400         | Validation Error | country, state                 | A valid integer is required.                                                      |
| 400         | Validation Error | address, phone, city, postcode | This field may not be blank.                                                      |
