Is it possible to automatically create a SMS login user via people api?

,

Is it possible to automatically create a login user via the people api?
We tried to mimic the person form auto user creation by adding the following snippet to the JSON payload sent to the /api/v1/people api:

"user_for_contact": {
    "create": true
}

The hope was that it would, since it seems to be the case with the xlsx form, automatically create a SMS login user.
Unfortunately, it did not yield the same result. Is there perhaps something we’re missing?

It would be advantageous not to make an additional request and create the login info ourselves by using the create-many-users and login-by-sms.

Hi @robinmurphy

Can you please share the reasons for not using the users api: API to interact with CHT Applications | Community Health Toolkit

You can use this to create the associated person and/or place or associate with existing person/place. Enabling login-by-sms just requires changing a field in the user definition.
I would definitely recommend using the dedicated API instead of relying on an implementation detail.

Hi @diana

I totally missed that the /api/v2/users api can be used for person creation as well, not just linking.
Thank you for pointing that out!
That combined with the 'token_login': True, satisfies the requirement.

2 Likes