Joining the loyalty program
Fetch Connection
Fetch the Connection for the current customer. You can filter by their user ID (fetched from the User endpoint) or filter by their email.
curl "https://api.perkville.com/v2/connections/?business=25&user_id=1234" -H "Authorization: Bearer accesstoken123abc"curl "https://api.perkville.com/v2/connections/?business=25&user__emails__email=example@example.com" -H "Authorization: Bearer accesstoken123abc"If the connection exists, you may proceed to the next step and check for necessary Agreements.
If the connection doesn't not exist, and you are using an admin-level token, see creating a connection.
Accept Agreements
Businesses can set Agreements that must be agreed to prior to joining the loyalty program. If these restrictions are in place, you'll need to perform a few additional steps before attempting to join on the user's behalf.
Fetch Agreements that are applicable to joining the loyalty program, and present them to the user.
curl "https://api.perkville.com/v2/agreements-view/?business=25&user_id=1234&apply_to_join_flow=true" -H "Authorization: Bearer accesstoken123abc"Once the user agrees to the terms, post the acceptance via the batch agreement endpoint.
Finally, join via the Connections endpoint.
Create a Connection (admin only)
If the connection does not exist, you can create an External Member record for this user. To do so, you'll need to POST to the External Member endpoint. You'll want to provide key details, like external_system_id, external_member_id, and the user_email.
external_system_idshould represent what system this is coming from, likeMY_MEMBERSHIP_SYS.external_member_idshould be a unique ID representing the user in the source system. This will be used moving forward to detect membership/email updates, so make sure it's unique to this individual.user_emailwill be the user's email
The POST response will include the user's Connection URI. However, before attempting to join on their behalf, you'll want to see if the business has applicable agreements.
Once they have accepted any necessary agreements, you can use the Connections endpoint to facilitate a customer joining the loyalty program. You would change the Connection status to Active.
Caveats
statusonly accepts ACTIVE or INACTIVE.Scope rules apply. With
USER_CUSTOMER_INFO, a user can only update their own Connection. WithADMIN_CUSTOMER_INFO, staff can update Connections for their business.
Validation errors (customer-safe copy)
Below are the join-related validation errors that may be returned when setting status=ACTIVE, plus recommended customer-safe messages.
pv_connection_membership_not_activeWhen: The business requires an active membership and the customer’s membership is not active. Customer-safe: “Your membership is not active. Please contact the business for help.”
pv_agreement_requiredWhen: The business requires agreement terms and the customer has not agreed. They will need to review accept the business' loyalty program terms before being able to join. You can update your application to accept these agreements in your app, or prompt them to join online. Customer-safe: “Please review and accept the required terms to join at {business.perkville_url}"
Last updated
Was this helpful?

