How to programmatically activate a user through the API
I am struggling with a problem currently, which is the following:
I have the option to create a user with emailVerified and password to set him as Activated.
But
If I don't create a user already as activated...I find no way to programmatically Activate a user and set his/her password from the API.
I have tried the following:
Try to programmatically go through the invitation process
v2/users/:userId/invite_code - I get "User is already initialized (COMMAND-EF34g)"
Try to initiate v2 password change by getting returnCode in the API v2/users/:userId/password_reset - "User is not yet initialized (COMMAND-Sfe4g)" (The opposite error of the above for the same user with the same state) Try to set the initial password from the v1 API /management/v1/users/:userId/password/_initialize - "User is not yet initialized (COMMAND-M9dse)" Try to set the password from the v1 API /management/v1/users/:userId/password - "User is not yet initialized (COMMAND-M9dse)" I even saw that there is a /resources/v3alpha/users/{id}/_activate options but I haven't tested it as I wouldn't want to use an experimental endpoint that might break Please I would appreciate any help this topic, as I seem to be out of options
Try to initiate v2 password change by getting returnCode in the API v2/users/:userId/password_reset - "User is not yet initialized (COMMAND-Sfe4g)" (The opposite error of the above for the same user with the same state) Try to set the initial password from the v1 API /management/v1/users/:userId/password/_initialize - "User is not yet initialized (COMMAND-M9dse)" Try to set the password from the v1 API /management/v1/users/:userId/password - "User is not yet initialized (COMMAND-M9dse)" I even saw that there is a /resources/v3alpha/users/{id}/_activate options but I haven't tested it as I wouldn't want to use an experimental endpoint that might break Please I would appreciate any help this topic, as I seem to be out of options
4 Replies
hey @pbechliv apologies for the delay, were you able to fix it?.
Hey @Rajat Singh I haven't found a solution to this problem, is there any suggestion on this issue?
Wouldn't that be
https://zitadel.com/docs/apis/resources/user_service_v2/user-service-send-email-code
https://zitadel.com/docs/apis/resources/user_service_v2/user-service-verify-email
ZITADEL Docs
Send code to verify user email
ZITADEL Docs
Verify the email with the generated code.
Thank you for the response @SaarPhil I will try it out