Locations API
-
Get locations
Get a list of all locations associated with your Business Unit ID.
HTTP method: GET
Authentication: Business user OAuth Token
URL: https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations
Parameters
-
page, Optional integer
The page to retrieve. If the page number requested is higher than the available number of pages an empty array will be returned.
Example: ?page={page}
-
businessUnitId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations
curl -X GET "https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations" \-H "Authorization: Bearer YOUR-ACCESS-TOKEN"const accessToken = "YOUR-ACCESS-TOKEN";const response = await fetch("https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations",{method: "GET",headers: {Authorization: `Bearer ${accessToken}`,},});if (!response.ok) {throw new Error(`HTTP ${response.status}: ${await response.text()}`);}const data = await response.json();Response
{"locations": [{"id": null,"name": null,"urlFormattedName": null,"customerLocationId": null,"businessUnitId": null,"phone": null,"website": null,"description": {"header": null,"text": null},"locationDetails": {"countryCode": null,"streetAddress": null,"streetAddress2": null,"locality": null,"postalCode": null,"administrativeArea": null,"formattedAddress": null,"latitude": 0,"longitude": 0}}],"links": [{"method": null,"href": null,"rel": null}]} -
-
Get location using external ID
Get locations using the IDs you created during location set up.
HTTP method: GET
Authentication: Business user OAuth Token
URL: https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
Parameters
-
businessUnitId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
-
customerLocationId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
curl -X GET "https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}" \-H "Authorization: Bearer YOUR-ACCESS-TOKEN"const accessToken = "YOUR-ACCESS-TOKEN";const response = await fetch("https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}",{method: "GET",headers: {Authorization: `Bearer ${accessToken}`,},});if (!response.ok) {throw new Error(`HTTP ${response.status}: ${await response.text()}`);}const data = await response.json();Response
{"id": null,"name": null,"urlFormattedName": null,"customerLocationId": null,"businessUnitId": null,"phone": null,"website": null,"description": {"header": null,"text": null},"locationDetails": {"countryCode": null,"streetAddress": null,"streetAddress2": null,"locality": null,"postalCode": null,"administrativeArea": null,"formattedAddress": null,"latitude": 0,"longitude": 0}} -
-
Edit a location (partial)
Specify and edit fields. Any field you don't edit will remain the same. Any fields you assign as 'null' will become blank.
HTTP method: PATCH
Authentication: Business user OAuth Token
URL: https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
Parameters
-
businessUnitId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
-
customerLocationId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
curl -X PATCH "https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}" \-H "Content-Type: application/json" \-d '{"name": "example","phone": "example","website": "example","locationDetails": {"countryCode": "example","streetAddress": "example","streetAddress2": "example","locality": "example","postalCode": "example","administrativeArea": "example"},"description": {"header": "example","text": "example"}}' \-H "Authorization: Bearer YOUR-ACCESS-TOKEN"const accessToken = "YOUR-ACCESS-TOKEN";const response = await fetch("https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}",{method: "PATCH",headers: {"Content-Type": "application/json",Authorization: `Bearer ${accessToken}`,},body: JSON.stringify({"name": "example","phone": "example","website": "example","locationDetails": {"countryCode": "example","streetAddress": "example","streetAddress2": "example","locality": "example","postalCode": "example","administrativeArea": "example"},"description": {"header": "example","text": "example"}}),});if (!response.ok) {throw new Error(`HTTP ${response.status}: ${await response.text()}`);}const data = await response.json();Request Body
{"name": null,"phone": null,"website": null,"locationDetails": {"countryCode": null,"streetAddress": null,"streetAddress2": null,"locality": null,"postalCode": null,"administrativeArea": null},"description": {"header": null,"text": null}}Response
{"id": null,"name": null,"urlFormattedName": null,"customerLocationId": null,"businessUnitId": null,"phone": null,"website": null,"description": {"header": null,"text": null},"locationDetails": {"countryCode": null,"streetAddress": null,"streetAddress2": null,"locality": null,"postalCode": null,"administrativeArea": null,"formattedAddress": null,"latitude": 0,"longitude": 0}} -
-
Delete a location
Delete a location. Any reviews assigned to a deleted location become unmapped but remain available under your main business profile. Deleting a location does not delete associated reviews.
HTTP method: DELETE
Authentication: Business user OAuth Token
URL: https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
Parameters
-
businessUnitId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
-
customerLocationId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}
curl -X DELETE "https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}" \-H "Authorization: Bearer YOUR-ACCESS-TOKEN"const accessToken = "YOUR-ACCESS-TOKEN";const response = await fetch("https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id/{customerLocationId}",{method: "DELETE",headers: {Authorization: `Bearer ${accessToken}`,},});if (!response.ok) {throw new Error(`HTTP ${response.status}: ${await response.text()}`);}const data = await response.json(); -
-
Create a location
Create a location and assign an external ID. You must match the format of the CSV upload in Trustpilot for Business.
HTTP method: POST
Authentication: Business user OAuth Token
URL: https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id
Parameters
-
businessUnitId, Required string
Example: .../v1/private/business-units/{businessUnitId}/locations/external-id
curl -X POST "https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id" \-H "Content-Type: application/json" \-d '{"name": "example","customerLocationId": "example","phone": "example","website": "example","locationDetails": {"countryCode": "example","streetAddress": "example","streetAddress2": "example","locality": "example","postalCode": "example","administrativeArea": "example"},"description": {"header": "example","text": "example"}}' \-H "Authorization: Bearer YOUR-ACCESS-TOKEN"const accessToken = "YOUR-ACCESS-TOKEN";const response = await fetch("https://api.trustpilot.com/v1/private/business-units/{businessUnitId}/locations/external-id",{method: "POST",headers: {"Content-Type": "application/json",Authorization: `Bearer ${accessToken}`,},body: JSON.stringify({"name": "example","customerLocationId": "example","phone": "example","website": "example","locationDetails": {"countryCode": "example","streetAddress": "example","streetAddress2": "example","locality": "example","postalCode": "example","administrativeArea": "example"},"description": {"header": "example","text": "example"}}),});if (!response.ok) {throw new Error(`HTTP ${response.status}: ${await response.text()}`);}const data = await response.json();Request Body
{"name": null,"customerLocationId": null,"phone": null,"website": null,"locationDetails": {"countryCode": null,"streetAddress": null,"streetAddress2": null,"locality": null,"postalCode": null,"administrativeArea": null},"description": {"header": null,"text": null}} -