Setup a bot on gotosocial

First, create a user

Because I closed registration this has to be done via the cli. Commands for my instance running on fly.io:
# create account
/app/gotosocial --config-path /app/config.yaml admin account create --username some_username --email some_email@whatever.org --password 'SOME_PASSWORD'

# activate account
/app/gotosocial --config-path /app/config.yaml admin account confirm --username some_username

Setup Account

Most settings of an account can be changed via the user panel in gotosocial. But not the bot=true setting.
For automation we need an app anyway, so lets create an app and use it to change user settings.

To get the accesstoken the easiest way is to use this site: https://takahashim.github.io/mastodon-access-token/. Set the scope to write!
For the following commands we only need the access_token and not the client_id/client_secret.
The command to set bot=true, locked=false, display_name and note:
curl -X PATCH https://fedi.cress.space/api/v1/accounts/update_credentials -H 'Authorization: Bearer ACCESS_TOKEN' -F 'bot=true' -F 'locked=false' -F 'display_name=test user' -F 'note=some note'

Send a toot

Three ways to send a status: curl, httpie or python-requests.

Please be aware of the visibility rules on your server!
Some servers don't want bots on the local timeline, so use unlisted instead of public.
My examples here are set to private. This is only to show how posting a status works.

curl

curl https://fedi.cress.space/api/v1/statuses -H 'Authorization: Bearer ACCESS_TOKEN' -F 'status=toot via curl (private)' -F 'visibility=private'

httpie

http POST https://fedi.cress.space/api/v1/statuses 'Authorization: Bearer ACCESS_TOKEN' 'status=toot via httpie (private)' 'visibility=private'

python-requests

import requests

requests.post(
    url="https://fedi.cress.space/api/v1/statuses",
    headers={
        "Authorization": "Bearer ACCESS_TOKEN"
    },
    json={"status": "toot via requests (private)", "visibility": "private"},
)

The same code should work with httpx: replace requests with httpx.