The Customer Profile API provides information about the custom campaigns set up for any of your experiences. This means it helps collect more information about your guests from an external form, outside AnyRoad.
To make requests for our API, you will need an API key. Your AnyRoad user id and password are your normal AnyRoad account login credentials. Once you receive your API key, you will be able to make requests to all endpoints. Please keep your API key secure. If you believe your key has been compromised, please contact us for a new one.
All responses adhere to the JSON:API formatting guidelines found here: JSON API — A specification for building APIs in JSON.
Requesting an API Key
Please reach out to your AnyRoad Account Manager to activate your API key. Once activated, send the below request to receive your API key. You will need the AnyRoad account registered email and password associated with the owner of the account.
Request:
curl https://app.anyroad.com/external/api/v1/users/key -u "[email protected]:SuperSecretPa$word"
Response:
Status: 200
{
"data": {
"type": "users",
"id": "123",
"attributes": {
"key": "example-key-1234"
}
}
}
API Key Verification
To verify that your API key is active, send the following request, where is your API key:
Request:
curl -H 'X-API-KEY: ' https://app.anyroad.com/external/api/v1/users/profile
Response:
Status: 200
{ "data": { "type": "users", "id": "123", "attributes": { "first_name": "Jane", "last_name": "Doe", "email": "[email protected]" } } }
Key Terminology
Customer Profile
The Customer Profile API allows partners to append additional data to a customer’s AnyRoad profile. Its flexible structure can absorb just about any data type - customer preferences, demographics, psychographics, segmentation - that can then be viewed on a customer profile within AnyRoad, and used for analytics.
Campaigns
Campaigns define the data structure for a Customer Profile update. Each Customer Profile update is connected to a single campaign. A campaign has the following important information:
Name: a name to help easily identify the campaign
Data model: this is used to validate the data_set that you will be passing to the UPDATE endpoint (more about this below in the JSON Structure section)
Display label: the partner or customer facing label associated with the data
Display key: this is the value key that will be needed to be passed in the data_set, the value of which will be displayed under the display label heading
Approved IPs: this is a list of IP addresses that are authorized to use this API
JSON Structure
When sending a JSON object to update the data set, the structure of the JSON must match the predefined structure contained in the data model attribute of the campaign. AnyRoad will help to create this structure when the campaign is created. For this API, we conform to JSON Schema Draft 4.
The JSON schema description is quite extensive (see: Understanding JSON Schema — Understanding JSON Schema 7.0 documentation) but the following small example may help to get started:
{ "type": "object", <-><-><-><-><-><-><-></-></-></-></-></-></-></->
Here are few valid & invalid JSON objects following the above schema:
{ "flavor_profile": "red" } VALID { "flavor_profile": 6 } INVALID - wrong type { "flavour_profile": "red" } INVALID - mismatched property name { "flavor_profile": "red", "hacky": "hack" } INVALID - extra property
Endpoints
Customer Profile
The customer profile endpoint can be used to update and retrieve customer information with AnyRoad.
GET Request
Query Params:
customer_profile_id (string) - uuid that uniquely identifies the customer profile.
Example Request:
curl -H 'X-API-KEY: ' https://app.anyroad.com/external/api/v1/customer_profile/56c934fa-03c2-46f4-b7f9-6d44bafdd5a2
GET Response
Attributes:
id (string): the unique id (uuid) of a customer profile
data_set (JSON): a JSON object that contains the customer profile information. The structure of this JSON is pre-defined with AnyRoad as a campaign.
captured_at (datetime): the date a customer_profile was captured in RFC 3339 date representation. This date will be stored in UTC time. Example: if you pass “2021-03-01 00:00:00-08” as a parameter it will be stored as "2021-03-01T08:00:00Z".
referrer_medium (string): string that represents where the API call originated from or where the data was collected from the customer.
booking (collection): The properties of the booking.
guest_email (string): A Base64 encoded string representing the customer’s email address.
guest_first_name (string): A Base64 encoded string representing the customer’s first name.
guest_last_name (string): A Base64 encoded string representing the customer’s last name.
booking_id (integer): booking id that matches a customer profile.
number_guests_booked (integer): An integer representing the number of guests that were booked for this booking.
tickets (string): The tickets associated with a booking
Example Responses:
Status: 200 - OK
{ "data": { "attributes": { "booking": { "guest_email": "Ym9iQGxhd2Jsb2cuY29t", "guest_first_name": "Qm9i", "guest_last_name": "TG9ibGF3", "id": 1234, "number_guests_booked": 2, "tickets": { "adult": 1, "child": 1 } }, "captured_at": null, "data_set": null, "experience": { "date": "2021-03-31", "name": "Monster Mash", "time": "15:00" }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "referrer_medium": null }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "type": "customer_profile" } }
Status: 401 - unauthorized
{ "error": "Invalid API key." }
Status: 403 - forbidden
{ "error": "Forbidden." }
PATCH Request
Query Params:
customer_profile_id (string) - required: uuid that uniquely identifies the customer profile
captured_at (timestamp) - optional: timestamp in RFC 3339 format, stored in UTC time.
referrer_medium (string) - optional: string that represents where the API call originated from or where the data was collected from the customer.
data_set (JSON) - optional: valid JSON that represents any unique customer data desired
Example Request:
curl -X PATCH -H 'X-API-KEY: ' -H 'Content-Type: application/json' https://app.anyroad.com/external/api/v1/customer_profile/56c934fa-03c2-46f4-b7f9-6d44 bafdd5a2 -d '{"data_set":{"custom_attribute":"red"},"referrer_medium":"email","captured_at":"2021-03-01 00:00:00-08"}'
PATCH Response
Example Responses:
Status: 200 - OK
{ "data": { "attributes": { "booking": { "guest_email": "Ym9iQGxhd2Jsb2cuY29t", "guest_first_name": "Qm9i", "guest_last_name": "TG9ibGF3", "id": 1234, "number_guests_booked": 2, "tickets": { "adult": 1, "child": 1 } }, "captured_at": "2021-03-01T08:00:00Z", "data_set": { "custom_attribute":"red" }, "experience": { "date": "2021-03-31", "name": "Monster Mash", "time": "15:00" }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "referrer_medium": "email" }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "type": "customer_profile" } }
Status: 401 - unauthorized
{ "error": "Invalid API key." }
Status: 403 - forbidden
{ "error": "Forbidden." }
Customer Profile Search
POST Request
Query Params:
booking_id (integer) - optional: booking id that matches a customer profile.
last_name (string) - optional: last name of a customer that matches a customer profile. Before searching, we will remove accents, cases, apostrophes, hyphens, and spaces from names. Ex: D'Angelo - dangelo, Van Morrison - vanmorrison, Beyoncé - beyonce, Newton-John - newtonjohn
experience_date (timestamp) - optional: The date of the guest’s experience. Timestamp in YYYY-MM-DD format.
Example Request:
curl -X POST -H 'X-API-KEY: <API KEY>' -H 'Content-Type: application/json' https://app.anyroad.com/external/api/v1/customer_profile/search -d '{"booking_id":1234,"last_name":"Smith","experience_date":"2021-03-01"}'
POST Response
Example Responses:
Responses will be an array of results that match the search query.
Status: 200 - OK
{ "data": [ { "attributes": { "booking": { "guest_email": "Ym9iQGxhd2Jsb2cuY29t", "guest_first_name": "Qm9i", "guest_last_name": "TG9ibGF3", "id": 1234, "number_guests_booked": 2, "tickets": { "adult": 1, "child": 1 } }, "captured_at": "2021-03-01T08:00:00Z", "data_set": { "custom_attribute":"red" }, "experience": { "date": "2021-03-31", "name": "Monster Mash", "time": "15:00" }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "referrer_medium": "email" }, "id": "56c934fa-03c2-46f4-b7f9-6d44bafdd5a2", "type": "customer_profile" } ] }
Status: 204 - no content
{[ ]}
Status: 401 - unauthorized
{ "error": "Invalid API key." }
Status: 403 - forbidden
{ "error": "Forbidden." }
If you have any additional questions, you can contact our Customer Experience team via chat or at [email protected].