Mastodon
  • What is Mastodon?
  • Using Mastodon
    • Signing up for an account
    • Setting up your profile
    • Posting toots
    • Using the network features
    • Dealing with unwanted content
    • Promoting yourself and others
    • Set your preferences
    • More settings
    • Using Mastodon externally
    • Moving or leaving accounts
    • Running your own server
  • Running Mastodon
    • Preparing your machine
    • Installing from source
    • Configuring your environment
    • Installing optional features
      • Full-text search
      • Hidden services
      • Single Sign On
    • Setting up your new instance
    • Using the admin CLI
    • Upgrading to a new release
    • Backing up your server
    • Migrating to a new machine
    • Scaling up your server
    • Moderation actions
    • Troubleshooting errors
      • Database index corruption
  • Developing Mastodon apps
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • Logging in with an account
    • Guidelines and best practices
    • Libraries and implementations
  • Contributing to Mastodon
    • Technical overview
    • Setting up a dev environment
    • Code structure
    • Routes
    • Bug bounties and responsible disclosure
  • Spec compliance
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
    • Bearcaps
  • REST API
    • OAuth Scopes
    • Rate limits
  • API Methods
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
    • timelines
      • conversations
      • lists
      • markers
      • streaming
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • announcements
    • proofs
    • oembed
  • API Entities
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Announcement
    • AnnouncementReaction
    • Application
    • Attachment
    • Card
    • Context
    • Conversation
    • Emoji
    • Error
    • FeaturedTag
    • Field
    • Filter
    • History
    • IdentityProof
    • Instance
    • List
    • Marker
    • Mention
    • Notification
    • Poll
    • Preferences
    • PushSubscription
    • Relationship
    • Report
    • Results
    • ScheduledStatus
    • Source
    • Status
    • Tag
    • Token

domain_blocks

View and update domain blocks.

get
Fetch domain blocks

https://mastodon.example/api/v1/domain_blocks

View domains the user has blocked.

Returns: Array of strings
OAuth: User token + read:blocks or follow
Version:
1.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>
Query Parameters
max_id
optional
string
Internal parameter. Use HTTP Link header from response for pagination.
since_id
optional
string
Internal parameter. Use HTTP Link header from response for pagination.
limit
optional
string
Maximum number of results to return per page. Defaults to 40. NOTE: Pagination is done with the Link header from the response.

Response

200: Success

Sample call with limit=2. Because domain ids are not public, you must parse the HTTP Link header to access next and previous pages.

Link: <https://mastodon.social/api/v1/domain_blocks?limit=2&max_id=16194>; rel="next", <https://mastodon.social/api/v1/domain_blocks?limit=2&since_id=16337>; rel="prev"

["nsfw.social","artalley.social"]

401: Unauthorized

Incorrect Authorization header

{
  "error": "The access token is invalid"
}

post
Block a domain

https://mastodon.example/api/v1/domain_blocks

Block a domain to:

  • hide all public posts from it
  • hide all notifications from it
  • remove all followers from it
  • prevent following new users from it (but does not remove existing follows)

Returns: n/a
OAuth: User token + ****write:blocks or follow
Version:
1.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>
Form Data Parameters
domain
required
string
Domain to block.

Response

200: Success

If the call was successful, an empty object will be returned. Note that the call will be successful even if the domain is already blocked or if the domain does not exist or if the domain is not a domain.

{}

401: Unauthorized

Incorrect Authorization header

{
  "error": "The access token is invalid"
}

422: Unprocessable Entity

If domain is not provided or contains spaces, the request will fail.

empty

{
  "error": "Validation failed: Domain can't be blank"
}
invalid
{
  "error": "Validation failed: Domain is not a valid domain name"
}

delete
Unblock a domain

https://mastodon.example/api/v1/domain_blocks

Remove a domain block, if it exists in the user’s array of blocked domains.

Returns: n/a
OAuth: User token + write:blocks or follow
Version history:
1.4.0 - added

Request

Headers
Authorization
required
string
Bearer <user token>
Form Data Parameters
domain
required
string
Domain to unblock.

Response

200: Success

If the call was successful, an empty object will be returned. Note that the call will be successful even if the domain was not previously blocked.

{}

401: Unauthorized

Incorrect Authorization header

{
  "error": "The access token is invalid"
}

422: Unprocessable Entity

If domain is not provided or contains spaces, the request will fail.

empty

{
  "error": "Validation failed: Domain can't be blank"
}
invalid domain
{
  "error": "Validation failed: Domain is not a valid domain name"
}

Last updated December 27, 2020 · Improve this page

Sponsored by

Dotcom-Monitor LoadView Stephen Tures Swayable

Join Mastodon · Blog · ·

View source · CC BY-SA 4.0 · Imprint