Overview
The upsert endpoint intelligently creates a new entity or updates an existing one based on configurable duplicate detection strategies. It automatically handles conflicts and prevents duplicate records using exact matching, fuzzy matching, or AI-powered similarity detection.Endpoint
Authentication
Requires a valid API key in the Authorization header:Request Body
The entity data (same structure as Create Entity endpoint)
Configuration options for upsert behavior
How to handle conflicts when an existing entity is found:
source_wins- New data overwrites existing datatarget_wins- Keep existing data, ignore new datamanual_review- Flag for manual review without updatingsmart_merge(default) - Intelligently merge both datasets
Strategy for detecting duplicate entities:
exact_match- Match by externalId and taxId (case-insensitive)fuzzy_match- Similarity matching on name and taxId (80% threshold)ai_similarity- AI-powered semantic similarity detectionhybrid(recommended) - Exact match with fuzzy fallback
Whether to automatically create relationships between entities
Response
Indicates if the operation succeeded
The action performed:
created or updatedThe final entity state after upsert
The entity state before update (null if newly created)
Confidence score (0-1) for the duplicate detection match
Explanation of why the entity was created/updated
Array of field-level conflicts detected during merge (if any)
Deduplication Strategies
Exact Match
Matches entities based on exact field comparison (case-insensitive):- Fields:
externalId,taxId - Use case: When you have reliable unique identifiers
- Speed: Fastest
- Accuracy: 100% for identical values
Fuzzy Match
Uses Levenshtein distance for similarity matching:- Fields:
name,taxId - Threshold: 80% similarity
- Use case: When dealing with typos or variations
- Speed: Moderate
- Accuracy: High for similar strings
AI Similarity
AI-powered semantic similarity detection:- Method: Vector embeddings and cosine similarity
- Use case: Complex multi-field matching
- Speed: Slower
- Accuracy: Highest for semantically similar entities
Hybrid (Recommended)
Combines exact and fuzzy matching:- Primary: Exact match on identifiers
- Fallback: Fuzzy match on names
- Confidence threshold: 80%
- Use case: Best balance of speed and accuracy
Conflict Resolution Strategies
smart_merge (Default)
Intelligently merges data from both sources:- Priority: Newer data for simple fields
- Arrays: Merges and deduplicates
- Objects: Deep merge with conflict detection
- Empty values: Preserves non-empty existing values
source_wins
New data completely replaces existing:- Use case: When incoming data is authoritative
- Behavior: All fields from source
- Risk: May lose valuable existing data
target_wins
Keeps existing data, ignores incoming:- Use case: When existing data is authoritative
- Behavior: No updates performed
- Risk: May miss important updates
manual_review
Flags conflicts without auto-resolution:- Use case: High-stakes data requiring human review
- Behavior: Creates review task
- Result: Entity marked for manual resolution
Examples
Simple Upsert (Default Behavior)
Upsert with Exact Match Strategy
Upsert with Fuzzy Matching
Hybrid Strategy (Recommended)
Response Examples
Created New Entity
Updated Existing Entity
Use Cases
Data Import from External System
Progressive Data Enrichment
Best Practices
-
Choose the Right Strategy:
exact_matchfor clean, structured data with reliable IDsfuzzy_matchfor user-entered data with potential typoshybridfor most production scenarios
-
Handle Conflicts Gracefully:
- Use
smart_mergefor automatic resolution - Use
manual_reviewfor critical financial data - Check
conflictsarray in response for important changes
- Use
-
Monitor Confidence Scores:
- Scores below 0.7 may indicate weak matches
- Log low-confidence updates for review
- Consider manual review threshold
-
Relationship Management:
- Set
createRelationships: trueto auto-link related entities - Useful for transaction-customer, company-person relationships
- Set
Error Responses
400 Bad Request
400 Missing Required Fields
500 Internal Server Error
Next Steps
- Batch Upsert - Process multiple entities at once
- List Entities - Query upserted entities
- Update Entity - Make targeted updates
- Get Entity - Retrieve full entity details