"BAD CSRF" when executing PUT using API, curl, and PHP

You need to put the Api-Key and Api-Username values in the request header. There’s a curl example near the end of this topic that could be helpful: Sync DiscourseConnect user data with the sync_sso route.