Invite User Endpoint
POST /admin/projects/:projectId/invite
Invite a new user to the project. This will perform the following actions:
- Search for an existing user with the provided 
email, if given - Search for an existing profile resource (
Patient,Practitioner, orRelatedPerson) - Create a new 
User, if no existingUserwas found,- Set the password if 
passwordis given - Generate a password reset url
 
 - Set the password if 
 - Create a new profile resource, if no existing profile was found
 - Create a corresponding 
ProjectMembershipresource, for the (user, profile) pair - Send an invite email, if 
sendEmailistrue 
Parameters
{
  resourceType: 'Patient' | 'Practitioner' | 'RelatedPerson';
  firstName: string;
  lastName: string;
  email?: string;
  externalId?: string;
  password?: string;
  sendEmail?: boolean;
  membership?: Partial<ProjectMembership>;
}
| parameter | description | 
|---|---|
resourceType | The User's profile resourceType | 
firstName, lastName | The first and last names that will be assigned to user's profile resource. Ignored if a profile resource already exists | 
email | The email address assigned to the User. Used to identify users within each project | 
externalId | The unique id provided by external identity provider (if applicable). See Using External Ids | 
password | The User's password | 
sendEmail | If true, send an invite email to the user. If self-hosting, see our guide on setting up SES | 
membership | Used to override any fields of the resulting ProjectMembership resource. Common use cases include: 
  | 
Constraints
- Either 
emailorexternalIdis required. 
Examples
Inviting a Practitioner
- Typescript
 - CLI
 - cURL
 
await medplum.post('admin/projects/:projectId/invite', {
  resourceType: 'Practitioner',
  firstName: 'George',
  lastName: 'Washington',
  email: 'dr.gw@example.gov',
  password: 'lib3rty0rDe4th!',
});
medplum post admin/projects/:projectId/invite \
'{
  "resourceType": "Practitioner",
  "firstName": "George",
  "lastName": "Washington",
  "email": "dr.gw@example.gov",
  "membership": {
    "admin": true
  }
}'
curl https://api.medplum.com/admin/projects/:projectId/invite \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "resourceType": "Practitioner",
  "firstName": "George",
  "lastName": "Washington",
  "email": "dr.gw@example.gov",
  "membership": {
    "admin": true
  }
}'
Example Response:
Returns the ProjectMembership associated with the new user
{
  resourceType: 'ProjectMembership',
  id: ':id',
  admin: true,
  project: {
    reference: 'Project/:projectId',
  },
  user: {
    reference: 'User/:userId',
    display: 'dr.gw@example.gov'
  },
  profile: {
    reference: 'Practitioner/:practitionerId',
    display: 'George Washington'
  },
}
Inviting a Patient
- Typescript
 - CLI
 - cURL
 
await medplum.post('admin/projects/:projectId/invite', {
  resourceType: 'Patient',
  firstName: 'George',
  lastName: 'Washington',
  email: 'patient.gw@example.gov',
  password: 'lib3rty0rDe4th!',
});
medplum post admin/projects/:projectId/invite \
'{
  "resourceType": "Patient",
  "firstName": "George",
  "lastName": "Washington",
  "email": "patient.gw@example.gov",
  "password: "lib3rty0rDe4th!"
}'
curl https://api.medplum.com/admin/projects/:projectId/invite \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "resourceType": "Patient",
  "firstName": "George",
  "lastName": "Washington",
  "email": "patient.gw@example.gov",
  "password: "lib3rty0rDe4th!"
}'
Example Response:
Returns the ProjectMembership associated with the new user
{
  resourceType: 'ProjectMembership',
  id: ':id',
  admin: true,
  project: {
    reference: 'Project/:projectId'
  },
  user: {
    reference: 'User/:userId',
    display: 'patient.gw@example.gov'
  },
  profile: {
    reference: 'Patient/:patientId',
    display: 'George Washington'
  }
}