## TL;DR

The ID in a lookup or reference field is malformed or belongs to the wrong object. Validate the ID format and confirm it points at the right object type.

## Error

```text
INVALID_CROSS_REFERENCE_KEY: invalid cross reference id
```

## Steps

1. Check the ID's format and its object prefix Expected: you spot the wrong object or a typo.
2. Confirm the referenced record exists and you can see it Expected: it is real and visible.
3. Fix the lookup value to the correct ID Expected: the reference is valid.
4. Re-run the operation Expected: it succeeds.

## When to use

- INVALID_CROSS_REFERENCE_KEY
- A lookup points at a bad ID

## When not to use

- The ID is fine (then check field-level security)
- The reference is polymorphic (then confirm the allowed types)

## Tool compatibility

- Salesforce ID formats
- Data loader upserts

## Variant phrasings

### invalid cross reference id

The lookup ID is malformed or points at the wrong object.

### INVALID_CROSS_REFERENCE_KEY

Same: validate the ID and its object type.

## Why it happens

Agents copy IDs between objects or truncate them. The three-character prefix encodes the object, so a wrong prefix fails fast.

## Edge cases

- 15 vs 18 character IDs: both work in the API, but case matters for the 15-char form
- External IDs need the field marked as external first

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_IEX6bDVx4yOh0aIUbyFCBw
