openapi: 3.0.4
info:
  title: Fractal Accounts
  description: Fractal Accounts description
  contact:
    name: Fractal Cloud
    url: https://fractal.cloud/
    email: contact-us@fractal.cloud
  version: v1
paths:
  /Accounts:
    post:
      tags:
        - Accounts
      summary: Create an account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAccountRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
  /Accounts/me:
    put:
      tags:
        - Accounts
      summary: Update an account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAccountRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
    delete:
      tags:
        - Accounts
      summary: Delete an account
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Accounts/{accountId}/activate:
    put:
      tags:
        - Accounts
      summary: Activate an account
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActivateAccountRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
      deprecated: true
  /Accounts/me/activate:
    put:
      tags:
        - Accounts
      summary: Activate an account
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActivateAccountRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Accounts/me/changepassword:
    put:
      tags:
        - Accounts
      summary: Change an account password
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeAccountPasswordRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Accounts/{accountId}:
    get:
      tags:
        - Accounts
      summary: Get an account by id
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
  /Accounts/{email}:
    get:
      tags:
        - Accounts
      summary: Get an account by email
      parameters:
        - name: email
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
  /Accounts/serviceAccount:
    post:
      tags:
        - Accounts
      summary: Create a service account
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
      deprecated: true
  /Accounts/me/serviceAccount:
    post:
      tags:
        - Accounts
      summary: Create a service account
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
  /Accounts/serviceAccount/secret:
    get:
      tags:
        - Accounts
      summary: Get the service account secret
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
      deprecated: true
  /Accounts/me/serviceAccount/secret:
    get:
      tags:
        - Accounts
      summary: Get the service account secret
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
  /Accounts/resourcegroups/{shortName}:
    post:
      tags:
        - Accounts
      summary: Upsert a personal resource group
      parameters:
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertPersonalResourceGroupRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonalResourceGroup'
      deprecated: true
    get:
      tags:
        - Accounts
      summary: Get a personal resource group by its short name
      parameters:
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonalResourceGroup'
      deprecated: true
  /Accounts/me/resourcegroups/{shortName}:
    post:
      tags:
        - Accounts
      summary: Upsert a personal resource group
      parameters:
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertPersonalResourceGroupRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonalResourceGroup'
    get:
      tags:
        - Accounts
      summary: Get a personal resource group by its short name
      parameters:
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonalResourceGroup'
    delete:
      tags:
        - Accounts
      summary: Delete a personal resource group
      parameters:
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Accounts/{accountId}/resourcegroups/{shortName}:
    delete:
      tags:
        - Accounts
      summary: Delete a personal resource group
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
      deprecated: true
  /Health:
    get:
      tags:
        - Health
      responses:
        '200':
          description: OK
  /Organizations:
    post:
      tags:
        - Organizations
      summary: Create an organization
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrganizationRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
    put:
      tags:
        - Organizations
      summary: Update an organization
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateOrganizationRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
  /Organizations/{organizationId}:
    get:
      tags:
        - Organizations
      summary: Get an organization
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
    delete:
      tags:
        - Organizations
      summary: Delete an organization
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Organizations/{organizationId}/resourcegroups/{shortName}:
    post:
      tags:
        - Organizations
      summary: Upsert an organizational resource group
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertOrganizationalResourceGroupRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationalResourceGroup'
    get:
      tags:
        - Organizations
      summary: Get an organizational resource group by shortname
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationalResourceGroup'
    delete:
      tags:
        - Organizations
      summary: Delete an organizational resource group
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Organizations/{organizationId}/permissions:
    put:
      tags:
        - Organizations
      summary: Grant an organization permission to a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
    delete:
      tags:
        - Organizations
      summary: Revoke an organization permission from a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Organizations/{organizationId}/resourcegroups/{shortName}/permissions:
    put:
      tags:
        - Organizations
      summary: Grant an organizational resource group permission to a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
    delete:
      tags:
        - Organizations
      summary: Revoke an organizational resource group permission from a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Organizations/{organizationId}/teams/{shortName}/permissions:
    put:
      tags:
        - Organizations
      summary: Grant team permissions to a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
    delete:
      tags:
        - Organizations
      summary: Revoke a team permission from a principal
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PermissionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /Organizations/{organizationId}/teams:
    post:
      tags:
        - Organizations
      summary: Upsert a team
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertTeamRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamEntity'
  /Organizations/{organizationId}/teams/{shortname}:
    get:
      tags:
        - Organizations
      summary: Get a team by shortname
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortname
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamEntity'
    delete:
      tags:
        - Organizations
      summary: 'Delete a team '
      parameters:
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: shortname
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamEntity'
components:
  schemas:
    Account:
      type: object
      properties:
        id:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        avatarUrl:
          type: string
          nullable: true
        phoneNumber:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/AccountStatus'
        challenge:
          type: string
          nullable: true
        forcePasswordChange:
          type: boolean
        serviceAccountId:
          type: string
          nullable: true
      additionalProperties: false
    AccountStatus:
      enum:
        - Registered
        - Active
        - Invited
        - Blocked
        - Deleted
      type: string
    ActivateAccountRequest:
      type: object
      properties:
        password:
          type: string
          format: password
          nullable: true
      additionalProperties: false
    ChangeAccountPasswordRequest:
      type: object
      properties:
        oldPassword:
          type: string
          format: password
          nullable: true
        newPassword:
          type: string
          format: password
          nullable: true
      additionalProperties: false
    CreateAccountRequest:
      type: object
      properties:
        name:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        avatarUrl:
          type: string
          nullable: true
        phoneNumber:
          type: string
          nullable: true
        businessScopes:
          uniqueItems: true
          type: array
          items:
            type: string
          nullable: true
      additionalProperties: false
    CreateOrganizationRequest:
      type: object
      properties:
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
      additionalProperties: false
    EntityStatus:
      enum:
        - Unknown
        - Active
        - Deleting
      type: string
    Organization:
      type: object
      properties:
        id:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
        admins:
          type: array
          items:
            type: string
          nullable: true
        members:
          type: array
          items:
            type: string
          nullable: true
        teams:
          type: array
          items:
            type: string
          nullable: true
        resourceGroups:
          type: array
          items:
            type: string
          nullable: true
        status:
          $ref: '#/components/schemas/EntityStatus'
      additionalProperties: false
    OrganizationalResourceGroup:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ResourceGroupId'
        displayName:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/EntityStatus'
        icon:
          type: string
          nullable: true
        livesystems:
          type: array
          items:
            type: string
          nullable: true
        fractals:
          type: array
          items:
            type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        createdBy:
          type: string
          nullable: true
        updatedAt:
          type: string
          format: date-time
        updatedBy:
          type: string
          nullable: true
        membersIds:
          type: array
          items:
            type: string
          nullable: true
        teamsIds:
          type: array
          items:
            type: string
          nullable: true
        managersIds:
          type: array
          items:
            type: string
          nullable: true
      additionalProperties: false
    PermissionRequest:
      type: object
      properties:
        principalType:
          $ref: '#/components/schemas/PrincipalType'
        principalId:
          type: string
          description: >-
            The identifier of the principal:

            <list type="bullet"><item><description>Organization → GUID (e.g.
            `2cf133e2-6f35-4179-802e-51376ac79141`).</description></item><item><description>Account
            → email (e.g. `example@fractal.cloud`).</description></item></list>
          nullable: true
        permissionType:
          $ref: '#/components/schemas/PermissionType'
      additionalProperties: false
      description: >-
        Request to grant or revoke a permission to a principal (organization or
        account).
    PermissionType:
      enum:
        - Admin
        - Edit
        - Terminate
        - View
      type: string
    PersonalResourceGroup:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ResourceGroupId'
        displayName:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/EntityStatus'
        icon:
          type: string
          nullable: true
        livesystems:
          type: array
          items:
            type: string
          nullable: true
        fractals:
          type: array
          items:
            type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        createdBy:
          type: string
          nullable: true
        updatedAt:
          type: string
          format: date-time
        updatedBy:
          type: string
          nullable: true
      additionalProperties: false
    PrincipalType:
      enum:
        - Account
        - Team
      type: string
    ResourceGroupId:
      type: object
      properties:
        resourceGroupType:
          $ref: '#/components/schemas/ResourceGroupType'
        ownerId:
          type: string
          nullable: true
        shortName:
          type: string
          nullable: true
      additionalProperties: false
    ResourceGroupType:
      enum:
        - Personal
        - Organizational
      type: string
    TeamEntity:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/TeamId'
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        status:
          $ref: '#/components/schemas/EntityStatus'
        icon:
          type: string
          nullable: true
        isPrivate:
          type: boolean
      additionalProperties: false
    TeamId:
      type: object
      properties:
        organizationId:
          type: string
          format: uuid
        shortName:
          type: string
          nullable: true
      additionalProperties: false
    UpdateAccountRequest:
      type: object
      properties:
        name:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        avatarUrl:
          type: string
          nullable: true
        phoneNumber:
          type: string
          nullable: true
      additionalProperties: false
    UpdateOrganizationRequest:
      type: object
      properties:
        organizationId:
          type: string
          format: uuid
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
      additionalProperties: false
    UpsertOrganizationalResourceGroupRequest:
      type: object
      properties:
        displayName:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
      additionalProperties: false
    UpsertPersonalResourceGroupRequest:
      type: object
      properties:
        displayName:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
      additionalProperties: false
    UpsertTeamRequest:
      type: object
      properties:
        shortName:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        icon:
          type: string
          nullable: true
        isPrivate:
          type: boolean
      additionalProperties: false
  securitySchemes:
    Bearer:
      type: apiKey
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        "Authorization: Bearer {token}"
      name: JWT Authorization
      in: header
security:
  - Bearer: []
