User Addresses management
Through the API
For more information on the API usage for Addresses, see Management API: Addresses. |
View addresses
The two endpoints below allow you to retrieve the information present in the addresses
object or a particular address
item, from the User data model, no matter if the account is lite or managed.
Create addresses
You can also create addresses using the endpoints below.
-
For Managed profiles: POST /api/v2/managed-users/{userId}/addresses
-
For Lite profiles: POST /api/v2/lite-users/{userId}/addresses
Specifics for id
and default
fields
The id
field is set automatically so you don’t have to manage this aspect.
You can reuse IDs to update a user’s address
items.
The default
field is set automatically to true
for an address if:
-
There is only one item in the
addresses
object. -
The field is specified in the payload with the value
true
.
There can be only one default address at a time.
So if you add or update an address with the field default: true , the other addresses are set to default: false .
|
Update addresses
You can update addresses by using an equivalent method as for creating them, but providing an addressId
in the endpoint call.
-
For Managed profiles: POST /api/v2/managed-users/{userId}/addresses/{addressId}
-
For Lite profiles: POST /api/v2/lite-users/{userId}/addresses/{addressId}
Delete addresses
For addresses deletion, you can delete all addresses or a specific address.
-
For Managed profiles (all): DELETE /api/v2/managed-users/{userId}/addresses
-
For Managed profiles: DELETE /api/v2/managed-users/{userId}/addresses/{addressId}
-
For Lite profiles (all): DELETE /api/v2/lite-users/{userId}/addresses
Through imports
Create addresses via import
The addresses.x.id
column is not mandatory in the CSV file as the id
will be generated during processing anyway.
You can still specify it in the file, but in the process of creation (i.e., in the absence of an existing address with this id
), the value is ignored.
We generate the id
field for addresses on the basis of a numerical sequence starting at 0
.
[
{
"email": "bx@import.com",
"given_name": "B",
"family_name": "X",
"gender": "male",
"birthdate": "1970-01-01",
"default": false,
"locality": "Paris",
"postal_code": 75001,
"addresses.0.id": 0, (1)
"addresses.0.default": false,
"addresses.0.street_address": "12 rue de la Boétie",
"addresses.0.postal_code": 75001,
"addresses.0.locality": "Paris",
"addresses.0.country": "France",
"addresses.1.default": true, (1)
"addresses.1.street_address": "18 rue du Général Leclerc",
"addresses.1.postal_code": 75004,
"addresses.1.locality": "Paris",
"addresses.1.country": "France"
}
]
1 | Here, addresses.0 has a specified id while addresses.1 does not. |
Since we are in a creation process, assuming there is no address registered for the user, the provided id
is ignored and the application generates the ids (0
and 1
) itself for both addresses.
email,given_name,family_name,gender,birthdate,default,locality,postal_code,addresses.0.id,addresses.0.default,addresses.0.street_address,addresses.0.postal_code,addresses.0.locality,addresses.0.country,addresses.1.default,addresses.1.street_address,addresses.1.postal_code,addresses.1.locality,addresses.1.country
bx@import.com,B,X,male,1970-01-01,false,Paris,75001,0,false,12 rue de la Boétie,75001,Paris,France,true,18 rue du Général Leclerc,75004,Paris,France
Here, addresses.0
has a specified id
while addresses.1
does not.
Since we are in a creation process, assuming there is no address registered for the user, the provided id
is ignored and the application generates the ids (0 and 1) itself for both addresses
Update addresses via import
When updating addresses, yo must specify the addresses.x.id
field to make modifications to an existing address.
[
{
"email": "bx@import.com",
"given_name": "B",
"family_name": "X",
"gender": "male",
"birthdate": "1970-01-01",
"default": false,
"locality": "Paris",
"postal_code": 75001,
"addresses.0.id": 0, (1)
"addresses.0.default": false,
"addresses.0.street_address": "12 rue de la Boétie",
"addresses.0.postal_code": 75001,
"addresses.0.locality": "Paris",
"addresses.0.country": "France",
"addresses.1.default": true, (2)
"addresses.1.street_address": "18 rue du Général Leclerc",
"addresses.1.postal_code": 75004,
"addresses.1.locality": "Paris",
"addresses.1.country": "France"
}
]
1 | addresses.0 has a specified id while `addresses.1 does not. |
2 | addresses.0 is only modified on the values specified in the file whereas addresses.1 is created with the values specified in the file. |
email,given_name,family_name,gender,birthdate,default,locality,postal_code,addresses.0.id,addresses.0.default,addresses.0.street_address,addresses.0.postal_code,addresses.0.locality,addresses.0.country,addresses.1.default,addresses.1.street_address,addresses.1.postal_code,addresses.1.locality,addresses.1.country
bx@import.com,B,X,male,1970-01-01,false,Paris,75001,0,false,12 rue de la Boétie,75001,Paris,France,true,18 rue du Général Leclerc,75004,Paris,France
Here, addresses.0
has a specified id
while addresses.1
does not.
In this update process, we assume addresses.0
already existed and was the only address registered while addresses.1
did not.
addresses.0
is only modified on the values specified in the file whereas addresses.1
is created with the values specified in the file.
Delete addresses via import
If you want to delete an existing address, you need to pass the to_delete
boolean as part of the address object in your import file.
{
"email": "test@example.com",
"addresses": [
{
"id": 1,
"to_delete": true (1)
}
]
}
1 | Pass to_delete as true along with the desired address id to delete the address. |
email;addresses.0.id;addresses.0.to_delete (1)
test@example.com;1;true (1)
1 | Pass to_delete as true along with the desired address id to delete the address. |