This service provides an API endpoint for identifying and reconciling customer identities across multiple purchases with different contact information.
The Identity Reconciliation API helps track a customer's identity across multiple purchases by linking different contact information (email addresses and phone numbers) to the same person.
Identifies and consolidates contact information based on the provided email and/or phone number.
{
"email": "string | null",
"phoneNumber": "string | null"
}
At least one of email
or phoneNumber
must be provided.
{
"contact": {
"primaryContactId": number,
"emails": string[],
"phoneNumbers": string[],
"secondaryContactIds": number[]
}
}
primaryContactId
: ID of the primary contactemails
: Array of all email addresses associated with the contact (primary contact's email first)phoneNumbers
: Array of all phone numbers associated with the contact (primary contact's phone number first)secondaryContactIds
: Array of IDs of all secondary contacts linked to the primary contact
- When a request is received with an email and/or phone number, the service searches for existing contacts with matching information.
- If no matching contacts are found, a new primary contact is created.
- If matching contacts are found, the service identifies the primary contact and consolidates all related contact information.
- If the request contains new information (email or phone number) that doesn't exist in the contact network, a new secondary contact is created and linked to the primary contact.
- If multiple primary contacts are found to be related, the oldest one is kept as primary and the others are converted to secondary.
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd identity-reconciliation
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Build the application
npm run build
-
Start the production server
npm start
The service uses a SQLite database with a single table:
Contact {
id Int
phoneNumber String?
email String?
linkedId Int? // the ID of another Contact linked to this one
linkPrecedence "secondary"|"primary" // "primary" if it's the first Contact in the link
createdAt DateTime
updatedAt DateTime
deletedAt DateTime?
}
ISC