Pair two instances in one command
Use `spl federation pair` to set up a lasting, consent-gated connection between two instances with a single command. Covers approval, pausing, sharing rules, and token renewal.
What this is
An instance is any running Syncropel server: your laptop, a hosted instance at <label>.syncropel.app, or a self-hosted server. Two instances can be paired so they share records, with consent controlling what is shared.
spl federation pair add <peer-url> sets up that pair with one command. The command:
- Finds the peer and checks its signed manifest at
/.well-known/syncropel. - Runs a short, replay-protected handshake.
- Creates a service account and token on each side, each tied to the other instance's identity, so neither can pose as someone else.
- Saves the pair on both sides.
- Returns. From then on,
spl syncuses the pair automatically. You never pass a--peer-token.
This guide assumes you have two instances (alice and bob), each with an identity, and each can reach the other's URL.
Prerequisites
- Both instances run
spl(check withspl version). - Each instance has an identity. Run
spl identity show. If it says "no identity," runspl identity generate. - Each instance's URL is reachable from the other. For local two-instance setups, use
--insecure-localhoston both. For cross-host, both should serve TLS. - Optional but recommended:
spl identity verifyon each side first, to check that the local key matches the instance's identity.
The headline command
From alice's host:
spl federation pair add https://bob.example.comThat's it. The output looks like this:
✓ Discovered https://bob.example.com
DID: did:sync:instance:bob-fedb12...
Manifest TTL: 6d 23h remaining
→ Initiating handshake (nonce: 8f4a...)
→ Awaiting peer approval...
[on bob's side, an admin runs `spl decisions approve <id>`]
✓ Pair confirmed
pair_id: fed_<sha256-of-both-DIDs>
scopes: federation:sync_pull, federation:sync_push, federation:subscribe
token TTL: 90d (auto-renew at 83d)
state: active
Saved on: both instances
Try: spl federation list
spl sync th_workspace from did:sync:instance:bob-fedb12...The default is manual approval on both sides. The owner of bob's instance sees the pending request with spl decisions list and approves it with spl decisions approve <id>. Once approved, bob creates the account and token, and alice's command picks them up.
For trusted environments where you want auto-approve (for example, several instances under one owner), see Auto-approval via CEL below.
What happens during approval
When alice runs spl federation pair add <peer-url> and bob requires manual approval:
- Bob receives the request and checks alice's manifest. Bob creates an approval request and answers
202 Accepted. - Alice's command checks with bob every 2 seconds, for up to 60 seconds.
- Bob's owner runs
spl decisions approve <id>. Bob creates the account and token, and records the pair. - Alice's next check receives
state: "active"along with the token. Bob forgets the token once it has been collected, and keeps it for 5 minutes at most. - Alice's command saves the pair and the peer's credential locally, and confirms with bob.
If the 60 seconds pass without approval (for example, the owner is away), alice's command prints a hint and exits successfully:
! still pending after 60s; re-run `spl federation pair add` once the peer operator approvesRunning the command again creates a new pair_id. Bob can reject the old request with spl decisions reject <id>, or it will expire on its own.
The full lifecycle
After pairing, use these spl federation commands to manage the pair:
spl federation list # all pairs + state column
spl federation show <peer-did> # detail: tokens (IDs), grants, last-sync
spl federation pause <peer-did> # active → paused (sync calls fail with pair_paused)
spl federation resume <peer-did> # paused → active
spl federation refresh <peer-did> # re-fetch peer manifest
spl federation revoke <peer-did> --reason X # any → revoked (terminal)A pair is always in one of these states:
- establishing: pairing is in progress.
- active: pairing is complete and the peer is reachable.
- paused: you paused it with
spl federation pause. - degraded: the peer has been unreachable for more than 24 hours.
- revoked: final. You revoked it, or the peer did.
A degraded pair with no contact for 90 days is archived automatically.
Syncing with a pair
Without a pair, you had to pass a token by hand:
spl sync th_workspace from https://bob.example.com --peer-token sk_... # tediousWith a pair:
spl sync th_workspace from did:sync:instance:bob-fedb12... # uses pair storespl sync has no --peer-token flag. If you try to sync from a peer URL that isn't paired, you get:
ERROR: unpaired_peer
https://bob.example.com is not paired with this instance.
Run: spl federation pair https://bob.example.comIf the peer answers a sync with 401, the pair becomes degraded. The next successful sync makes it active again. Every change of state is logged.
Cross-namespace consent
By default, pairing only allows sync within namespaces both peers already share. Cross-namespace record sharing requires an explicit consent grant:
spl federation grant <peer-did> \
--namespace research \
--maps research,my-team \
--hash-level L1This works with namespace consent: the pair decides whether two instances can talk, and consent decides what they may share. They are separate.
To revoke a specific grant without revoking the pair:
spl federation revoke-grant <peer-did> --grant-id <id>Sync mode and thread filtering
Per pair you can configure how often to sync:
spl federation set-mode <peer-did> --mode polling # checks every 5 minutes by default
spl federation set-mode <peer-did> --mode continuous # stays connected and syncs as changes happen
spl federation set-mode <peer-did> --mode on-demand # only when explicitly run
spl federation set-poll-interval <peer-did> --interval 1mAnd what threads sync:
spl federation thread-allow <peer-did> --thread th_workspace
spl federation thread-rule <peer-did> --expression 'thread().id.startsWith("th_research_")'Thread rules accept any CEL expression that uses record and thread().
Auto-approval via CEL
For trusted situations (your own instances, known organisations, CI test setups), you can approve pairs automatically with a decision policy (spl config add-decision-policy):
spl config add-decision-policy \
--name auto-approve-trusted-fleet \
--action auto_apply \
--priority 100 \
--expression 'record.body.aitl.kind == "pair_pending.v1" && record.body.peer_did.startsWith("did:web:my-org.example.com/")'This auto-approves any pair handshake where the peer DID starts with your org's domain. The pair completes immediately, without anyone approving it.
By default there is no auto-approval. Someone approves each pair.
Token rotation
Pair tokens last 90 days and renew automatically at 83 days. The old token stops working as soon as the new one is issued.
If automatic renewal fails:
- One day before expiry, a
pair_renewal_failedentry is added to the audit log. - At expiry, syncs fail with
token_expired_renew_pairand the pair becomesdegraded. - Run
spl federation refresh <peer-did>to renew it by hand.
Auditing
Every change of state is logged on the thread th_audit_federation_pairs. Read that thread to follow what is happening with your pairs:
spl thread records th_audit_federation_pairs -o json | jq '.[] | {when: .body.timestamp, peer: .body.peer_did, transition: .body.transition}'Troubleshooting
"peer served /.well-known/syncropel but no federation_manifest key": the peer has no identity set up. Run spl identity generate on the peer side.
"pair_handshake_rejected: unauthenticated_initiator": certificate (TLS) verification failed. If you're testing locally without TLS, both sides need --insecure-localhost.
"pair_paused" on spl sync: the pair is paused. Run spl federation resume <peer-did>.
"unpaired_peer": you're trying to sync from a URL or DID that doesn't match any pair record. Run spl federation pair add <peer-url> first.
Peer returns 410 Gone: the request was already used. Run spl federation pair again; each attempt needs a fresh request.
What you get
Pairing gives you:
- A network of instances, not disconnected islands.
spl syncwithout handling tokens by hand.- A trail you can audit. The pair's history is kept as records and survives
spl exportandspl import. - Separate controls. Pairing decides who can connect, and consent decides what is shared.
See also
- Federation discovery: finding peers by URL or directory
- Async federation: sync through a relay when peers are offline
- Concepts: Federation: how federation works
- Consent: cross-namespace record sharing rules
Federation: pairing two instances
Set up record sync between two Syncropel instances by hand. Covers identity setup, creating sync pairs, cross-namespace sharing, and common problems.
Invite another instance
Use `spl federation invite` to pair with another instance, share namespaces, and allow threads in one command.