SSyncropel Docs

Your first federation pair

Pair two workspaces with one command, write a record on one, read it on the other, and see how consent controls what is shared.

What you'll build

Two workspaces (alice and bob), paired with spl federation pair add, exchanging records over a single signed link. You'll write a record on alice, sync it to bob, and check it arrived, without setting up any URLs or tokens by hand.

Federation in Syncropel is records on a reserved thread, not a separate sign-in or transport system. The pair, its consent grants and its sync state are all records on th_federation_pairs.

Allow about 30 minutes, including one approval on bob's side.

Before you start

  • spl installed (spl --version)
  • Two workspaces side by side. The easiest setup is the same machine with different ports and different SYNCROPEL_HOME folders.
  • Each workspace has an identity (spl identity show shows a DID). If not, run spl identity generate.
  • Each workspace can reach the other. Two workspaces on the same machine can.

1. Start two workspaces

Keep the tutorial off port 9100

If you already run Syncropel on this machine, it is listening on 9100 and using ~/.syncro/. The tutorial workspaces use their own home folders and different ports so nothing collides with, or writes into, your real data.

Terminal A, alice on port 9201:

SYNCROPEL_HOME="$HOME/.syncro-alice" \
  spl serve --port 9201 --insecure-localhost

Terminal B, bob on port 9202:

SYNCROPEL_HOME="$HOME/.syncro-bob" \
  spl serve --port 9202 --insecure-localhost

--insecure-localhost turns sign-in off for a workspace that only listens on this machine (127.0.0.1). It is not about TLS. That lets this tutorial skip tokens entirely. Use it for local testing only. Real workspaces keep sign-in on, and pairs across machines exchange real credentials.

In a third terminal, set up a shortcut for each workspace:

alias spl-alice='SYNCROPEL_HOME=$HOME/.syncro-alice SPL_SERVE_URL=http://127.0.0.1:9201 spl'
alias spl-bob='SYNCROPEL_HOME=$HOME/.syncro-bob SPL_SERVE_URL=http://127.0.0.1:9202 spl'

Verify both are healthy:

spl-alice status
spl-bob status

Both should report a green status with their DIDs shown in the instance_did field.

2. Start the pair from alice

spl-alice federation pair add http://127.0.0.1:9202

What you'll see, in order:

✓ Discovered http://127.0.0.1:9202
  DID:           did:sync:instance:bob-fedb12...
  Manifest TTL:  6d 23h remaining

→ Initiating handshake (nonce: 8f4a...)
→ Awaiting peer approval...

The CLI now checks bob's pair status every 2 seconds for up to 60 seconds, waiting for someone on bob's side to approve.

3. Approve on bob's side

In the third terminal, list bob's pending decisions (everything waiting for a person):

spl-bob decisions list

You'll see one entry for the pending pair:

ID                 KIND                                         BODY (excerpt)
2c7b8f…            syncropel.federation.pair_pending.v1         peer_did: did:sync:instance:alice-...
                                                                pair_id:  fed_<sha256>

Approve it:

spl-bob decisions approve 2c7b8f…

Output:

✓ Approved
  request: 2c7b8f…
  action:  applied
  result:  pair_completed
            pair_id: fed_<sha256>
            sa_minted: sa_bob_for_alice_<id>
            token_ttl: 90d

Approving a pair_pending.v1 decision completes the pair: bob's workspace created a service account for alice, saved a signed pair.genesis.v1 on its th_federation_pairs thread, and sent the result back to alice.

4. Watch alice complete the handshake

Back in terminal A's polling, alice now sees the approval:

✓ Pair confirmed
  pair_id:       fed_<sha256>
  scopes:        federation:sync_pull, federation:sync_push, federation:subscribe
  token TTL:     90d (auto-renew at 83d)
  state:         active

  Persisted at:  th_federation_pairs (genesis record on both sides)

The pair is active: it is recorded on both sides, each side has a token for the other, and spl sync can use the pair without any --peer-token.

Verify with:

spl-alice federation list
PEER DID                                    URL                          STATE     LAST_SYNC
did:sync:instance:bob-fedb12...             http://127.0.0.1:9202        active    never

And on bob's side:

spl-bob federation list

You should see alice's DID with state active. Both sides hold the relationship; this pair works in both directions (records can flow both ways, subject to consent).

5. Write a record on alice and sync to bob

spl-alice intend "Test the federation link" --thread th_fed_test

Output includes the record id and thread. Now pull from alice on bob's side:

spl-bob sync th_fed_test from did:sync:instance:alice-...

Output:

✓ Sync complete
  thread:  th_fed_test
  pulled:  1 record
  cursor:  <opaque>

The pair already knows alice's address and token, so you don't need --peer-token or --peer-url. If you tried to sync from a URL with no matching pair, you'd get ERROR: unpaired_peer.

6. Verify the record arrived

spl-bob thread records th_fed_test
ACTOR                              ACT       BODY (excerpt)
did:sync:user:alice                INTEND    Test the federation link

Same record ID, same body and same thread ID on both workspaces. A record's ID comes from its content, so the two copies cannot differ.

The reverse direction works the same way:

spl-bob know "Verified the federation link from bob's side" --thread th_fed_test
spl-alice sync th_fed_test from did:sync:instance:bob-fedb12...
spl-alice thread records th_fed_test

You'll now see two records on both sides, alice's INTEND and bob's KNOW, forming a single thread that spans both workspaces.

7. Inspect the pair lifecycle records

The pair is itself records on th_federation_pairs:

spl-alice thread records th_federation_pairs

You'll see at least three records:

  • pair_init.v1: alice's request to pair
  • pair.genesis.v1 (signed by bob): the record that activates the pair
  • pair_active.v1 (on alice's side only): alice's confirmation

The pair's current state comes from this thread. Pausing, resuming and revoking each add a record that changes it.

What just happened

You did the following:

  1. One command created the pair. spl federation pair add <url> found the peer, completed a secure handshake, created matching accounts, and saved signed pair records on both sides. No config file to edit and no tokens to copy.
  2. Approval can't be skipped. Bob's workspace raised a decision request and did not complete until a person approved. The approval is itself a signed record. Auto-approval is optional (see the federation pair guide); the default is manual.
  3. spl sync uses the pair automatically. The pair holds the credential, so you don't pass --peer-token.
  4. The same record has the same ID everywhere. Alice's record ID equals bob's for the same record, so the two copies cannot conflict.
  5. The pair is auditable and portable. Pair changes are records. spl export from alice includes the pair, and importing into a new workspace carries it forward (see the portability guide).

Pairing is the gate to everything else federation does, such as relaying while a peer is offline and sharing across namespaces with consent.

Where to next

Troubleshooting

SymptomLikely causeFix
peer served /.well-known/syncropel but no federation_manifest keyThe other workspace has no identity set up.On the other workspace: spl identity show. If it reports no identity, run spl identity generate. Then re-try the pair from the initiating side.
pair_handshake_rejected: unauthenticated_initiatorSecure connection failed. Either the peer's address doesn't serve a valid certificate, or you forgot --insecure-localhost on a local-only setup.For local testing, make sure both workspaces started with --insecure-localhost. For real setups across machines, confirm both sides use TLS. The flag is for testing only and is refused on any host other than 127.0.0.1.
The approval times out (alice's CLI prints still pending after 60s)Nobody approved on bob's side within 60 seconds. The pair is still in establishing state.The original pair_pending.v1 decision on bob's side stays valid until bob rejects it or it expires. Re-run spl federation pair add <url> from alice to start a new attempt that can be approved.
unpaired_peer on spl syncYou're syncing from a URL or DID that doesn't match any pair record on this side.Run spl federation list to confirm what pairs exist on this side. If you expected one but it's missing, the pair was never completed (the handshake was interrupted). Re-run spl federation pair add <url>.
Pair shows degraded stateThe peer was unreachable for over 24 hours, or a sync call got a 401 (token expired or revoked).Run spl federation refresh <peer-did> to check the peer again. If the peer is permanently gone, spl federation revoke <peer-did> cleanly closes out the pair.

On this page