Also in docs/dev/quickstarts.md
Map a source to a canonical model
Line up a source’s fields with a shared model (Contact, Company, …) so data from many sources lines up. About 4 minutes.
You need:
- An API key in
PYROSYNC_API_KEYand the deployment URL inPYROSYNC_URL(for examplehttps://app.example.com). - A canonical model id in
MODEL_ID(from the catalog in the dashboard) and a source id inSOURCE_ID(for example from the CSV quickstart).
1. Ask for a proposal
POST /api/mappings/propose
curl -sS -X POST "$PYROSYNC_URL/api/mappings/propose" \
-H "X-API-Key: $PYROSYNC_API_KEY" \
-H "Content-Type: application/json" \
-d "$(cat <<JSON
{
"canonicalModelId": "${MODEL_ID}",
"sourceId": "${SOURCE_ID}",
"sourceFields": [
{
"name": "Email Address",
"primitive": "string",
"sampleValues": [
"ada@example.com"
]
},
{
"name": "Full Name",
"primitive": "string",
"sampleValues": [
"Ada Lovelace"
]
}
]
}
JSON
)"
Nothing is written. The response gives field matches, a score for each, and whether it reused an earlier mapping.
2. Save it as a draft mapping
POST /api/mappings
MAPPING_ID=$(curl -sS -X POST "$PYROSYNC_URL/api/mappings" \
-H "X-API-Key: $PYROSYNC_API_KEY" \
-H "Content-Type: application/json" \
-d "$(cat <<JSON
{
"key": "contacts_csv",
"title": "Contacts CSV",
"sourceId": "${SOURCE_ID}",
"sourceKind": "file",
"canonicalModelId": "${MODEL_ID}",
"sourceFingerprint": "<fingerprint from the proposal>",
"spec": "<spec from the proposal>"
}
JSON
)" | jq -r '.data.id')
echo "$MAPPING_ID"
3. Preview it against real rows
POST /api/mappings/{id}/preview
curl -sS -X POST "$PYROSYNC_URL/api/mappings/$MAPPING_ID/preview" \
-H "X-API-Key: $PYROSYNC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"Email Address": "ada@example.com",
"Full Name": "Ada Lovelace"
}
]
}'
Result: A draft mapping with a preview of the mapped records. Publishing stays a separate, reviewed step.