Mastodon Admin bulk domain-blocking via CURL

 Sun, 01 Jan 2023 20:11 UTC

Mastodon Admin bulk domain-blocking via CURL
Image: CC BY 4.0 by cybrkyd


Mastodon v4.0.2 does not yet have the ability to bulk-import domain blocks at a server level. This functionality is in the works and may be made available in a future release. For now, admins need to add domain blocks one-by-one. Ain’t nobody got time for that! Let’s bulk import using CURL.

Assumption #1

An application with admin permissions is loaded to allow API access. If not, go to Settings » Development and add one. I’ve given mine read write admin:read admin:write permissions. Obtain your access token which is conveniently named Your access token.

Assumption #2

You have a block list ready to load — all we need is the URL to be blocked. FediBlock by PaulaToThePeople is a good place to start.

Use CURL to send the domain to your instance. In the following example, we will be blocking the domain twitter.com with a full suspend and include a public comment.

curl 'https://my-instance.com/api/v1/admin/domain_blocks' \
    -H 'Authorization: Bearer xxxthis_is_where_you_have_your_access_tokenxxx' \
    -F 'domain=twitter.com' \
    -F 'severity=suspend' \
    -F 'public_comment=Testing'

For bulk uploads, use a bash script file, add as many of those as you need and execute.

Further reading: see admin/domain_blocks API methods