MM messages from CLI

Ah, OK - that’s a bit more complicated now.
You need to first create a direct message channel with this specific user. To do that, use the CreateDirectChannel API Call.
The return value of this call will be the channel ID to post to. You can always run the CreateDirectChannel call, if the channel already exists, it will return the ID for you.

Example User ID td6fsn7ow7y9mjc1c6okhpk8ie wants to send to User ID bxsn57fc4inpjg6n89hgxxburw:

curl -H "Authorization: Bearer <yourtoken>" -X POST https://mm.yourdomain.com/api/v4/channels/direct -d '[ "td6fsn7ow7y9mjc1c6okhpk8ie", "bxsn57fc4inpjg6n89hgxxburw" ]'
{"id":"nsschcqxajgtdkdymgq55qidto","create_at":1663939493000,"update_at":1663939493000,"delete_at":0,"team_id":"","type":"D","display_name":"","name":"bxsn57fc4inpjg6n89hgxxburw__td6fsn7ow7y9mjc1c6okhpk8ie","header":"","purpose":"","last_post_at":1663939514017,"total_msg_count":1,"extra_update_at":0,"creator_id":"td6fsn7ow7y9mjc1c6okhpk8ie","scheme_id":null,"props":null,"group_constrained":null,"shared":false,"total_msg_count_root":1,"policy_id":null,"last_root_post_at":1663939514017}

The resulting ID nsschcqxajgtdkdymgq55qidto can then be used in the next call to post the message:

curl -H "Authorization: Bearer <yourtoken>" -X POST https://mm.yourdomain.com/api/v4/posts -d '{ "channel_id": "nsschcqxajgtdkdymgq55qidto", "message": "test" }'