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

# Address Migration

This guide covers the process of migrating address data using an API. Address migration allows users to import address data into their system from a migration file in CSV, XLS, or JSON format. The column names in the migration file must match the field names listed in the table below.

### Fields and Descriptions

#### User Data

| **Field Names** | **Data Type** | **Required** | **Descriptions**                                       |
| --------------- | ------------- | ------------ | ------------------------------------------------------ |
| user            | string        | true         | Customer Code of the user.                             |
| email           | string        | true         | The email of the user.                                 |
| phone\_number   | string        | false        | The phone number of the address                        |
| first\_name     | string        | true         | First name of the recipient (max 255 characters)       |
| last\_name      | string        | true         | Last name of the recipient (max 255 characters)        |
| title           | string        | false        | The address title (max 128 characters)                 |
| line            | string        | true         | The address line (max 255 characters)                  |
| tax\_office     | string        | false        | For legal entities                                     |
| tax\_no         | string        | false        | For legal entities                                     |
| country         | string        | true         | Must match the name in the database case-insensitively |
| city            | string        | true         | Must match the name in the database case-insensitively |
| township        | string        | true         | Must match the name in the database case-insensitively |
| district        | string        | false        | Must match the name in the database case-insensitively |
| company\_name   | string        | false        | For legal entities                                     |
| extra\_field    | dict          | false        | Additional address data. Must be a valid JSON object.  |

#### Parameters

| **Parameter**     | **Data Type** | **In** | **Descriptions**                                                  |
| ----------------- | ------------- | ------ | ----------------------------------------------------------------- |
| chanel\_id        | integer       | url    | The id of the shop channel                                        |
| \[api\_token]     | string        | header | The API key of the customer account                               |
| \[files]          | disct         | body   | The dictionary includes the file descriptor or the migration file |
| \[migration\_key] | string        | url    | The type of migration (user, address, order, order\_item etc.)    |

### `POST` Starting the Migration

**Path:** `/api/v1/remote/{channel_id}/migrations/start/{migration_key}`

To start the address migration, send a request to the /api/v1/remote/{channel\_id}/migrations/start/{migration\_key} endpoint and trigger the migration queue. In this case, set the migration key value to "address".

**Request**

```python
import requests
import json

url = "https://{customer_api_url}/api/v1/remote/{channel_id}/migrations/start/{migration_type}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
   'content-type': 'application/json',
   'Authorization': 'Token {}'.format(api_token)
}
files = {'file': open('/path/to/file/address.csv','rb')}
response = requests.post(url, headers=headers, files=files)
print(response.text)

```

**Response**

As a result of the request, a response with a 200 OK status code will be recieved, and it will contain the migration ID.

```js
{
  "migration_id":"4d6f7650799f484d875a89adf8d472b8"
}
```

### `GET` Checking Migration Progress

**Path:** `/api/v1/remote/{channel_id}/migrations/{migration_id}/progress/`

This method is used to check the progress of the migration by sending a request to the /api/v1/remote/{channel\_id}/migrations/{migration\_id}/progress/ endpoint, providing the parameters mentioned earlier.

**Request**

```python
import requests

url = "https://{customer_api_url}/api/v1/remote/{channel_id}/migrations/{migration_id}/progress/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
   'content-type': 'application/json',
   'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)
```

**Response**

As a result of the request, a response with a 200 OK status code will be recieved, and it will contain the following values in the response body:

```js
{
  "Processed_count": 1000,
  "Error_count": 0,
  "total_count": 1000
}
```


---

# 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://apidocs.akinon.com/commerce/address-migration.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.
