
# Check and Fix Drift

This walks through the whole conformance loop: connect an app, link its records to your golden records, say which field must match, find the records that drifted, and fix them. Each step shows the [`fob-mdm`](/docs/cli) command first and the API call under it. Both do the same thing.

> **Simulated apps:** Reading from and writing to real apps isn't built yet. Here the app's records are ones you give it in `config.sample_records`, so you can see every step work.

## Before you start

You need an API key with **Full Access** (**Settings → API Keys**), and a Vendor object with a `gstin` identity field, a `bank_ifsc` field and a golden record. The [Quick Start](/docs/guide/quick-start) sets those up.

For the CLI, save the key as a profile once:

```bash
fob-mdm config profiles add acme
```

For cURL, put it in your shell:

```bash
export MDM=https://mdm.finopsbricks.com/api/v1
export MDM_API_KEY=fob_mdm_xxxxxxxxxxxxxxxxxx
export MDM_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
```

## Step 1: Connect an app

Register the payments platform. Its records are vendors, and `sample_records` are the vendors it holds: Acme Supplies with a stale IFSC, and Acme Labs, which has no golden record yet. Save this as `payments.json`:

```json
{
  "sample_records": [
    { "tp_id": "cont_8f2k", "name": "ACME SUPPLIES", "gstin": "29ABCDE1234F1Z5", "bank_ifsc": "HDFC0009999" },
    { "tp_id": "cont_9x1m", "name": "Acme Labs LLP", "gstin": "29PQRST6789K1Z2", "bank_ifsc": "ICIC0004321" }
  ]
}
```

```bash
fob-mdm integrations create --name Payments --type razorpayx --object vendor --config payments.json
```

```
ID:        5
Name:      Payments
Type:      razorpayx
Object:    vendor
Records:   2 simulated
Created:   2026-11-26 07:20:08
```

With cURL, `config.object` names the object:

```bash
curl -X POST "$MDM/integrations" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Payments",
    "type": "razorpayx",
    "config": {
      "object": "vendor",
      "sample_records": [
        { "tp_id": "cont_8f2k", "name": "ACME SUPPLIES", "gstin": "29ABCDE1234F1Z5", "bank_ifsc": "HDFC0009999" },
        { "tp_id": "cont_9x1m", "name": "Acme Labs LLP", "gstin": "29PQRST6789K1Z2", "bank_ifsc": "ICIC0004321" }
      ]
    }
  }'
```

The integration's id is `5` below.

## Step 2: Link its records

```bash
fob-mdm integrations pull 5
```

```
Pulled 2: 1 newly linked, 0 refreshed, 1 not linked.

TP_ID      REASON
---------------------------
cont_9x1m  no_golden_record

no_golden_record: create the golden record, then pull again. no_identity_value: the app has no identity value for it.
```

```bash
curl -X POST "$MDM/integrations/5/pull" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"
```

```json
{ "data": { "pulled": 2, "linked": 1, "updated": 0, "unmatched": [{ "tp_id": "cont_9x1m", "reason": "no_golden_record" }] } }
```

Acme Supplies was linked to the golden record with the same GSTIN. Acme Labs wasn't: there's no golden record with its GSTIN. Create one and pull again to link it.

The golden record now shows the app's values next to its own:

```bash
fob-mdm records show 100
```

```
ID:       100
Object:   1

name:       Acme Supplies Private Limited
gstin:      29ABCDE1234F1Z5
bank_ifsc:  HDFC0001234

--- Payments (cont_8f2k) ---

FIELD      APP VALUE        MATCHES
-----------------------------------
name       ACME SUPPLIES    NO
gstin      29ABCDE1234F1Z5  yes
bank_ifsc  HDFC0009999      NO
```

## Step 3: Require the field to match

The name differs too, but only the bank IFSC matters for payments. Require it to match, and have the app's owner fix it:

```bash
fob-mdm contracts create --integration 5 --field bank_ifsc --mode ticket
```

The API takes the field's id rather than its key. `fob-mdm fields list --object vendor` shows it, `12` here:

```bash
curl -X POST "$MDM/conformance-contracts" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{ "integration": 5, "field": 12, "enforcement_mode": "ticket" }'
```

`ticket` waits for a person to change the app. `auto` has MDM push the golden value itself.

## Step 4: Find the drift

```bash
fob-mdm conformance run
fob-mdm conformance status --status failed
```

```
Checked 1: 0 conformant, 1 failed.
See them with: fob-mdm conformance status --status failed

STATE  INTEGRATION  RECORD  FIELD      STATUS  CHECKED
------------------------------------------------------------------
41     5            100     bank_ifsc  failed  2026-11-26 07:20:08
```

```bash
curl -X POST "$MDM/conformance/reconcile" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"

curl -X GET "$MDM/conformance/states?status=failed" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"
```

The app's `HDFC0009999` differs from the golden `HDFC0001234`, so state `41` is `failed`.

## Step 5: Fix it

```bash
fob-mdm conformance enforce 41
```

```
State 41 (record 100, bank_ifsc) is now pending: ticket_opened.
A ticket is open. Once the app's owner has fixed it: fob-mdm conformance confirm 41
```

Once the app's owner has changed the IFSC, confirm it:

```bash
fob-mdm conformance confirm 41
```

```
State 41 (record 100, bank_ifsc) is now conformant: verified.
```

```bash
curl -X POST "$MDM/conformance/states/41/enforce" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"

curl -X POST "$MDM/conformance/states/41/confirm" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"
```

With an `auto` contract there's no ticket: `enforce` pushes the golden value, and the state turns `conformant` straight away. Switch with `fob-mdm contracts edit 3 --mode auto`.

`fob-mdm conformance events` ([List Enforcement Events](/docs/api/endpoints/conformance/events)) shows what was done, and the record's page in the app shows the Payments column.

## Related

- [Hub-First Editing and Conformance](/docs/concepts/hub-first-and-conformance)
- CLI: [integrations](/docs/cli/integrations), [contracts](/docs/cli/contracts), [conformance](/docs/cli/conformance)
- API: [Integrations](/docs/api/endpoints/integrations), [Conformance Contracts](/docs/api/endpoints/conformance-contracts), [Conformance](/docs/api/endpoints/conformance)
