Bulk invite users?

(Alasdair Young) #1


Could someone please tell me how to bulk invite users to a private discourse forum? We have around 250 users on our main site and I’d like to take all their emails and invite them without having to manually invite each user to a topic individually.

Multiple invites on single topic?
(Sam Saffron) #2

Have a look at the samples in the Discourse api project.

(Alasdair Young) #3

From reading through, it looks like I’d need to send a post to send a POST
to example.com/t/1/invite.json

with the following post params:

api_username (maybe “forumadmin”? What should this be?)
email (email of user to invite)


(Camille Roux) #4

Maybe you could accept emails separated with coma in the email field for invitation (at least if it’s an admin)

(Alasdair Young) #5

When I try to post to that endpoint I get a “[Bad CSRF]” error. I read on
other threads that this was supposed to be fixed. Any ideas as to why it
isn’t working?

(Alasdair Young) #6

Also, when I manually try to “Invite friends to this topic”, I see a red circle with a cross in it when I try to click the email button. Is this some kind of rate limiting? If so, how do I turn it off?

(Sam Saffron) #7

Not sure if I support this, its not like you will be bulk inviting users all the time. One api call per user is not blocking anything.

2 possible reasons

  1. bad api_key
  2. you did not specify api_username

(Alasdair Young) #8

Any idea what the api username should be? I am using the “default” api key.

(Alasdair Young) #9

I have checked the API key and it looks fine.

Note that I am trying just a regular HTTP post to mywebsite.com -&nbspThis website is for sale! -&nbspmywebsite Resources and Information. - is that even the correct url to post to?

@sam any ideas? To reiterate: I’m not using the ruby API, this is just an http post.

(Kane York) #10

The combination of an API key and username replaces the combination of a CSRF token and a auth cookie.

The username you provide is the user that the action will be performed as.

(Alasdair Young) #11

Still no luck. Every time I try it I get a 403 back with “[‘BAD CSRF’]” as the message.

Some notes:

  1. I’m posting from my local machine to the discourse server. I am NOT on the server itself.
  2. The api key that was generated says it’s for “All Users”

Any other suggestions?

(Arpit Jalan) #12

Bulk Invite feature is now available! Try it out:

(Brian) #13

I tried to send a bulk invite about an hour ago (50 email addresses) but nothing seems to have happened. A notice came up that said it would let me know once complete but nothing so far.

API Functionality for invites
(Jeff Atwood) #14

Can you PM your bulk invite file to @techAPJ?

(Arpit Jalan) #15

Can you try sending out bulk invites again? I pushed some updates today, and I am sure your issue is resolved now. Also I have a bonus for you :tada:


You can now upload a list of emails (one email/line) in txt file directly, no need to mess with csv file anymore (if you don’t want to) :smile:

(Brian) #16

Thanks! I tested and it is working now :slight_smile: I received a PM from the system account saying “The bulk invite has been processed” and I see the invite emails sent in the log

(Jeff Atwood) closed #17