Working with user profiles
The Spoonity platform provides a suite of APIs that can be used in customer-facing scenarios to help them manage their profile. These include tools for updating their personal information, retrieving data and statistics, and even deleting their account.
The profile workflow
The typical profile workflow follows a consistent pattern:
- authenticating the customer
- viewing their information
- updating their information
- deleting their account
Authentication and registration is covered in greater detail as part of the Registering an account workflow.
Viewing and updating personal information
A user's profile in Spoonity contains important personal identifiable information (PII), as well as system information like their internal ID and status.
This information can be retrieved and/or updated via our /user/profile APIs.
These requests are authenticated via session token, and in most cases, the Spoonity platform is designed to give users direct control over their data and account, with a few exceptions.
Retrieve profile
This API will return the most important user information to the client. It takes a session token scoped to a single user.
Retrieve profile
curl -G https://api.spoonity.com/user/profile?session_key={session_key}
Update profile
Data attached to a user's profile is organized into two sections: core properties and "metadata". Core properties are available at the root level of the user model, while "metadata" lives within the dedicated metadata key.
Core properties can be updated and edited directly using the field name and supplying an appropriate value. Updating metadata requires knowing the user_metadata_id, which can be found as part of the GET /user/profile request.
You can update as many or as few properties as you want in any single update request.
Update profile
curl -G https://api.spoonity.com/user/profile?session_key={session_key} \
-d '{
"contact_consent": 3
}'
Viewing balances and history
Users will accumulate and spend currencies as they interact with the loyalty program. The Spoonity platform maintains a history of each of these interactions, as well as dedicated APIs for retrieving balance and eligibility information for the user.
Get available rewards
A user's balance can be retrieved using the GET /user/reward/list request. This request returns information about the user's individual balances in each currency the merchant supports, as well as the eligibility, availability, and progress towards individual rewards.
The results of this API are scoped towards the user making the request. If you're looking for a more generalized API that gives all reward information, then you should use the spending rules API.
Get available rewards
curl -G https://api.spoonity.com/user/reward/list?session_key={session_key}
Get transaction history
Every order that a user completes is logged and linked back to their account. This history can be retrieved using the GET transaction history API.
Get transaction history
curl -G https://api.spoonity.com/vendor/{vendor_id}/customers/{customer_id}/history?session_key={session_key}
Deleting an account
Deleting a user account requires two steps, and can only be completed by the user themselves.
The first step is triggered from an authenticated account, and notifies the platform of a user's intention to delete their account. This results in an email being sent to their inbox with the final instructions to carry out the process.
The email will link to a separate process, using a secure one-time-use token, to finalize the deletion process.
Start the deletion process
The first step involves calling the submit delete request. This will trigger the email that will include the instructions for how the user can delete their account.
Start the deletion process
curl -G https://api.spoonity.com/vendor/{vendor_id}/customers/{user_id}/submit?session_key={session_key}
Finalize account deletion
After receiving the email, the user will be directed to page in the app or a web site that will use the secure token from the email to actually delete the account.
Finalize account deletion
curl -G https://api.spoonity.com/vendor/{vendor_id}/customers?session_key={session_key} \
--request DELETE \
-d '{
"code": "aca0a733c0ba5a8afde59ce6d6f4dbf3"
}'