User Addresses APIs
A user can store 2 addresses at maximum and the user will have the same addresses options in the checkout process to select from one of the saved addresses to continue.
Both APIs require the session-token cookie header to sent along.
There are 2 APIs for handling the user addresses information:
- Get Addresses: The user's addresses can be fetched via this API.
- Update Addresses: User addresses can be updated using this API.
1. Get User Addresses
Endpoint
GET /user/addresses/get
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"success": true,
"addresses": {
"_id": "65df69ecd5d42b2477085cec",
"user_id": "65ddb7496a09ca290bec88b2",
"createdAt": "2024-02-28T17:14:20.859Z",
"updatedAt": "2024-05-21T18:23:59.425Z",
"address1": {
"address_title": "Home",
"firstname": "John",
"lastname": "Doe",
"address": "street 123, Dubai, UAE",
"apt_suite": "",
"city": "Dubai",
"country": "ae", // SO 3166-1 alpha-2 country code. It will be alwasy UAE since the platform is in UAE
"phone_prefix": "+971",
"phone_number": "31643454835",
"state": "ae-sh" // The state code of UAE
},
"address2": null // Means that user has saved only one address
"__v": 0,
}
}2. Update Addresses
Endpoint
PUT /user/addresses/update
Payload
For instance we are updating the second address as Office address. It will be saved along with the previous Home address as well. In short only that data can be sent which needs to be updated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"address1": {
"address_title": "Office",
"firstname": "John",
"lastname": "Doe",
"address": "street 456, Abu Dhabi, UAE",
"apt_suite": "Near building ABC",
"city": "Abu Dhabi",
"country": "ae", // SO 3166-1 alpha-2 country code. It will be alwasy UAE since the platform is in UAE
"phone_prefix": "+971",
"phone_number": "31643454835",
"state": "ae-az" // The state code of UAE
}
}Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
"success": true,
"msg": "Your Address updated successfully",
"addresses": {
"_id": "65df69ecd5d42b2477085cec",
"user_id": "65ddb7496a09ca290bec88b2",
"createdAt": "2024-02-28T17:14:20.859Z",
"updatedAt": "2024-05-21T19:01:42.425Z",
"address1": {
"address_title": "Home",
"firstname": "John",
"lastname": "Doe",
"address": "street 123, Dubai, UAE",
"apt_suite": "",
"city": "Dubai",
"country": "ae",
"phone_prefix": "+971",
"phone_number": "31643454835",
"state": "ae-sh"
},
"address2": { // The updated adddress object
"address_title": "Office",
"firstname": "John",
"lastname": "Doe",
"address": "street 456, Abu Dhabi, UAE",
"apt_suite": "Near building ABC",
"city": "Abu Dhabi",
"country": "ae",
"phone_prefix": "+971",
"phone_number": "31643454835",
"state": "ae-az"
}
"__v": 0,
}
}