Post anonymously via API?

Hi,

Is it possible to post anonymously via API? I’m browsing through API doc but can’t find how to do so.

Thanks.

4 Likes

Hmm… First time I am seeing this, but I believe it will be possible, but require a 2-step. So you’d first enable anonymous mode via the API, then post using the anonymous account via the API.

You might need to do some trial and error to figure it out, see How to reverse engineer the Discourse API for some tips.

2 Likes

Yes, you can post anonymously via the API. You will either have to use an “all users” api key or a “user specific” api key for the actual anonymous username, not the original username of the user.

curl -i -sS -X POST "http://localhost:3000/posts.json"  \
-H "Content-Type: multipart/form-data;"  \
-H "Api-Key: 48656cfb5197594c71525452e78a403208c4d1a123f60408b765d9c6bd1a9450"  \
-H "Api-Username: anonymous1"  \
-F "title=b5d39ea5124 4684a27917c d1b81ea2e9e"  \
-F "raw=6d9392121129f0ce504583d74e056f5d fe4cf67228216d302509deeca33f0ebc 690106384b6a4204151572e9d4e9da45"

HTTP/1.1 200 OK
6 Likes

Thanks for the response.
Is there anyway that the admin knows who has posted the anonymous post?

1 Like

I don’t think that info is exposed in the UI anywhere. Looks like you can use a data explorer query though:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.