Upsert a user and enroll them in a program

Create or update a user from matching criteria, then enroll them in a program as a draft, in a single call.

The user is searched with the match_by criteria, combined in AND.
If exactly one user matches, it is updated from user.
If none matches, a new user is created from user, completed by some match_by criteria. If one of the emails sent in user is already taken, the call is rejected with a 422 that says why.
If several users match, the call is rejected with a 409 and nothing is written.

A draft enrollment is then created on program_identifier. If the user is already enrolled on that program, the existing enrollment is returned instead of a duplicate.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params

Matching criteria, target program and user data

match_by
object
required

Criteria used to find the user, combined in AND. They describe the user as HeyTeam currently knows them: a value you want to change goes in user only, otherwise the search no longer finds the user. Sending only firstname and lastname can lead to a 409 if several users share the same name.

On creation, phone_number, date_of_birth and custom_field are written on the new user. date_of_birth and custom_field can only be set this way, and the phone number sent in user takes precedence. Names and emails come from user only: send the same values in both blocks so that the same match_by finds the user on the next calls. A criterion added in later calls will not match a user created without it.

integer
required

Identifier of the target program to enroll the user into.

user
object
required

User attributes used for creation or update.
On creation, firstname, lastname and at least one of professional_email or personal_email are required.
On update, every field provided in this block overwrites the current value on the matched user; fields absent from the payload are preserved as they are in the database.

Responses

Language
Credentials
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json