Cannot do create_invite nor send_invite via API
-
Hello. I've been using the API for some time to manage users in my Cloudron instance through a different application (our association members management app).
But now I find that cannot use the "create_invite" and "send_invite" calls, to generate a link for the users to log in after creation (as explained here https://docs.cloudron.io/api.html#tag/Users/paths/~1users~1{userId}~1create_invite/post).
The API call, even I use json format, replies with a html text like this:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST /api/v1/users/uid-13f7fac9-131e-4452-93c3-6d7762615e8c/create_invite</pre> </body> </html>
Sorry, no idea of what's happening here. This was working before, although I couldn't say when exactly it broke. I think the call we are making is correct.
Any clue? Thanks.
-
Actually the API has changed with v7, since the whole impersonation/invite/password reset area was reworked. Sorry we haven't updated the docs yet.
Will do this in a bit. For the meantime, essentially the routes are now:
GET '/api/v1/users/:userId/invite_link' -> 200 { inviteLink } POST '/api/v1/users/:userId/send_invite_email' with body { email: 'send@invite.to' } -> 202 {}
-
@nebulon thanks! I've been able to do it now, with these routes.
One question: I see that the send_invite_email has now a parameter to specify the email address to send the link. Is this mandatory? Or can I omit it, and have cloudron to use the primary email address of the user?
-
@andres-moya currently the email is mandatory. I don't quite remember right now if this was on purpose or just because the route was implemented mainly with the dashboard in mind.
I think it makes sense to have it optional and falling back to the user's email address then.
Also please note, that a user now mostly only has one email and optionally a password reset email address set.