Skip to main content

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 bot or automated service@weather-bot@example.com
ServiceA software service@relay@example.com
GroupA shared actor for communities@developers@example.com

Actor Properties​

Every actor has these essential properties:

{
"@context": "https://www.w3.org/ns/activitystreams",
"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..."
}
}

Required Actor Endpoints​

EndpointPurpose
inboxReceives incoming activities from other servers
outboxContains activities performed by this actor

Optional Actor Endpoints​

EndpointPurpose
followersCollection of actors following this actor
followingCollection of actors this actor follows
likedCollection of objects this actor has liked

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
typeYesThe type of activity
actorYesWho 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 (newest first)
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
{actor}/followersVisible to 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": []
}

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 content warnings (sensitive) and custom emoji.

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