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

# Address

## General data

This section corresponds to contact address field data.

### Category type

| Name                       | Value |
| -------------------------- | ----- |
| **Home**                   | 0     |
| **Mailing**                | 1     |
| **Billing**                | 2     |
| **Postal**                 | 3     |
| **Household registration** | 4     |
| **Other**                  | 5     |

## Search contact address

```javascript
GET https://{API_DOMAIN}/api/v1/address
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    '{"city_id":1}'
    https://{API_HOST}/api/v1/address
```

### Form Data

The table below shows available filter conditions

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                          |
| --------------- | -------- | ------- | ------ | -------------------------------------------------------------------- |
| **contact\_id** | false    | NULL    | Number | Customer id                                                          |
| **type**        | false    | NULL    | Number | 0:Home,1:Mailing,2:Billing,3:Postal,4:Household registration,5:Other |
| **address**     | false    | NULL    | String | Address                                                              |
| **country\_id** | false    | NULL    | Number | Country id                                                           |
| **state\_id**   | false    | NULL    | Number | City id                                                              |
| **city\_id**    | false    | NULL    | Number | District id                                                          |
| **description** | false    | NULL    | String | Address description                                                  |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                                |
| -------- | ---------------- | ---------------------------------------------------------- |
| data     | Array of objects | [Address array](/developer/api/response-object.md#address) |
| meta     | Object           | Pagination meta                                            |

```javascript

{
    "data": [
        {
            "id": 2678,
            "type": 1,
            "enum_type": {
                "key": "MAILING",
                "value": 1,
                "description": "mail address"
            },
            "address": "8th Floor, No. 35, Ai 1st Road, Ren'ai District, Keelung City",
            "contact_id": 1938277,
            "profile_id": 1938247,
            "state": {
                "id": 2,
                "country_id": 1,
                "name": "Keelung City"
            },
            "state_id": 2,
            "country": {
                "id": 1,
                "name": "Taiwan",
                "abbrev": null
            },
            "country_id": 1,
            "city": {
                "id": 1,
                "state_id": 2,
                "name": "Ren'ai District",
                "zipcode": "200"
            },
            "city_id": 1,
            "description": null
        },
        {
            "id": 2830,
            "type": 1,
            "enum_type": {
                "key": "MAILING",
                "value": 1,
                "description": "mail address"
            },
            "address": "No. 19, Ai 1st Road",
            "contact_id": 1938482,
            "profile_id": 1938452,
            "state": {
                "id": 2,
                "country_id": 1,
                "name": "Keelung City"
            },
            "state_id": 2,
            "country": {
                "id": 1,
                "name": "Taiwan",
                "abbrev": null
            },
            "country_id": 1,
            "city": {
                "id": 1,
                "state_id": 2,
                "name": "Ren'ai District",
                "zipcode": "200"
            },
            "city_id": 1,
            "description": null
        }
    ],
    "links": {
        "first": "https://firstline.localhost/api/address?per_page=2&city_id=1&page=1",
        "last": "https://firstline.localhost/api/address?per_page=2&city_id=1&page=63",
        "prev": null,
        "next": "https://firstline.localhost/api/address?per_page=2&city_id=1&page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 63,
        "path": "https://firstline.localhost/api/address",
        "per_page": "2",
        "to": 2,
        "total": 126
    }
}
```

## Get specified customer's contact addresses

## Get specified contact address

```javascript
https://{API_DOMAIN}/api/v1/address/{address}
```

```javascript
shell curl -X GET -H "Content-Type: application/json" https://{API_HOST}/api/v1/address/1 
```

### URL Parameters

| PARAMETER   | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                |
| ----------- | -------- | ------- | ------ | ---------------------------------------------------------- |
| **address** | True     | Null    | Number | [Address](/developer/api/response-object.md#address) id of |

### Response

Please refer to[Address](/developer/api/response-object.md#address)Response format

| PROPERTY | TYPE   | DESCRIPTION                                          |
| -------- | ------ | ---------------------------------------------------- |
| **data** | Object | [Address](/developer/api/response-object.md#address) |

```javascript

{
    "data": {
        "id": 1,
        "type": 3,
        "address": "67, rue Michelle Jones\n81785 Berge",
        "profile_id": 1,
        "state": {
            "id": 1,
            "country_id": 1,
            "name": "Taipei City"
        },
        "state_id": 1,
        "country": {
            "id": 1,
            "name": "Taiwan",
            "abbrev": null
        },
        "country_id": 1,
        "city": {
            "id": 1,
            "state_id": 1,
            "name": "Ren'ai District",
            "zipcode": "200"
        },
        "city_id": 1,
        "description": null
    }
}

```

## Add specified customer's contact address

```javascript
POST https://{API_DOMAIN}/api/v1/address
```

```javascript
curl -X POST
    -H "Content-Type: application/json"
    '{"profile_id":1,"country_id":1,"state_id":1,"city_id":1,"address": "67, rue Michelle Jones 81785 Berge"}'
    https://{API_HOST}/api/v1/address
```

### Form Data

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                     |
| --------------- | -------- | ------- | ------ | --------------------------------------------------------------- |
| **contact\_id** | true     | NULL    | Number | Customer id                                                     |
| **type**        | true     | NULL    | Number | 0:Home,1:Postal,2:Billing,3:Courier,4:Current residence,5:Other |
| **address**     | true     | NULL    | String | Address                                                         |
| **country\_id** | false    | NULL    | Number | Country id                                                      |
| **state\_id**   | false    | NULL    | Number | City id                                                         |
| **city\_id**    | false    | NULL    | Number | District id                                                     |
| **description** | false    | NULL    | String | Address description                                             |

### Response

```javascript
{
    "data": {
        "id": 1,
        "type": 3,
        "address": "67, rue Michelle Jones\n81785 Berge",
        "profile_id": 1,
        "state": {
            "id": 1,
            "country_id": 1,
            "name": "Taipei City"
        },
        "state_id": 1,
        "country": {
            "id": 1,
            "name": "Taiwan",
            "abbrev": null
        },
        "country_id": 1,
        "city": {
            "id": 1,
            "state_id": 1,
            "name": "Ren'ai District",
            "zipcode": "200"
        },
        "city_id": 1,
        "description": null
    }
}
```

## Modify contact address

```javascript
PUT https://{API_DOMAIN}/api/v1/address/{address}
```

```javascript
curl -X PUT
    -H "Content-Type: application/json"
    '{"address": "Section 1, Ren'ai Road"}'
    https://{API_HOST}/api/v1/address/1
```

### URL Parameters

| PARAMETER   | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ----------- | -------- | ------- | ------ | ----------- |
| **address** | true     | NULL    | Number | Address id  |

### Form Data

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                     |
| --------------- | -------- | ------- | ------ | --------------------------------------------------------------- |
| **contact\_id** | false    | NULL    | Number | Customer id                                                     |
| **type**        | false    | NULL    | Number | 0:Home,1:Postal,2:Billing,3:Courier,4:Current residence,5:Other |
| **address**     | false    | NULL    | String | Address                                                         |
| **country\_id** | false    | NULL    | Number | Country id                                                      |
| **state\_id**   | false    | NULL    | Number | City id                                                         |
| **city\_id**    | false    | NULL    | Number | District id                                                     |
| **description** | false    | NULL    | String | Address description                                             |

### Response

Please refer to[Address](/developer/api/response-object.md#address)Response format

```javascript
{
    "data": {
        "id": 1,
        "type": 3,
        "address": "Section 1, Xinyi Road",
        "profile_id": 1,
        "state": {
            "id": 1,
            "country_id": 1,
            "name": "Taipei City"
        },
        "state_id": 1,
        "country": {
            "id": 1,
            "name": "Taiwan",
            "abbrev": null
        },
        "country_id": 1,
        "city": {
            "id": 1,
            "state_id": 1,
            "name": "Ren'ai District",
            "zipcode": "200"
        },
        "city_id": 1,
        "description": null
    }
}
```

## Delete contact address

Http status is 204

```javascript
DELETE https://{API_DOMAIN}/api/v1/address/{address}
```

```javascript
curl -X DELETE
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/address/1
```

### URL Parameters

| PARAMETER   | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| ----------- | -------- | ------- | ------ | ----------- |
| **address** | true     | NULL    | Number | Address id  |

> Returns JSON format

```
{}
```
