> ## Documentation Index
> Fetch the complete documentation index at: https://docs.embedreach.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Sync Setup

> Phase 4: Define schemas for your data structure

## Overview

Phase 4 turns your Phase 3 plan into concrete schemas. You define how your data maps to Reach's system through flexible schema definitions that match your existing data structure—no transformation required. Reach reviews the proposed model with you before go-live.

## The Two-Part Process

**1. Defining schemas**

You define schemas that describe your data exactly as it exists in your system, then Reach reviews the model and required mappings with you.

**2. Sending data**

Historical import followed by ongoing sync (covered in Phase 5)

> [!NOTE]
>
> This is **self-service** — you create schemas, map fields, and send data through the partner UI or API without waiting on us. During onboarding we'll review the model with you before go-live. If you haven't yet, read [How Reach models your data](https://docs.embedreach.com/data-sharing/data-model.md) first; the [Custom Schemas](https://docs.embedreach.com/data-sharing/custom-schemas.md) reference has the full JSON format.

## Schema Creation Process

### Step 1: Start from your real data

Use example JSON objects of your customer, transaction, and other important business records **as they exist in your system** as the basis for the schemas you'll define. Don't reshape your data to fit ours — the schema describes your structure as-is.

> [tab] Customer Example
>
> ```json theme={null}
> {
>   "id": "cust_12345",
>   "email": "john@example.com",
>   "phone": "+14155551234",
>   "first_name": "John",
>   "last_name": "Doe",
>   "created_at": "2024-01-15T10:30:00Z",
>   "city": "San Francisco",
>   "state": "CA",
>   "total_lifetime_value": 5280.50,
>   "tags": ["vip", "email_subscribed"]
> }
> ```

> [tab] Transaction Example
>
> ```json theme={null}
> {
>   "id": "txn_67890",
>   "customer_id": "cust_12345",
>   "amount": 150.00,
>   "created_at": "2024-03-20T14:22:00Z",
>   "status": "completed",
>   "items": [
>     {
>       "name": "Service A",
>       "price": 100.00
>     },
>     {
>       "name": "Service B",
>       "price": 50.00
>     }
>   ]
> }
> ```

> [tab] Location Example
>
> ```json theme={null}
> {
>   "id": "loc_001",
>   "name": "Downtown Office",
>   "address": {
>     "street": "123 Main St",
>     "city": "Portland",
>     "state": "OR",
>     "zip": "97201"
>   },
>   "phone": "+15035551000",
>   "google_business_profile_id": "ChIJ..."
> }
> ```

> [!NOTE]
>
> Send representative redacted examples from your source model—not idealized versions. Include optional fields and null states, but do not share production PII or credentials.

### Step 2: Define custom schemas

Create a schema for each record type. Each schema accepts your exact structure and is assigned a category:

**Schema Categories:**

* **`contacts_schema`**: Customer/contact records
* **`transactions_schema`**: Transaction/billing records
* **`locations_schema`**: Location/address records
* **Additional schemas**: Custom schemas as needed for your business model

**No data transformation required** — your format is accepted as-is. See [Custom Schemas](https://docs.embedreach.com/data-sharing/custom-schemas.md) for the JSON Schema format, `$ref` references between schemas, and PII annotations.

### Step 3: Map critical fields

In each schema mapping, identify which fields serve key purposes:

> [tab] Customer Mappings
>
> **Customer Schema Mappings:**
>
> * Which field is the email? → `email`
> * Which field is the phone? → `phone`
> * Which field is the customer ID? → `id`
> * Which field is the creation date? → `created_at`
> * Which fields for segmentation? → `tags`, `city`, `state`, `total_lifetime_value`
> * Which fields for merge fields? → `first_name`, `last_name`
>
> These mappings enable:
>
> * Segmentation for targeted campaigns
> * Personalization in emails and SMS
> * Attribution logic

> [tab] Transaction Mappings
>
> **Transaction Schema Mappings:**
>
> * Which field is the amount? → `amount` or `total`
> * Which field is the transaction date? → `created_at` or `completed_at`
> * Which field links to customer? → `customer_id`
> * Which field indicates status? → `status`
> * Which fields contain line items? → `items` array
>
> These mappings enable:
>
> * ROAS calculations
> * Revenue attribution
> * Conversion tracking

> [tab] Location Mappings
>
> **Location Schema Mappings:**
>
> * Which field is the location name? → `name`
> * Which field has the address? → `address` object
> * Which field links to Google Business Profile? → `google_business_profile_id`
>
> These mappings enable:
>
> * Multi-location reputation management
> * Location-based segmentation
> * Google Business Profile integration

### Step 4: Send data to the resources endpoint

Once a schema exists, you write records against it at the standard resources endpoint, keyed by schema name:

```bash theme={null}
POST /api/resources/{SchemaName}    # e.g. /api/resources/Customer, /api/resources/Transaction
```

Each request accepts your JSON structure directly—no reformatting needed. Writes are an upsert keyed on the record's external ID. See [Ongoing Data Sync](https://docs.embedreach.com/onboarding/ongoing-sync.md) for single vs. batch writes and backfill.

## What Data You'll Send

### Customer/Contact Data (When Products Use Synced Contact Identity)

**Minimum Required:**

* Unique customer ID from your system
* Either first and last name, or a single full name — Reach rejects a contacts mapping without one
* Email and/or phone when the selected product workflow uses that delivery or identity route

**Highly Recommended:**

* Phone number (enables SMS, improves attribution)
* Creation date/timestamp
* Address (city, state, zip for geographic targeting)

**Optional but Valuable:**

* Custom attributes for segmentation
* Lifetime value or spend metrics
* Customer status (active, inactive, churned)
* Opt-in/opt-out status for email and SMS
* Tags or categories

### Transaction/Billing Data (Varies by Industry)

> [tab] Online Transactions
>
> **E-commerce, Bookings:**
>
> * Order data with line items
> * Sent after purchase completion
> * Include product/service details
>
> ```json theme={null}
> {
>   "externalId": "order_4567",
>   "customerId": "customer_789",
>   "amount": 250.00,
>   "createdAt": "2024-04-15T11:30:00Z",
>   "status": "completed",
>   "items": [
>     {
>       "name": "Product A",
>       "quantity": 2,
>       "price": 100.00
>     }
>   ]
> }
> ```

> [tab] Contract-Based
>
> **SaaS, Memberships:**
>
> * Agreements/proposals after finalization
> * Can be amended over time as contracts change
> * Include contract value and terms
>
> ```json theme={null}
> {
>   "externalId": "contract_789",
>   "customerId": "customer_456",
>   "amount": 12000.00,
>   "createdAt": "2024-01-10T09:00:00Z",
>   "startDate": "2024-02-01",
>   "endDate": "2025-02-01",
>   "status": "active"
> }
> ```

> [tab] Invoice-Based
>
> **B2B Services:**
>
> * Invoice data (even if unpaid)
> * More important than payment completion
> * Describes the sale before money changes hands
>
> ```json theme={null}
> {
>   "externalId": "invoice_123",
>   "customerId": "customer_789",
>   "amount": 5000.00,
>   "invoiceDate": "2024-03-01",
>   "dueDate": "2024-03-31",
>   "status": "pending",
>   "services": [...]
> }
> ```

### Location Data (If Applicable)

**Required for:**

* Reputation product (Google Business Profile mapping)
* Location-based segmentation in Engage

**Skip if:**

* Only using Measure/Acquire
* Single-location businesses

## Key Decision: What Counts as a Transaction?

Work with Reach to define your "conversion event"—the moment that matters for attribution:

> [card] Booking-Based
>
> **When:** Customer schedules/reserves
>
> **Pros:**
>
> * Shows impact quickly
> * Captures intent early
>
> **Cons:**
>
> * Not actual revenue yet
> * May include cancellations

> [card] Payment-Based
>
> **When:** Customer pays
>
> **Pros:**
>
> * Actual revenue
> * Most accurate attribution
>
> **Cons:**
>
> * Longer attribution window
> * Delayed insights

> [card] Invoice-Based
>
> **When:** Invoice is issued
>
> **Pros:**
>
> * Describes the sale
> * Works for B2B/net-terms
>
> **Cons:**
>
> * May not reflect payment
> * Requires status updates

> [!NOTE]
>
> You can send updates as transactions progress through stages (booked → paid → fulfilled). This provides both early visibility and eventual accuracy.

## Schema Evolution

Schemas can evolve as your needs change, within strict validation rules that protect existing data:

**Adding new fields** — always safe. Add the field to the schema; existing records are unaffected and the new field becomes available for segmentation and merge fields.

**Renaming, retyping, or removing a field** — restricted once records exist. Removing a field that resources use returns an error rather than silently dropping data; a field that live tenant segments or merge fields depend on is protected. While you're still iterating before go-live, the simplest path is to clear a schema's resources and re-send.

**Adding new schemas** — self-service and independent. Define the new schema and start writing to it at your own pace.

> [!NOTE]
>
> The full change-by-change reference (what's allowed, what errors, and how to fix it) lives in the schema lifecycle guide.

## Phase 4 Checklist

**1. Representative source examples reviewed**

Redacted JSON examples include required, optional, and null states

**2. Schemas defined by the partner and reviewed with Reach**

Custom schemas match the approved source structure and product requirements

**3. Field mappings confirmed**

Critical fields identified for attribution and segmentation

**4. API endpoints provisioned**

Custom endpoints ready to accept your data

**5. Conversion event defined**

Decision made on what counts as a transaction

## Next Steps

With schemas defined, you're ready to choose a sync method and begin sending data.

> [card] [Phase 5: Ongoing Data Sync](https://docs.embedreach.com/onboarding/ongoing-sync.md)
>
> Choose sync method and implement ongoing data flow


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.