# Assigning/Updating/Removing contacts to location
When you want to manage a contact to a location, then the location services leverages the /locations/{id}/contacts
endpoints.
# Assigning contacts to location
# Building your request
Great, let's assign a contact to a location! All that you have to do now, is to tell us to process the request. To do so, we will call the POST /locations/{id}/contacts
endpoint.
This endpoint requires some additional core information, such as:
contactId
- the corresponding id of the contact that would be assigned to this location.isPrimary
- true/false - When true, this is the primary contact. Also, the previously assigned primary contact, if any, would become non-primary.
# Sample request:
In our example, we're going to be assigning a contact to the location
# Sample response:
{
"data":
{
"type": "location",
"attributes": {
"id": "1009843199016960000",
"name": "Benevity",
"address": {
"addressLine": "611 Meredith Rd",
"country": "Canada",
"district": "Alberta",
"locality": "Calgary",
"postalCode": "T2E 2W5",
"geoCoordinate": {
"latitude": 0,
"longitude": 0
}
},
"phoneNumber": "+14035555556",
"referenceId": "810e95f6-de45-478a-bc8c-3d94379fe002",
"tags": [],
"contacts": [
{
"id": "1009902601988210688",
"contactId": "1009902487177527296",
"locationId": "1009843199016960000",
"isPrimary": true,
"firstName": "FirstName",
"lastName": "LastName",
"emailAddress": "EmailAddress@email.com"
}
]
}
}
}
# Updating contacts to location
# Building your request
Let's update contact details in the location! All that you have to do now, is to tell us to process the request. To do so, we will call the PATCH /locations/{id}/contacts/{locationContactId}
endpoint.
This endpoint requires some additional core information, such as:
locationContactId
- the corresponding id of the LocationContact that is assigned to this location.isPrimary
- true/false - When true, this is the primary contact. Also, the previously assigned primary contact, if any, would become non-primary.
# Sample request:
In our example, we're going to be updaing a contact information in the location
# Sample response:
{
"data":
{
"type": "location",
"attributes": {
"id": "1009843199016960000",
"name": "Benevity",
"address": {
"addressLine": "611 Meredith Rd",
"country": "Canada",
"district": "Alberta",
"locality": "Calgary",
"postalCode": "T2E 2W5",
"geoCoordinate": {
"latitude": 0,
"longitude": 0
}
},
"phoneNumber": "+14035555556",
"referenceId": "810e95f6-de45-478a-bc8c-3d94379fe002",
"tags": [],
"contacts": [
{
"id": "1009902487177527296",
"contactId": "1009902487177527223",
"locationId": "1009843199016960000",
"isPrimary": false,
"firstName": "FirstName",
"lastName": "LastName",
"emailAddress": "EmailAddress@email.com"
}
]
}
}
}
# Removing contact to location
# Building your request
Let's remove contact details in the location! To do so, we will call the DELETE /locations/{id}/contacts/{locationContactId}
endpoint.
This endpoint requires some additional core information, such as:
locationContactId
- the corresponding id of the LocationContact that is assigned to this location.
# Sample request:
In our example, we're going to be updaing a contact information in the location
# Response Details:
On successful deletion, 204 code is returned with no content.
# 🚀 ☀️ ⭐️ Congratulations! ⭐️ ☀️ 🚀
You have now assigned a contact to the location, to help your users drive further goodness in the world!