Updating Program Memberships for Existing Users
Updating an existing program membership allows you to modify specific fields of a user's membership, such as the external_user_id.
Updating Program Memberships
To update an existing program membership, you can make a PATCH
request to the /v2/program-memberships/:program_membership_id
endpoint.
Request Parameters
external_user_id
(optional): The external user ID you want to update the program membership with.phone
(optional): The phone number to update the program membership with. Note: this should be formatted with area code first like +17891234567. If you send in an unformatted number we will format and set to US as long as there is an area code privided.first_name
(optional): The user's first name.last_name
(optional): The user's last name.birthday
(optional): The user's birthday ("YYYY-MM-DD").family_member_birthdays
(optional): An array of objects, each representing a family member. Each object can include the following fields:first_name
(required): The first name of the family member.last_name
(optional): The last name of the family member.birthday
(required): The birthday ("YYYY-MM-DD") of the family member.status
(required): The status of the family member ("active"/"inactive").
Example Request
curl -X PATCH 'https://loyalty.hang.xyz/partner-api/v2/program-memberships/membership_id_1' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"external_user_id": "12345",
"first_name": "joe",
"last_name": "Smith",
"birthday": "1989-02-25",
"phone": "+17891234567",
"email": "[email protected]",
"family_member_birthdays": [
{
"first_name": "Anna",
"birthday": "2000-02-02",
"status": "active"
},
{
"first_name": "Mason",
"last_name": "Smith",
"birthday": "2002-01-01",
"status": "active"
}
]
}'
Response
If successful, the API will return a 200 OK status along with the details of the updated program membership.
Example Response
{
"membership": {
"id": "membership_id_1",
"external_user_id": "user123",
"created_at": 1633887337,
"phone": "+17891234567",
"email": "[email protected]",
"social_media_credentials": {
"twitter_username": "updated_twitter",
"instagram_username": "updated_instagram",
"tiktok_username": "updated_tiktok"
},
"family_member_birthdays": [
{
"first_name": "Anna",
"last_name": "",
"birth_date": "2000-02-02",
"status": "active"
},
{
"first_name": "Mason",
"last_name": "Smith",
"birth_date": "2002-01-01",
"status": "active"
}
]
}
}
Implementing Program Membership Updates in Your Backend
After making the API call, Hang will update the selected program membership fields ( external_user_id
, phone
or a combination of them). Utilize the returned membership data to maintain accurate and up-to-date user information in your loyalty programs.
Error Handling
If the API encounters an error, a relevant error message will be returned to guide you through the troubleshooting process. For example, if there is an issue with the external_user_id
parameters, the API will return an error message describing the problem.
Last updated