Creating a staged user with an API call

I don’t think they can. They would have to register and update their preferences on that topic or their overall notification preferences.

2 Likes

Are there some docs about this endpoint? I have searched API docs but it is not there.

I am looking for a way how to create topic and assign it to a specific user (by discourse-assign plugin).

And also thinking if API key have to by for user system or I can use some other user with minimal permissions (what are that minimal required?).

Just this post: Creating a staged user with an API call - #8 by blake

This is totally doable. Have a look at Reverse engineer the Discourse API and you will see which endpoint the discourse-assign plugin calls.

Nope does not need to be with the system user. You just need a user with enough trust level to create and assign topics.

Thank you for reply. I understand how to assign specific post, but how to reliably find post just created by the /admin/email/handle_mail endpoint? It also seems to queue received calls, so I will not always find it immediately after the first call.

Correct, that endpoint does not return a topic_id.

Do they HAVE to be staged users? Couldn’t you just create the user via the api and then create a topic? Or are people that don’t have accounts yet going to be emailing that endpoint?

It is for public contact form on different products where each have different merchant. I want to assign topic to the specific merchant and also deny access to topics what does not belong to that merchant.

I have a question from a non-devleoper’s perspective.

I’m using Discourse as our company’s ticket system and I have it set up successfully to create new topics from non-registered users in our support forum.

Occasionally, I need to create a ticket on behalf of a customer instead of them creating it directly.

Is there an easy step by step way to do this and create a topic on behalf of someone that does not already have an account on the forum? I don’t want them to have a full account unless they sign up for one themselves.

1 Like

I would try creating a topic via incoming email:

This way a staged user will be created on topic creation.

You could create the staged user via the api

curl -i -sS -X POST "http://localhost:4200/users"  \
-H "Content-Type: multipart/form-data"  \
-H "Api-Key: 3e8aa0b7970cf010da24d06215fdc7b3951352c61a59ada70f5f36b4ce890bb2"  \
-H "Api-Username: system"  \
-F "name=2e6ac3603"  \
-F "active=false"  \
-F "staged=true"  \
-F "username=2e6ac3603"  \
-F "email=2e6ac3603@example.com"  \
-F "password=f9b4c3c7ebd1c2877a0ad659be6ca83e"

and then create the topic for the user but, on the user create action discourse will then send an activation email:

{“success”: true,“active”: false,“message”: “You’re almost done! We sent an activation mail to 2e6ac3603@example.com. Please follow the instructions in the mail to activate your account.If it doesn’t arrive, check your spam folder.”}

So are each of these lines separated by a CR at the end? And is there a double space, or a tab before each back-slash?
Sorry, like I said, I’m not a dev so just showing this code isn’t quite enough to get me over the finish line without a little extra info.

So using this method just creates the user, but even though staged=true it sends out the e-mail invite?

The easiest answer is always the best:

So we’ll be using that for our occasional needs.
Thanks for the help.

2 Likes