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

# Add a team user

> Assign a direct team role to an existing user.

> [!WARNING]
>
> This endpoint is experimental and may change or be removed without notice.


## OpenAPI

````yaml post /v1/teams/{team_id}/users
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/teams/{team_id}/users:
    parameters:
      - $ref: '#/components/parameters/team_id'
    post:
      summary: Adds a user to a team
      description: >-
        Gives the user a team role. Returns 409 when the user already has a team
        role on the team; to change it, update their team role instead.
        Organization admins have access to every team and can't be given a team
        role. Requires an organization admin. Temporary; may be removed once
        fine-grained access control is available.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTeamUserRequestV1'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamUserV1'
      x-codeSamples:
        - lang: bash
          source: |-
            curl --request POST \
            --url https://api.baseten.co/v1/teams/{team_id}/users \
            --header "Authorization: Bearer $BASETEN_API_KEY" \
            --data '{
              "user_id": "4kq2v9p",
              "team_role": "TEAM_VIEWER"
            }'
        - lang: python
          source: |-
            import requests
            import os
            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
            url = "https://api.baseten.co/v1/teams/{team_id}/users"

            headers = {"Authorization": f"Bearer {API_KEY}"}

            response = requests.request(
                "POST",
                url,
                headers=headers,
                json={'user_id': '4kq2v9p', 'team_role': 'TEAM_VIEWER'}
            )

            print(response.text)
components:
  parameters:
    team_id:
      schema:
        type: string
      name: team_id
      in: path
      required: true
  schemas:
    CreateTeamUserRequestV1:
      additionalProperties: false
      description: |-
        Request to add a user to a team.

        Temporary; may be removed once fine-grained access control is available.
      properties:
        user_id:
          description: ID of the user to add, from `GET /v1/users`
          examples:
            - 4kq2v9p
          title: User Id
          type: string
        team_role:
          $ref: '#/components/schemas/TeamRoleV1'
          description: Team role to give the user
      required:
        - user_id
        - team_role
      title: CreateTeamUserRequestV1
      type: object
    TeamUserV1:
      description: A user's access to a team.
      properties:
        team_id:
          description: Unique identifier of the team
          title: Team Id
          type: string
        team_name:
          description: Name of the team
          title: Team Name
          type: string
        user_id:
          description: Unique identifier of the user
          title: User Id
          type: string
        user_name:
          anyOf:
            - type: string
            - type: 'null'
          description: Name of the user, or their email address when they have no name
          title: User Name
        user_email:
          anyOf:
            - type: string
            - type: 'null'
          description: Email address of the user
          title: User Email
        direct_team_role:
          anyOf:
            - $ref: '#/components/schemas/TeamRoleV1'
            - type: 'null'
          description: >-
            Team role given to the user on this team; null when their access
            comes only from a directory group or from being an organization
            admin. Temporary; may be removed once fine-grained access control is
            available.
        effective_team_role:
          $ref: '#/components/schemas/TeamEffectiveRoleV1'
          description: >-
            Team role that applies: the strongest of the direct team role and
            the user's directory groups' team roles on this team, or `ADMIN` for
            an organization admin. Temporary; may be removed once fine-grained
            access control is available.
      required:
        - team_id
        - team_name
        - user_id
        - user_name
        - user_email
        - direct_team_role
        - effective_team_role
      title: TeamUserV1
      type: object
    TeamRoleV1:
      description: |-
        A team role a user can be given.

        Temporary; may be removed once fine-grained access control is available.
      enum:
        - TEAM_VIEWER
        - TEAM_MEMBER
        - TEAM_ADMIN
      title: TeamRoleV1
      type: string
    TeamEffectiveRoleV1:
      description: >-
        The team role that applies to a user, or `ADMIN` for an organization
        admin.


        Temporary; may be removed once fine-grained access control is available.
      enum:
        - TEAM_VIEWER
        - TEAM_MEMBER
        - TEAM_ADMIN
        - ADMIN
      title: TeamEffectiveRoleV1
      type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````