> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add users to teams

> Add one or more people to one or more teams. Every person in `users` is added to every team in `teams`. For people who already have a Prophecy account, set `createUser` to `false` and `invitationStatus` to `Accepted`; they join the team immediately. For new people, set `createUser` to `true` and omit `invitationStatus`; the same call creates their account.

## Add existing or new users

Choose the request shape based on whether each person already has a Prophecy account:

| Person | `createUser` | `invitationStatus` | Result |
| - | - | - | - |
| Already has an account | `false` | `Accepted` | They join the team immediately. |
| Does not have an account | `true` | Omit | Prophecy creates their account and adds it to the team. |

When you create users, `isRequesterGlobalAdmin` controls what happens next:

| `isRequesterGlobalAdmin` | What happens to the new person |
| - | - |
| `true` | They are invited and can use Prophecy as soon as they sign in. |
| `false` | The invitation waits until a Prophecy administrator approves it. |

Set `isRequesterGlobalAdmin` to `true` only if your account is a Prophecy administrator for the whole instance. The [get current user API](https://docs.prophecy.ai/api-reference/users/get-current-user.md) returns `ClusterAdmin` as the account `type` in that case.

If Prophecy sends email on your instance, new people also get an invitation email. The response's `emailResult` says whether one was sent.

To confirm that people joined a team, use the [get team members query](https://docs.prophecy.ai/api-reference/teams/get-team-members.md).

## Troubleshoot team invitation failures

A response with `"success": false` and `N team invitation failures` means that many people were not added. The response does not say why. It is one of these causes:

| Cause | Fix |
| - | - |
| The person has no Prophecy account and `createUser` is `false`. | Invite them with `"createUser": true`. |
| No team has exactly that name, for example because a team ID was sent. | Use the team's exact name. |
| Your account is not an admin of that team. | Ask a team admin to add them, or to make you an admin. |
| Prophecy could not add the member. | Try again. If it keeps failing, contact Prophecy support. |

> [!NOTE]
>
> `Invite registration failed` in the message is a different error. The account was created, but
> Prophecy's seat registration did not accept it. Ask your Prophecy administrator about available
> seats.


## OpenAPI

````yaml post /api/auth/inviteUsers
openapi: 3.0.3
info:
  title: Prophecy API - Users
  description: API for retrieving user details and adding users to teams
  version: 1.0.0
servers: []
security: []
paths:
  /api/auth/inviteUsers:
    parameters:
      - name: X-AUTH-TOKEN
        in: header
        description: Prophecy access token
        required: true
        schema:
          type: string
    post:
      tags:
        - Users
      summary: Add users to teams
      description: >-
        Add one or more people to one or more teams. Every person in `users` is
        added to every team in `teams`. For people who already have a Prophecy
        account, set `createUser` to `false` and `invitationStatus` to
        `Accepted`; they join the team immediately. For new people, set
        `createUser` to `true` and omit `invitationStatus`; the same call
        creates their account.
      operationId: inviteUsers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                users:
                  type: array
                  description: One entry per person.
                  items:
                    type: object
                    properties:
                      emailID:
                        type: string
                        description: Email address the person signs in to Prophecy with.
                      invitationStatus:
                        type: string
                        enum:
                          - Accepted
                        description: >-
                          Send `Accepted` with `createUser: false`. Omit it with
                          `createUser: true`; Prophecy sets it from
                          `isRequesterGlobalAdmin`.
                      createUser:
                        type: boolean
                        description: >-
                          `false` if the person already has an account. `true`
                          to create one. With `false`, someone without an
                          account is not added.
                teams:
                  type: array
                  items:
                    type: string
                  description: One or more team names (not team IDs).
                isAdmin:
                  type: boolean
                  description: '`true` makes the people team admins as well as members.'
                seatsRequested:
                  type: integer
                  description: >-
                    Leave as `0` unless your Prophecy administrator gives you a
                    number of seats to request.
                isRequesterGlobalAdmin:
                  type: boolean
                  description: >-
                    Whether your account is a Prophecy administrator for the
                    whole instance (account type `ClusterAdmin`). When creating
                    users, `true` means invited people can use Prophecy as soon
                    as they sign in, and `false` means the invitation waits
                    until a Prophecy administrator approves it. Leave as `false`
                    when adding people who already have an account.
            examples:
              existing:
                summary: Add people who already have an account
                value:
                  users:
                    - emailID: user@example.com
                      invitationStatus: Accepted
                      createUser: false
                  teams:
                    - analytics_team
                  isAdmin: false
                  seatsRequested: 0
                  isRequesterGlobalAdmin: false
              new:
                summary: Invite new people
                value:
                  users:
                    - emailID: new.user@example.com
                      createUser: true
                  teams:
                    - analytics_team
                  isAdmin: false
                  seatsRequested: 0
                  isRequesterGlobalAdmin: true
      responses:
        '200':
          description: Invitation results
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Indicates whether all invitations succeeded.
                  message:
                    type: string
                    description: >-
                      Summary of the outcome, for example `1 invitations
                      successful.` or `N team invitation failures`.
                  details:
                    type: object
                    properties:
                      totalUsers:
                        type: integer
                      totalTeams:
                        type: integer
                      totalPossibleInvitations:
                        type: integer
                      attemptedInvitations:
                        type: integer
                      successfulInvitations:
                        type: integer
                      userCreationFailures:
                        type: integer
                      teamInvitationFailures:
                        type: integer
                      skippedInvitations:
                        type: integer
                      athenaCallResult:
                        type: string
                      emailResult:
                        type: string
                        description: >-
                          Whether an invitation email was sent. New people get
                          an invitation email only if Prophecy sends email on
                          your instance.
                      seatsRequested:
                        type: integer
              example:
                success: true
                message: 1 invitations successful.
                details:
                  totalUsers: 1
                  totalTeams: 1
                  totalPossibleInvitations: 1
                  attemptedInvitations: 1
                  successfulInvitations: 1
                  userCreationFailures: 0
                  teamInvitationFailures: 0
                  skippedInvitations: 0
                  athenaCallResult: <RESULT>
                  emailResult: <RESULT>
                  seatsRequested: 0

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.