> For the complete documentation index, see [llms.txt](https://docs.commercelayer.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.commercelayer.io/core-api-reference/addresses/update.md).

# Update an address

How to update an existing address via API

To [update](https://docs.commercelayer.io/core/updating-resources) an existing address, send a `PATCH` request to the `/api/addresses/:id` endpoint, where `id` is the ID of the resource that you want to update.

Here below the list of all the possible arguments that you can pass with the request body.

## Request

**PATCH** <https://yourdomain.commercelayer.io/api/addresses/:id>

### Arguments

| Body Parameter                   | Type      | Required |
| -------------------------------- | --------- | -------- |
| **type**                         | `string`  | Required |
| **id**                           | `string`  | Required |
| attributes.**business**          | `boolean` | Optional |
| attributes.**first\_name**       | `string`  | Optional |
| attributes.**last\_name**        | `string`  | Optional |
| attributes.**company**           | `string`  | Optional |
| attributes.**line\_1**           | `string`  | Optional |
| attributes.**line\_2**           | `string`  | Optional |
| attributes.**city**              | `string`  | Optional |
| attributes.**zip\_code**         | `string`  | Optional |
| attributes.**state\_code**       | `string`  | Optional |
| attributes.**country\_code**     | `string`  | Optional |
| attributes.**phone**             | `string`  | Optional |
| attributes.**email**             | `string`  | Optional |
| attributes.**notes**             | `string`  | Optional |
| attributes.**lat**               | `float`   | Optional |
| attributes.**lng**               | `float`   | Optional |
| attributes.**billing\_info**     | `string`  | Optional |
| attributes.**\_add\_tags**       | `string`  | Optional |
| attributes.**\_remove\_tags**    | `string`  | Optional |
| attributes.**reference**         | `string`  | Optional |
| attributes.**reference\_origin** | `string`  | Optional |
| attributes.**metadata**          | `object`  | Optional |
| relationships.**geocoder**       | `object`  | Optional |
| relationships.**tags**           | `array`   | Optional |

### Example

{% tabs %}
{% tab title="Request" %}
The following request updates the address identified by the ID "XAyRWNUzyN":

```shell
curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "addresses",
    "id": "xYZkjABcde",
    "attributes": {
      "line_2": "Apt.23"
    },
    "relationships": {
      "geocoder": {
        "data": {
          "type": "geocoders",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "addresses",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN"
    },
    "attributes": {
      "business": false,
      "first_name": "John",
      "last_name": "Smith",
      "company": "The Red Brand Inc.",
      "full_name": "John Smith",
      "line_1": "2883 Geraldine Lane",
      "line_2": "Apt.23",
      "city": "New York",
      "zip_code": "10013",
      "state_code": "NY",
      "country_code": "US",
      "phone": "(212) 646-338-1228",
      "full_address": "2883 Geraldine Lane Apt.23, 10013 New York NY (US) (212) 646-338-1228",
      "name": "John Smith, 2883 Geraldine Lane Apt.23, 10013 New York NY (US) (212) 646-338-1228",
      "email": "john@example.com",
      "notes": "Please ring the bell twice",
      "lat": 40.6971494,
      "lng": -74.2598672,
      "is_localized": true,
      "is_geocoded": true,
      "provider_name": "google",
      "map_url": "https://www.google.com/maps/search/?api=1&query=40.6971494,-74.2598672",
      "static_map_url": "https://maps.googleapis.com/maps/api/staticmap?center=40.6971494,-74.2598672&size=640x320&zoom=15",
      "billing_info": "VAT ID IT02382940977",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "geocoder": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/relationships/geocoder",
          "related": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/geocoder"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/events"
        }
      },
      "tags": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/relationships/tags",
          "related": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/tags"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/addresses/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  },
  "meta": {
    "mode": "test",
    "organization_id": "xRRkjDFafe",
    "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.commercelayer.io/core-api-reference/addresses/update.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
