Skip to main content

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 NamesData TypeRequiredDescriptions
userstringtrueCustomer Code of the user.
emailstringtrueThe email of the user.
phone_numberstringfalseThe phone number of the address
first_namestringtrueFirst name of the recipient (max 255 characters)
last_namestringtrueLast name of the recipient (max 255 characters)
titlestringfalseThe address title (max 128 characters)
linestringtrueThe address line (max 255 characters)
tax_officestringfalseFor legal entities
tax_nostingfalseFor legal entities
countrystingtrueMust match the name in the database case-insensitively
citystingtrueMust match the name in the database case-insensitively
townshipstringtrueMust match the name in the database case-insensitively
districtstringfalseMust match the name in the database case-insensitively
company_namestringfalseFor legal entities

Parameters

ParameterData TypeInDescriptions
chanel_idintegerurlThe id of the shop channel
[api_token]stringheaderThe API key of the customer account
[files]disctbodyThe dictionary includes the file descriptor or the migration file
[migration_key]stringurlThe 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

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.

{
"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

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:

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