Skip to content
Rezha Julio

activitypub

How ActivityPub actually works

13 min read

WebFinger, inboxes, Follow and Accept, signed POSTs, and the fan-out. How the protocol behind Mastodon, Pixelfed, and Threads actually moves your posts around.

Blueprint-style drawing of five lighthouse towers on separate islands exchanging sealed envelopes along dotted routes
Blueprint-style drawing of five lighthouse towers on separate islands exchanging sealed envelopes along dotted routes

I run two Mastodon instances, pegelinux.top and fedi.my.id. The question I get most often about them is some version of: how does a post I write on my server end up on a server I have never heard of?

The short answer is ActivityPub. The long answer is this post.

ActivityPub is the protocol underneath Mastodon, Pixelfed, PeerTube, Lemmy, Misskey, and a growing list of things that are not microblogging at all. WordPress blogs speak it through an Automattic-maintained plugin. Ghost 6.0 ships it built in. Meta wired Threads into it, opt-in, starting in 2024. If you have used any of these, you have used ActivityPub whether you noticed or not.

What follows is how the protocol actually works: the data model, the identity lookup, the follow handshake, the delivery fan-out, and the signature scheme that keeps random strangers from posting as you. Everything below comes from the W3C specs, the Mastodon documentation, and the kind of payload watching you end up doing when you operate an instance.

A protocol in two parts

ActivityPub became a W3C Recommendation on 23 January 2018, written by Christine Lemmer-Webber, Jessica Tallon, Erin Shepherd, Amy Guy, and Evan Prodromou in the Social Web Working Group. It is built on top of ActivityStreams 2.0, a separate W3C standard that defines the vocabulary: what a “Note” is, what a “Follow” is, and so on.

The spec actually defines two protocols:

  1. Client to server (C2S): how your app talks to your own server. You POST activities to your outbox, and the server wraps bare objects in a Create for you.
  2. Server to server (S2S): how servers talk to each other. This is the federation part.

Here is the slightly awkward truth: almost nobody implements the client-to-server half. Mastodon has its own REST API. Misskey has its own API. When people say “ActivityPub” in 2026, they almost always mean the server-to-server federation protocol. That is the half this post is about.

One more foundation note: ActivityPub data is JSON-LD. If you know JSON-LD, great. If you do not, you can read every payload in this post as plain JSON and miss nothing. That was a deliberate design choice, and it is a big part of why the protocol spread.

The data model: actors, activities, objects

Everything in ActivityPub is an object with an id, and every id is a URL you can fetch. Three families of objects matter:

  • Actors are the things that do stuff: Person, Organization, Service, Application, Group. Your account is an actor.
  • Objects are the content: Note (a short post), Article (long-form), Image, Video, Event, Question (polls), and more.
  • Activities are the verbs: Create, Update, Delete, Follow, Accept, Reject, Like, Announce, Undo, Block, Move, Flag. An activity always has an actor (who did it) and usually an object (what they did it to).

Every actor comes with two required endpoints: an inbox (where activities addressed to you arrive) and an outbox (a list of what you produced). Both are OrderedCollections. Actors also expose followers and following collections, and those collections are load-bearing, as you will see in the delivery section.

ActivityPub at a glance. Click a node to fold it, scroll to zoom, drag to move.

Finding people: WebFinger

You know people as @alice@fedi.example. The protocol does not. ActivityPub only knows actor URLs like https://fedi.example/users/alice. The translation between the two is a separate standard: WebFinger, RFC 7033.

Given a handle, you ask the domain’s well-known endpoint:

GET https://fedi.example/.well-known/webfinger?resource=acct:alice@fedi.example

and get back a small JSON document:

{
"subject": "acct:alice@fedi.example",
"links": [
{
"rel": "self",
"type": "application/activity+json",
"href": "https://fedi.example/users/alice"
}
]
}

The rel: "self" link of type application/activity+json is the actor URL. Fetch that URL with an Accept: application/activity+json header and you get the actor document itself:

{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1"
],
"id": "https://fedi.example/users/alice",
"type": "Person",
"preferredUsername": "alice",
"name": "Alice",
"summary": "<p>Posts about protocols.</p>",
"inbox": "https://fedi.example/users/alice/inbox",
"outbox": "https://fedi.example/users/alice/outbox",
"followers": "https://fedi.example/users/alice/followers",
"following": "https://fedi.example/users/alice/following",
"publicKey": {
"id": "https://fedi.example/users/alice#main-key",
"owner": "https://fedi.example/users/alice",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
}
}

Two things worth noticing. First, the handle and the actor URL are allowed to look nothing alike, and on some software they genuinely do not. Second, the actor carries a public key. Hold that thought; it becomes important in the signatures section.

Try a lookup: from a handle to an actor document

Sample data, shaped exactly like real responses. No lookup leaves your browser; arbitrary domains would block the browser call with CORS anyway.

This indirection is also why your handle is tied to your domain. Move domains and your old handle stops resolving, which is why self-hosters care so much about owning their domain.

Following someone: the handshake

Say alice on instance A wants to follow berta on instance B. Alice clicks Follow. Her server POSTs a Follow activity to berta’s inbox:

{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://a.example/activities/9f2c1e",
"type": "Follow",
"actor": "https://a.example/users/alice",
"object": "https://b.example/users/berta"
}

If berta’s account auto-accepts, instance B immediately POSTs an Accept back to alice’s inbox, quoting the original activity:

{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://b.example/users/berta#accepts/follows/42",
"type": "Accept",
"actor": "https://b.example/users/berta",
"object": {
"id": "https://a.example/activities/9f2c1e",
"type": "Follow",
"actor": "https://a.example/users/alice",
"object": "https://b.example/users/berta"
}
}

Only after the Accept lands does instance A record alice as following berta, and instance B record alice as a follower of berta. A locked account holds the Follow in a pending state and answers with Accept or Reject once a human decides. Unfollowing is an Undo wrapping the original Follow.

Walk the whole exchange, including the signature checks and the unfollow:

Instance A, alice's server

    Instance B, berta's server

      Sample exchange. Payloads follow the real shapes, domains are shortened to a.example and b.example so the movement is easy to follow. Nothing leaves your browser.

      That is the whole social graph: thousands of these little exchanges per second, between servers that have never met.

      Posting: Create, addressing, and the fan-out

      When alice publishes a post, her server wraps the object in a Create activity and delivers it:

      {
      "@context": "https://www.w3.org/ns/activitystreams",
      "id": "https://a.example/users/alice/statuses/109234567890/activity",
      "type": "Create",
      "actor": "https://a.example/users/alice",
      "published": "2026-12-06T02:00:00Z",
      "to": ["https://www.w3.org/ns/activitystreams#Public"],
      "cc": ["https://a.example/users/alice/followers"],
      "object": {
      "id": "https://a.example/users/alice/statuses/109234567890",
      "type": "Note",
      "attributedTo": "https://a.example/users/alice",
      "content": "<p>Hello, fediverse.</p>",
      "to": ["https://www.w3.org/ns/activitystreams#Public"],
      "cc": ["https://a.example/users/alice/followers"]
      }
      }

      A few details in there do real work:

      • The content is HTML. Clients render it; they do not parse markup out of plain text.
      • Addressing is explicit. to, cc, bto, bcc, and audience decide who gets the activity. The special URI https://www.w3.org/ns/activitystreams#Public (often written as:Public) means “publicly visible.” It is a marker, not a destination: the spec forbids delivering anything to it. A typical public Mastodon post is addressed to: as:Public and cc: followers. Followers-only flips that: to: followers, no public marker.
      • The audience on the activity and on the object match. Receiving servers check both.

      Delivery is the sender’s job. Instance A computes the recipient set from the addressing fields, expands any collections (the followers collection is the common one), de-duplicates, and POSTs the activity to every remote inbox. This is why the followers collection matters: it is the mailing list for everything you publish.

      Fan-out is expensive, so there is an optimization. An actor can advertise a sharedInbox, one endpoint per server that accepts deliveries meant for many local users at once. Instead of 500 POSTs to 500 inboxes on mastodon.social, alice’s server sends one POST to mastodon.social’s shared inbox and lets it sort out local delivery. The difference is easiest to see:

      Alice publishes a public Note. Her server delivers it.

      500 remote followers spread over 3 servers. Flip the switch and watch the delivery count.

      1. 1Wrap the Note in a Create, addressed to: as:Public, cc: alice's followers.
      2. 2Expand the followers collection: remote actors.
      3. 3Resolve each actor's inbox and group the deliveries.
      4. 4Queue one POST per destination inbox. Failed ones retry later.

      POSTs sent

      Sample run. Counts are realistic for a mid-size account; the splitting and retry behavior is what Mastodon, Misskey and friends actually do. Nothing leaves your browser.

      Replies work the same way, with the addition of inReplyTo pointing at the parent object, and a Mention tag for every @-mentioned actor, who also lands in the addressing. Mentions are how a post reaches someone who does not follow you.

      Proving you said it: HTTP signatures

      So far this all works on trust, and that should bother you. Anybody can POST a JSON blob to berta’s inbox claiming that alice wants to follow her. Or worse, claiming that alice wants to Delete her own account.

      The answer is signatures, and here the spec gets coy. It says servers SHOULD validate what they receive and explicitly declines to mandate a mechanism. The fediverse converged on one anyway: HTTP Signatures, an IETF draft that never became an RFC but is load-bearing infrastructure for the entire network.

      It works like this. Every actor has a key pair; you saw the public half on the actor document. When instance A POSTs the Follow to instance B, it signs the request with alice’s private key and attaches a header:

      Signature: keyId="https://a.example/users/alice#main-key",
      algorithm="rsa-sha256",
      headers="(request-target) host date digest",
      signature="..."

      One signed POST, end to end

      The receiver side is where the trust is decided. Try flipping the tamper switch before the last step.

      1. 1Instance A builds the request: the Follow body plus Host, Date and a Digest of the body.
      2. 2It joins the listed headers into a signing string and signs it with alice's private key.
      3. 3The Signature header rides along. Its keyId says whose key signed and where to fetch the public half.
      4. 4Instance B fetches alice's actor document, rebuilds the signing string from the request it received, and verifies.

      The signing string

      (request-target): post /users/berta/inbox
      host: b.example
      date: Sun, 06 Dec 2026 02:00:00 GMT
      digest: SHA-256=9f2c1e7a…

      What travels

      Signature: keyId="https://a.example/users/alice#main-key",
        algorithm="rsa-sha256",
        headers="(request-target) host date digest",
        signature="a94bbf02…"

      Simplified but faithful: real servers also check the Date for freshness and re-fetch keys on a schedule. Nothing is computed or sent anywhere.

      Instance B reads the keyId, fetches alice’s actor document if it has not seen her before, pulls out publicKeyPem, and verifies the signature over the listed headers. Valid signature means the request really came from whoever controls alice’s key. Invalid means drop it.

      Two practical wrinkles:

      • Fetching is also signed, sometimes. Servers in “secure mode” (Mastodon’s authorized fetch) and software like GoToSocial require signatures on GET requests too. That creates a bootstrap problem: to verify a signature you need the actor’s public key, but fetching the actor document itself requires a signature, signed by whom? Mastodon’s answer is the instance actor, an internal account per server whose key signs outbound fetches. The loop breaks because the instance actor’s key can be fetched without yet knowing the original actor.
      • Linked Data Signatures were the other candidate. The spec mentions them, Mastodon supported them for a while, and then dropped them in favor of HTTP signatures alone. The lesson generalizes: what the fediverse actually runs is defined by implementations, and the paper standard follows.

      If you take one thing from this section: the signature, not the actor field, is what identifies the sender. Software that forgets this has a bad time.

      The verb table

      Create and Follow do most of the volume, but the vocabulary covers the whole social app surface:

      ActivityWhat it means in practice
      CreateNew post, wraps the object
      AnnounceBoost or reblog
      LikeFavorite
      Follow / Accept / RejectFollow request and its answer
      UndoUnfollow, un-like, un-boost, wraps the original
      UpdatePost edit or profile change
      DeleteRemove a post, or delete the whole actor
      MoveAccount migration to a new actor
      BlockBlock, mostly advisory between servers
      FlagReport to the other server’s moderators
      QuestionPolls, as an object type rather than an activity

      Move deserves a sentence. Migration across servers is possible: the old account sets alsoKnownAs pointing at the new one and sends a Move, and remote servers re-point your followers automatically. Your followers move. Your posts do not.

      The stuff Mastodon added on top

      The spec gives you a skeleton; real software grows features the spec never mentions, communicated through the same JSON. A few you have definitely seen:

      • Content warnings. Mastodon’s CW is the summary property used in a way the vocabulary did not intend, plus sensitive: true. It stuck, and now everything understands it.
      • Custom emoji. tag entries of type Emoji, under the http://joinmastodon.org/ns# namespace, with the image as an Icon.
      • Pinned posts. A featured collection on the actor document.
      • Profile fields. attachment entries of schema:PropertyValue type.
      • Hashtags and mentions. tag entries of type Hashtag and Mention.

      Extensions like these get written up as FEPs, Fediverse Enhancement Proposals, a community process run out of the SocialHub forums. It is RFC-flavored governance for a protocol whose official working group disbanded years ago. The Social Web Incubator Community Group keeps the lights on at the W3C, but the center of gravity is the FEP process now.

      Who actually speaks it

      The network is bigger than Mastodon and has been for a while:

      • Microblogging: Mastodon, Misskey and its fork Sharkey, Pleroma and its fork Akkoma, GoToSocial, and Threads (more on that below).
      • Media: Pixelfed for photos, PeerTube for video, Funkwhale for audio.
      • Long-form: WriteFreely, BookWyrm for book reviews, WordPress via the ActivityPub plugin that Automattic now maintains, and Ghost since version 6.0 shipped the social web built in.
      • Link aggregation: Lemmy and friends, where Group actors act as communities.
      • Events: Mobilizon.

      Threads is the biggest name and the strangest fit. Meta made fediverse sharing opt-in in a March 2024 beta, expanded it through 2024 (likes and replies from the fediverse visible in Threads, following fediverse accounts that interacted with you), and added a dedicated fediverse feed and fediverse search in June 2025. By Meta’s count, Threads had interacted with over 75% of fediverse servers. But the connection stays narrow: most Threads users never flip the switch, polls and quote posts do not cross over, and the EU rollout lags behind for regulatory reasons. It is a real member of the network and a reminder that federation is a policy choice, not just a technical one.

      Bluesky is the notable absence. It runs on AT Protocol, a different design with different tradeoffs, and does not speak ActivityPub at all. Bridgy Fed bridges the two networks for accounts that opt in.

      The honest limitations

      I like this protocol enough to run two servers, so let me be straight about where it creaks:

      • Deletes and undos are advisory. A Delete is a request. A server that dislikes you can keep your post and ignore it. Federation means copies exist on machines you do not control; act accordingly.
      • Direct messages are not encrypted. A DM is an ordinary Note with narrow addressing. Both ends’ servers store it in cleartext, and both admins can read it. Treat fedi DMs like email, because that is roughly the privacy model.
      • Authentication is de facto, not specified. The network runs on a years-old IETF draft. Key rotation, algorithm agility, and migration to the modern HTTP Message Signatures RFC are all active FEP territory precisely because the spec punted.
      • Your identity is rented from your domain. Handles are domain-bound. The Move dance migrates followers, not content, and it only works while your old server cooperates.
      • Federation is a trust graph, not a mesh. Instance-level blocks and allowlists shape who sees what. Two users on mutually blocking instances cannot interact, and that is a feature to the people who asked for it.

      None of these are fatal. All of them are worth knowing before you mistake the fediverse for a single website with many doors.

      Where to read more

      And if you want to watch your own server do all of this in real time: run an instance for a while. I moved my search stack to ParadeDB and rebuilt my fork as a patch stack, and both projects involved staring at exactly these payloads. The protocol is much less mysterious once you have watched a Follow arrive in your logs, signed, from a server in another hemisphere, and turned into a notification a second later.


      Related Posts


      Previous Post
      A Faster Cache Made My App Slower