Sharing a record across sites
One customer, several sites, one record. How sharing works, how fast edits travel, and what removing a site does.
Dana Whitfield is a regular at Portland and Salem. If each site keeps its own Dana, her phone number drifts: one site has the old one. A shared record fixes that. There is one Dana, and every site she belongs to sees the same record with the same id.
Sharing is opt-in. A customer created without location_ids, or with only the current
site, stays local to that site and costs nothing extra.
Sharing on create
Name every site the customer belongs to:
curl -X POST https://api.hyphabase.com/api/modules/clients \
-u sk_live_xxx: -H "X-Location-Id: $PORTLAND_ID" \
-H "Content-Type: application/json" \
-d '{
"first_name": "Dana",
"last_name": "Whitfield",
"email": "dana@example.com",
"phone": "+15035550143",
"location_ids": ["'$PORTLAND_ID'", "'$SALEM_ID'"]
}'Every id has to be a site your credential can reach, or the whole request is a 422.
The response says what you got back:
sourceissyncedfor a shared record andlocalfor one that belongs to a single site.location_idslists every site the record belongs to.idis the same at every site. An id you saved at Portland works at Salem.
Editing
Edit it at any site it belongs to. The change is written to the shared record and then copied to the other sites.
curl -X PATCH https://api.hyphabase.com/api/modules/clients/$CUSTOMER_ID \
-u sk_live_xxx: -H "X-Location-Id: $SALEM_ID" \
-H "Content-Type: application/json" \
-d '{"phone": "+15035550199"}'Two things to plan for:
- Edits travel in the background. The response confirms the shared record changed; the other sites catch up a moment later, not inside the same request. Don't read the same customer back from another site in the next instant and expect the new value.
- Last write wins. If two sites edit the same field at nearly the same time, the later write is the one that stays.
Adding and removing sites
Send the full list of sites you want in location_ids:
curl -X PATCH https://api.hyphabase.com/api/modules/clients/$CUSTOMER_ID \
-u sk_live_xxx: -H "X-Location-Id: $PORTLAND_ID" \
-H "Content-Type: application/json" \
-d '{"location_ids": ["'$PORTLAND_ID'"]}'A site that is no longer listed loses its copy. The record stays at the sites that are still listed. Removing the site you are calling from returns a confirmation message instead of the record, because there is nothing left there to return.
An existing local customer can be promoted to shared the same way, by listing more than the current site.
DELETE works from the site you call it on: it removes that site's copy only. The other
sites keep the customer, and the response says so.
What stays per site
Sharing covers the customer's own details: name, email and phone. Notes, addresses, statuses and bookings stay with the site where they were made, so Portland's staff notes don't show up on Salem's screen.
Which modules can share
Customers share today. Services have a shared-catalogue mechanism that is set up in the dashboard, not through the API. Other modules are still per site.