Skip to main content

Verified against W3C ActivityPub REC §3-5, Activity Streams 2.0 Core and Vocabulary, Mastodon v4.7.3 source (create.rb, status_parser.rb, context_helper.rb) on 2026-10-15.

Core Concepts

Before diving into implementation, you need to understand the fundamental building blocks of ActivityPub. Everything in the protocol revolves around four core concepts: Actors, Activities, Objects, and Collections.

The ActivityPub Model​

ACTOR(Person, Organization, Application, Service, Group)ActorActivityObjectperformstargetsCollectionsinbox • outbox • followers • following • liked

Actors​

An Actor is any entity that can perform activities. In social networking terms, actors are typically users, but they can also be bots, organizations, or services.

Actor Types​

TypeDescriptionExample
PersonA human user@alice@example.com
OrganizationA company or group@acme-corp@example.com
ApplicationA software applicationMastodon's server-wide "instance actor"
ServiceA service of any kind@weather-bot@example.com — Mastodon publishes bot accounts as Service
GroupA shared actor for communities@developers@example.com

Actor Properties​

Every actor has these essential properties:

{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1"
],
"type": "Person",
"id": "https://example.com/users/alice",
"inbox": "https://example.com/users/alice/inbox",
"outbox": "https://example.com/users/alice/outbox",
"followers": "https://example.com/users/alice/followers",
"following": "https://example.com/users/alice/following",
"preferredUsername": "alice",
"name": "Alice Smith",
"summary": "Software developer and Fediverse enthusiast",
"publicKey": {
"id": "https://example.com/users/alice#main-key",
"owner": "https://example.com/users/alice",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n..."
}
}

Actor Endpoints​

ActivityPub §4.1 says actors MUST have inbox and outbox, SHOULD have followers and following, and MAY have liked.

EndpointRequirementPurpose
inboxMUSTReceives incoming activities from other servers
outboxMUSTContains activities performed by this actor
followersSHOULDCollection of actors following this actor
followingSHOULDCollection of actors this actor follows
likedMAYCollection of objects this actor has liked

In practice, Mastodon rejects an actor that has neither preferredUsername nor a FEP-2c59 webfinger property (fetch_remote_actor_service.rb), and it needs a public key to verify your signed requests.

Activities​

An Activity represents an action. When an actor does something — posts a message, follows someone, likes a post — that action is represented as an Activity.

Common Activity Types​

ActivityDescriptionExample
CreateCreate new contentPosting a new status
UpdateModify existing contentEditing a post
DeleteRemove contentDeleting a post
FollowSubscribe to an actorFollowing a user
AcceptAccept a requestAccepting a follow request
RejectReject a requestRejecting a follow request
LikeExpress appreciationLiking a post
AnnounceShare contentBoosting/reblogging
UndoReverse an activityUnfollowing, unliking

Activity Structure​

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"id": "https://example.com/activities/1",
"actor": "https://example.com/users/alice",
"object": {
"type": "Note",
"id": "https://example.com/notes/1",
"content": "Hello, Fediverse!"
},
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/users/alice/followers"]
}

Activity Properties​

PropertyRequiredDescription
idYes, except for transient activities (AP §3.1)Globally unique URL
typeYesThe type of activity
actorYes in practice — servers reject activities without oneWho performed the activity
objectUsuallyThe target of the activity
toNoPrimary recipients
ccNoSecondary recipients
btoNoPrivate primary recipients
bccNoPrivate secondary recipients

Objects​

An Object represents content or things that activities act upon. The most common objects are content types like notes, articles, and images.

Common Object Types​

TypeDescriptionUse Case
NoteShort text contentMastodon statuses, tweets
ArticleLong-form contentBlog posts
ImageImage contentPhotos
VideoVideo contentVideo posts
AudioAudio contentPodcasts, music
DocumentGeneric fileAttachments
EventCalendar eventMeetups, events
PlaceLocationCheck-ins

Object Structure​

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Note",
"id": "https://example.com/notes/1",
"attributedTo": "https://example.com/users/alice",
"content": "Hello, Fediverse!",
"published": "2024-01-15T10:30:00Z",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/users/alice/followers"]
}

Important Object Properties​

PropertyDescription
idUnique identifier (URL)
typeThe object type
attributedToThe creator/author
contentThe main content (HTML)
publishedWhen it was created
updatedWhen it was last modified
inReplyToParent object (for replies)
attachmentMedia attachments
tagHashtags, mentions

Collections​

A Collection is an ordered or unordered set of objects or activities. Collections are used for inboxes, outboxes, followers lists, and more.

Collection Types​

TypeDescription
CollectionUnordered set
OrderedCollectionOrdered set. ActivityPub requires inbox and outbox to be in reverse chronological order (§5.1, §5.2)
CollectionPageA page within a collection
OrderedCollectionPageAn ordered page

Collection Structure​

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollection",
"id": "https://example.com/users/alice/outbox",
"totalItems": 42,
"first": "https://example.com/users/alice/outbox?page=1",
"last": "https://example.com/users/alice/outbox?page=3"
}

Collection Page​

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollectionPage",
"id": "https://example.com/users/alice/outbox?page=1",
"partOf": "https://example.com/users/alice/outbox",
"next": "https://example.com/users/alice/outbox?page=2",
"orderedItems": [
{ "type": "Create", "..." : "..." },
{ "type": "Announce", "..." : "..." }
]
}

Addressing and Visibility​

ActivityPub uses to, cc, bto, and bcc properties to control who sees content.

Special Addresses​

AddressMeaning
https://www.w3.org/ns/activitystreams#PublicVisible to everyone (also written as:Public or Public)
The actor's followers collectionVisible to followers

Only the Public collection is truly special. The followers collection is just the IRI in the actor's followers property — read it from the actor rather than assuming it's {actor}/followers.

Visibility Examples​

Public post:

{
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/users/alice/followers"]
}

Followers-only post:

{
"to": ["https://example.com/users/alice/followers"],
"cc": []
}

Direct message:

{
"to": ["https://other.example/users/bob"],
"cc": [],
"tag": [
{
"type": "Mention",
"href": "https://other.example/users/bob",
"name": "@bob@other.example"
}
]
}

Include a Mention tag for every addressed actor. If Mastodon receives a non-public post addressed to someone who isn't tagged, it records a silent mention and downgrades the post from direct to limited (create.rb).

JSON-LD Context​

ActivityPub uses JSON-LD for extensibility. The @context tells parsers how to interpret the JSON.

{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"toot": "http://joinmastodon.org/ns#",
"sensitive": "as:sensitive"
}
]
}
tip

You can extend ActivityStreams with custom properties by adding them to the context. This is how Mastodon adds features like the sensitive media flag and custom emoji. (The content-warning text itself goes in the standard summary property.)

Next Steps​

Now that you understand the core concepts:

  1. Your First ActivityPub Server - Put these concepts into practice
  2. ActivityStreams Reference - Complete vocabulary reference
  3. Object Types Reference - All object types with examples