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

# Get User Organizations

> Retrieve the list of organizations the current user belongs to. This endpoint returns all organizations where the user's email is registered, along with pending invitations.

**Use Case:**
- Populate the Switch Organization modal
- Show organization list in profile dropdown
- Check if user has multiple organizations
- View pending organization invitations



## OpenAPI

````yaml /openapi/public/openapi-auth.json get /organizations
openapi: 3.0.0
info:
  title: MileApp API - Auth
  version: 3.0.0
  description: MileApp API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Multi-Organization
    description: >-
      Multi-Organization feature allows users to belong to multiple
      organizations using the same email address. This enables seamless
      switching between organizations without requiring separate login
      credentials. When a user logs in with an email associated with multiple
      organizations, they can select which organization to access and switch
      between them with password verification only.


      **Related Guide:** [User
      Management](https://doc.mile.app/pages/setting/user-management/introduction-to-user-management)
paths:
  /organizations:
    get:
      tags:
        - Multi-Organization
      summary: Get User Organizations
      description: >-
        Retrieve the list of organizations the current user belongs to. This
        endpoint returns all organizations where the user's email is registered,
        along with pending invitations.


        **Use Case:**

        - Populate the Switch Organization modal

        - Show organization list in profile dropdown

        - Check if user has multiple organizations

        - View pending organization invitations
      operationId: getUserOrganizations
      responses:
        '200':
          description: Success - returns list of organizations
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Status of response
                  data:
                    type: object
                    properties:
                      currentOrganization:
                        type: object
                        description: Information about the currently active organization
                        properties:
                          userId:
                            type: string
                            description: User ID in the current organization
                          organizationId:
                            type: string
                            description: Current organization ID
                          organizationName:
                            type: string
                            description: Current organization name
                      organizations:
                        type: array
                        description: List of all active organizations the user belongs to
                        items:
                          type: object
                          properties:
                            userId:
                              type: string
                              description: User account ID for this organization
                            organizationId:
                              type: string
                              description: Organization ID
                            organizationName:
                              type: string
                              description: Organization display name
                            organizationLogo:
                              type: string
                              description: URL to organization logo (nullable)
                            roleName:
                              type: string
                              description: User's role in this organization
                            lastLogin:
                              type: string
                              format: date-time
                              description: Last login timestamp for this organization
                            isCurrent:
                              type: boolean
                              description: >-
                                Whether this is the currently active
                                organization
                      pendingInvitations:
                        type: array
                        description: List of pending organization invitations
                        items:
                          type: object
                          properties:
                            userId:
                              type: string
                              description: Pending user ID
                            organizationId:
                              type: string
                              description: Organization ID of the invitation
                            organizationName:
                              type: string
                              description: Organization name
                            organizationLogo:
                              type: string
                              description: URL to organization logo (nullable)
                            invitedAt:
                              type: string
                              format: date-time
                              description: Timestamp when the invitation was sent
                example:
                  status: true
                  data:
                    currentOrganization:
                      userId: 507f1f77bcf86cd799439011
                      organizationId: 507f1f77bcf86cd799439022
                      organizationName: Acme Corp
                    organizations:
                      - userId: 507f1f77bcf86cd799439011
                        organizationId: 507f1f77bcf86cd799439022
                        organizationName: Acme Corp
                        organizationLogo: https://storage.mile.app/logos/acme.png
                        roleName: owner
                        lastLogin: '2024-01-15T10:30:00+07:00'
                        isCurrent: true
                      - userId: 507f1f77bcf86cd799439012
                        organizationId: 507f1f77bcf86cd799439023
                        organizationName: Beta Inc
                        organizationLogo: null
                        roleName: admin
                        lastLogin: '2024-01-10T08:00:00+07:00'
                        isCurrent: false
                    pendingInvitations:
                      - userId: 507f1f77bcf86cd799439015
                        organizationId: 507f1f77bcf86cd799439024
                        organizationName: Gamma Inc
                        organizationLogo: null
                        invitedAt: '2024-01-14T09:00:00+07:00'
        '401':
          description: Unauthorized - User not authenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                  message:
                    type: string
                example:
                  status: false
                  message: Unauthenticated
      deprecated: false
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````