Programmatically Post to Mastodon with Make

📣
I use Make (formerly Integromat) for my personal, creator, and business automation needs and am an affiliate. If you sign up using my affiliate link, you get one month of the Pro plan for free.
There don't appear to be any social-media schedulers that support Mastodon yet,1 although there are a couple cross-posters to/from Twitter. If, however, you need to programmatically post to Mastodon through some service like Make or Zapier, Mastodon conveniently has an API that you can use.

Set up an Access Token

  1. Create an application at https://[YOUR MASTODON SERVER]/settings/applications by clicking on New Application.
  2. Set the Application Name, don't change the Redirect URI, and under Scopes check write:statuses and if you want to attach images write:media. You can uncheck the rest.

Once that is created, the application should now give you a Client key, Client secret, and Your access token. You only need the last.

Post a Status

If you're setting up some sort of automation service, the module you're looking for will be HTTP in Make, the POST webhook in Zapier, or webhook in IFTTT.

Skip the next section if you don't need to attach media to your status, but even if I'm sharing a link, I prefer to attach an image over using the Mastodon link preview.

Step 1. Upload media

Make a POST call to:

Loading...
https://[YOUR MASTODON SERVER]/api/v1/media?access_token=[YOUR ACCESS TOKEN]

Set the type to multipart/form-data and attach your image (not an image URL) to the file field.

My Mastodon publishing workflow on Make
My Mastodon publishing workflow on Make

If like me you only have access to an image URL in your workflow, you'll also need to do some sort of file fetch. Make conveniently has a 'Get a file' module for just such an occasion.

This call will return an object containing a media id that you will need for the next step.

More info: Documentation for the /media endpoint on Mastodon.

Step 2. Post the status

Make a POST call to:

Loading...
https://[YOUR MASTODON SERVER]/api/v1/statuses?access_token=[YOUR ACCESS TOKEN]

Set the type to application/x-www-form-urlencoded and pass the status field containing your status message. If you are attaching an image as well, pass the media_ids[] field with the media id you retrieved in the previous step.

More info: Documentation for the /statuses endpoint on Mastodon.


Footnotes

  1. Update 2023-02-10 Buffer does now, which is lovely. ↩

Published January 1, 2023