Vijil Teams API

Authentication, users, and team management

OpenAPI Specification

vijil-teams-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Vijil Console API (Combined) agent-configurations Teams API
  description: Combined OpenAPI specification for all vijil-console microservices.
  version: 0.1.0
tags:
- name: Teams
  description: Authentication, users, and team management
paths:
  /v1/auth/jwt/login:
    post:
      tags:
      - Teams
      summary: Jwt Login
      description: "Authenticate with email + password, sets JWT token in httpOnly cookie.\n\nArgs:\n    login_request: Login credentials (email and password)\n    response: FastAPI response object to set cookies\n    user_manager: FastAPI Users user manager\n\nReturns:\n    JWT token response with access_token and token_type (token also set in httpOnly cookie)\n\nRaises:\n    HTTPException: If authentication fails"
      operationId: jwt_login_v1_auth_jwt_login_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Jwt Login V1 Auth Jwt Login Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/auth/jwt/logout:
    post:
      tags:
      - Teams
      summary: Jwt Logout
      description: "Logout user by clearing the authentication cookie.\n\nArgs:\n    response: FastAPI response object to clear cookies\n\nReturns:\n    Success message"
      operationId: jwt_logout_v1_auth_jwt_logout_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Jwt Logout V1 Auth Jwt Logout Post
  /v1/auth/users/me:
    get:
      tags:
      - Teams
      summary: Get Current User Info
      description: "Get the currently authenticated user's information.\n\nArgs:\n    current_user: Current authenticated user (from JWT claims)\n\nReturns:\n    Current user information"
      operationId: get_current_user_info_v1_auth_users_me_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRead'
  /v1/auth/jwt/refresh:
    post:
      tags:
      - Teams
      summary: Jwt Refresh
      description: "Refresh JWT token.\n\nAccepts a valid or expired JWT token and returns a new token with\nfresh expiration. The token can be provided in a cookie or Authorization header.\n\nArgs:\n    request: FastAPI request object\n    response: FastAPI response object to set cookies\n    user_manager: FastAPI Users user manager\n    session: Database session\n\nReturns:\n    JWT token response with access_token and token_type (also sets cookie)\n\nRaises:\n    HTTPException: If token is invalid or user not found"
      operationId: jwt_refresh_v1_auth_jwt_refresh_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Jwt Refresh V1 Auth Jwt Refresh Post
  /v1/auth/change-password:
    post:
      tags:
      - Teams
      summary: Change Password
      description: "Change the current user's password.\n\nVerifies the current password, updates to the new password,\nclears the password_change_required flag, and returns a fresh JWT.\n\nArgs:\n    request: Change password request with current and new passwords\n    response: FastAPI response object to set cookies\n    claims: JWT claims from middleware\n    user_manager: FastAPI Users user manager\n    session: Database session\n\nReturns:\n    JWT token response with access_token and token_type\n\nRaises:\n    UnauthenticatedException: If current password is invalid\n    BadRequestException: If new password is same as current or invalid"
      operationId: change_password_v1_auth_change_password_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangePasswordRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Change Password V1 Auth Change Password Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/users/:
    post:
      tags:
      - Teams
      summary: Create User
      description: 'Create a new user.


        Requires team:write_user permission for the specified team (team owners and admins) or

        team:write_user_all permission (super admin).'
      operationId: create_user_v1_users__post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRead'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    get:
      tags:
      - Teams
      summary: Get User
      description: 'Get a user by query parameters.


        Currently supports:

        - email: Get user by email address


        Additional query parameters can be added in the future.'
      operationId: get_user_v1_users__get
      parameters:
      - name: email
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Email address of the user to retrieve
          title: Email
        description: Email address of the user to retrieve
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRead'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/users/me:
    get:
      tags:
      - Teams
      summary: Get Current User
      description: 'Get the current authenticated user''s information.


        Returns the user information for the authenticated user based on JWT claims.'
      operationId: get_current_user_v1_users_me_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRead'
  /v1/users/me/teams:
    get:
      tags:
      - Teams
      summary: Get My Teams
      description: 'Get the current user''s team memberships.


        Returns all teams the authenticated user is a member of, along with

        their role, name, and description.'
      operationId: get_my_teams_v1_users_me_teams_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/MembershipWithTeam'
                type: array
                title: Response Get My Teams V1 Users Me Teams Get
  /v1/users/{user_id}:
    get:
      tags:
      - Teams
      summary: Get User By Id
      description: Get a user by ID.
      operationId: get_user_by_id_v1_users__user_id__get
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: User Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserRead'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/teams/:
    post:
      tags:
      - Teams
      summary: Create Team
      description: 'Create a new team.


        Requires team:create_all permission (super admin only).'
      operationId: create_team_v1_teams__post
      parameters:
      - name: owner_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
          title: Owner Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TeamCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Team'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/teams/{team_id}/invites:
    post:
      tags:
      - Teams
      summary: Invite Users
      description: 'Invite a user to a team by email.


        Requires teams:invite permission (team owners and admins) or

        team:invite_all permission (super admin).'
      operationId: invite_users_v1_teams__team_id__invites_post
      parameters:
      - name: team_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Team Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InviteUserRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invitation'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/teams/invites/{invitation_id}/accept:
    post:
      tags:
      - Teams
      summary: Accept Invite
      description: 'Accept a team invitation.


        Only the target user (the one who was invited) can accept their invitation.

        The user_id and email come from the authenticated JWT token.'
      operationId: accept_invite_v1_teams_invites__invitation_id__accept_post
      parameters:
      - name: invitation_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Invitation Id
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Membership'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/teams/{team_id}/users:
    get:
      tags:
      - Teams
      summary: Get Team Users
      description: 'List all users in a team.


        Requires team:read permission (all team members) or

        team:read_all permission (super admin).'
      operationId: get_team_users_v1_teams__team_id__users_get
      parameters:
      - name: team_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Team Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TeamUser'
                title: Response Get Team Users V1 Teams  Team Id  Users Get
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v1/teams/{team_id}:
    get:
      tags:
      - Teams
      summary: Get Team
      description: 'Get a team by ID.


        Requires team:read permission (all team members) or

        team:read_all permission (super admin).


        Note: This route must come after more specific routes like /{team_id}/users

        to avoid route conflicts.'
      operationId: get_team_v1_teams__team_id__get
      parameters:
      - name: team_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Team Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Team'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    TeamRole:
      type: string
      enum:
      - OWNER
      - ADMIN
      - MEMBER
      title: TeamRole
      description: Team membership roles.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    TeamCreate:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        description:
          anyOf:
          - type: string
            maxLength: 1000
          - type: 'null'
          title: Description
      type: object
      required:
      - name
      title: TeamCreate
      description: Model for creating a new team.
    InvitationStatus:
      type: string
      enum:
      - PENDING
      - ACCEPTED
      - DECLINED
      - EXPIRED
      title: InvitationStatus
      description: Invitation status.
    UserRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        email:
          type: string
          format: email
          title: Email
        is_active:
          type: boolean
          title: Is Active
          default: true
        is_superuser:
          type: boolean
          title: Is Superuser
          default: false
        is_verified:
          type: boolean
          title: Is Verified
          default: false
        given_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Given Name
        family_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Family Name
        external_user_id:
          anyOf:
          - type: string
          - type: 'null'
          title: External User Id
        profile_image:
          anyOf:
          - type: string
            maxLength: 2083
            minLength: 1
            format: uri
          - type: 'null'
          title: Profile Image
        password_change_required:
          type: boolean
          title: Password Change Required
          default: false
        is_super_admin:
          type: boolean
          title: Is Super Admin
          default: false
      type: object
      required:
      - id
      - email
      title: UserRead
      description: Returned to clients when reading user info.
    LoginRequest:
      properties:
        email:
          type: string
          title: Email
        password:
          type: string
          title: Password
      type: object
      required:
      - email
      - password
      title: LoginRequest
      description: Login request model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Invitation:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        team_id:
          type: string
          format: uuid
          title: Team Id
        email:
          type: string
          title: Email
        invited_by:
          type: string
          format: uuid
          title: Invited By
        role:
          $ref: '#/components/schemas/TeamRole'
        status:
          $ref: '#/components/schemas/InvitationStatus'
        created_at:
          type: integer
          title: Created At
        expires_at:
          type: integer
          title: Expires At
      type: object
      required:
      - id
      - team_id
      - email
      - invited_by
      - role
      - status
      - created_at
      - expires_at
      title: Invitation
      description: Team invitation domains model.
    InviteUserRequest:
      properties:
        email:
          type: string
          minLength: 1
          title: Email
          description: Email address of the user to invite
        role:
          $ref: '#/components/schemas/TeamRole'
          description: Role to assign to the invited user
          default: MEMBER
      type: object
      required:
      - email
      title: InviteUserRequest
      description: Request model for inviting a user to a team (team_id comes from path).
    MembershipWithTeam:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        team_id:
          type: string
          format: uuid
          title: Team Id
        user_id:
          type: string
          format: uuid
          title: User Id
        role:
          $ref: '#/components/schemas/TeamRole'
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
        team_name:
          type: string
          title: Team Name
        team_description:
          anyOf:
          - type: string
          - type: 'null'
          title: Team Description
      type: object
      required:
      - id
      - team_id
      - user_id
      - role
      - created_at
      - updated_at
      - team_name
      - team_description
      title: MembershipWithTeam
      description: Team membership with team name and description.
    Team:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        description:
          anyOf:
          - type: string
            maxLength: 1000
          - type: 'null'
          title: Description
        created_by:
          type: string
          format: uuid
          title: Created By
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
      type: object
      required:
      - id
      - name
      - created_by
      - created_at
      - updated_at
      title: Team
      description: Team domains model.
    ChangePasswordRequest:
      properties:
        current_password:
          type: string
          title: Current Password
        new_password:
          type: string
          minLength: 8
          title: New Password
      type: object
      required:
      - current_password
      - new_password
      title: ChangePasswordRequest
      description: Request model for changing password.
    CreateUserRequest:
      properties:
        email:
          type: string
          format: email
          title: Email
          description: User email address
        password:
          type: string
          minLength: 8
          title: Password
          description: User password
        given_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Given Name
          description: User's given name
        family_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Family Name
          description: User's family name
        external_user_id:
          anyOf:
          - type: string
          - type: 'null'
          title: External User Id
          description: External user identifier
        profile_image:
          anyOf:
          - type: string
            maxLength: 2083
            minLength: 1
            format: uri
          - type: 'null'
          title: Profile Image
          description: URL to user's profile image
        team_id:
          type: string
          format: uuid
          title: Team Id
          description: ID of the team to assign the user to
        password_change_required:
          type: boolean
          title: Password Change Required
          description: Whether the user must change their password on first login
          default: true
      type: object
      required:
      - email
      - password
      - team_id
      title: CreateUserRequest
      description: Request model for creating a user with team assignment.
    TeamUser:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        email:
          type: string
          format: email
          title: Email
        given_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Given Name
        family_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Family Name
        external_user_id:
          anyOf:
          - type: string
          - type: 'null'
          title: External User Id
        profile_image:
          anyOf:
          - type: string
          - type: 'null'
          title: Profile Image
        is_active:
          type: boolean
          title: Is Active
        is_verified:
          type: boolean
          title: Is Verified
        is_super_admin:
          type: boolean
          title: Is Super Admin
          default: false
        role:
          $ref: '#/components/schemas/TeamRole'
        membership_id:
          type: string
          format: uuid
          title: Membership Id
        joined_at:
          type: integer
          title: Joined At
      type: object
      required:
      - id
      - email
      - is_active
      - is_verified
      - role
      - membership_id
      - joined_at
      title: TeamUser
      description: User information with team membership details.
    Membership:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        team_id:
          type: string
          format: uuid
          title: Team Id
        user_id:
          type: string
          format: uuid
          title: User Id
        role:
          $ref: '#/components/schemas/TeamRole'
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
      type: object
      required:
      - id
      - team_id
      - user_id
      - role
      - created_at
      - updated_at
      title: Membership
      description: Team membership domains model.