Mastodon Automated Postings using the API
May 16, 2023 —
Gregg Szumowski
You can post to Mastodon using their API using cURL.
Create or Find Your Access Token
Once you have a Mastodon account, you need your account's access token. The steps you need to get that:
- Sign into your Mastodon account
- Click on In the
"Preferences"link. - On the bottom left corner of that page, click the
"Development"link. - On the
"Your Applications"page, click the blueNEW APPLICATIONbutton. - Give your application a name, and decide what kind of access you want to have when you connect to your account via the Mastodon API (i
read,write, andfolloware the defaults). You can always change this later. - At the bottom of the page, click the blue
SUBMITbutton. - You will be directed back to the
Your applicationspage, but now you should see your application name. Click that. - In your application's page, there are three tokens. For this tutorial, you need the
Your access tokenone. Note: if your access token is ever compromised, you can click regenerate, and your old access token will stop working, and you'll be shown a new one.
Post a Status Update using cURL
$ curl https://mastodon.sdf.org/api/v1/statuses -H 'Authorization: Bearer put-your-api-token-here' -F 'status=Hello, World'