Bind a browser to a person
const url = 'https://stitch-collector-dev.magic-blocks.workers.dev/v1/identify';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"anon_id":"3f1a8c2e-9b4d-4a71-8e2f-0c5d6a7b8e91","traits":{"email":"jane.doe@example.com","phone":"(415) 555-0132"},"external_ids":{"relcu_contact_id":"88213"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://stitch-collector-dev.magic-blocks.workers.dev/v1/identify \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "anon_id": "3f1a8c2e-9b4d-4a71-8e2f-0c5d6a7b8e91", "traits": { "email": "jane.doe@example.com", "phone": "(415) 555-0132" }, "external_ids": { "relcu_contact_id": "88213" } }'The bind-at-birth call. Post the page’s anon_id together with the contact id the moment a contact is created, and the entire prior browsing history attaches to that person deterministically. Also sent on every authenticated sign-in: it is idempotent and repairs drift. Who sends it is the owner’s business — a form handler, a CRM, a portal, an agent, or a middleware in front of them; Stitch sees a key and a payload. Email and phone are hashed inside the Worker and never stored in plaintext.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”At least one of traits.email, traits.phone or an external_ids entry: an anon_id on its own identifies nobody and is a 400. Posting an anon_id together with a contact id binds the entire prior browsing history to the person in one call.
object
Normalised and SHA-256’d inside the Worker before anything touches storage. The plaintext exists only for the request.
object
Any formatting; normalised to E.164 before hashing.
Your systems’ ids for the person. Unrecognised keys are ignored.
object
The contact id in whatever is the system of record for contacts (today, likely the CRM): the spine id. octopus_id and los_contact_id are accepted as the same thing.
Responses
Section titled “ Responses ”The person this browser now belongs to.
object
Whether this call created the person.
How many previously separate persons this call joined.
Example
{ "person_id": "01fa113c-ae40-4671-851f-29707ed6c2da", "created": true, "merges": 0}Malformed JSON or a payload missing what the endpoint needs. The body says which.
object
What was wrong, in a sentence. A 401 carries unauthorized and nothing more.
Example generated
{ "error": "example"}No key, or a key the collector does not know. Nothing was written.
object
What was wrong, in a sentence. A 401 carries unauthorized and nothing more.
Example
{ "error": "unauthorized"}Only the method shown is served.