openapi: 3.0.3
info:
  title: ToolJet SCIM API
  version: 1.0.0
  description: >
    ToolJet supports SCIM 2.0 for automated user and group provisioning. All
    standard SCIM endpoints are supported — including `/Schemas`,
    `/ResourceTypes`, `/Users`, and `/Groups`.
servers:
  - url: https://app.tooljet.com/api/scim/v2
    description: Production server
  - url: http://localhost:3000/api/scim/v2
    description: Local development server
paths:
  /Users:
    get:
      summary: List Users
      responses:
        '200':
          description: List of users
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMListResponse'
    post:
      summary: Create User
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMUserRequest'
      responses:
        '201':
          description: User created
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMUserResponse'
  /Users/{id}:
    get:
      summary: Get User by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: User details
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMUserResponse'
    put:
      summary: Replace User
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMUserRequest'
      responses:
        '200':
          description: Updated user
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMUserResponse'
    patch:
      summary: Patch User
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMPatchRequest'
      responses:
        '200':
          description: User updated
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMUserResponse'
    delete:
      summary: Delete User
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: User deleted
  /Groups:
    get:
      summary: List Groups
      responses:
        '200':
          description: List of groups
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMGroupListResponse'
    post:
      summary: Create Group
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMGroupRequest'
      responses:
        '201':
          description: Group created
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMGroupResponse'
  /Groups/{id}:
    get:
      summary: Get Group by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Group details
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMGroupResponse'
    put:
      summary: Replace Group
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMGroupRequest'
      responses:
        '200':
          description: Group updated
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMGroupResponse'
    patch:
      summary: Patch Group
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              $ref: '#/components/schemas/SCIMPatchRequest'
      responses:
        '200':
          description: Group updated
          content:
            application/scim+json:
              schema:
                $ref: '#/components/schemas/SCIMGroupResponse'
    delete:
      summary: Delete Group
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Group deleted
components:
  schemas:
    SCIMUserRequest:
      type: object
      required:
        - schemas
        - userName
      properties:
        schemas:
          type: array
          items:
            type: string
          example:
            - urn:ietf:params:scim:schemas:core:2.0:User
            - urn:ietf:params:scim:schemas:extension:tooljet:User:2.0
        userName:
          type: string
        name:
          type: object
          properties:
            givenName:
              type: string
            familyName:
              type: string
        active:
          type: boolean
        password:
          type: string
          description: User password for creation.
        emails:
          type: array
          items:
            type: object
            properties:
              value:
                type: string
              primary:
                type: boolean
              type:
                type: string
        groups:
          type: array
          items:
            type: object
            properties:
              value:
                type: string
              display:
                type: string
        meta:
          type: object
          properties:
            resourceType:
              type: string
        urn:ietf:params:scim:schemas:extension:tooljet:User:2.0:
          type: object
          description: ToolJet’s custom SCIM extension (only used in requests)
          properties:
            role:
              type: string
    SCIMUserResponse:
      type: object
      properties:
        schemas:
          type: array
          items:
            type: string
          example:
            - urn:ietf:params:scim:schemas:core:2.0:User
        id:
          type: string
          format: uuid
        userName:
          type: string
        name:
          type: object
          properties:
            givenName:
              type: string
            familyName:
              type: string
        active:
          type: boolean
        emails:
          type: array
          items:
            type: object
            properties:
              value:
                type: string
              primary:
                type: boolean
              type:
                type: string
        meta:
          type: object
          properties:
            resourceType:
              type: string
              example: User
            created:
              type: string
              format: date-time
            lastModified:
              type: string
              format: date-time
    SCIMListResponse:
      type: object
      properties:
        totalResults:
          type: integer
        startIndex:
          type: integer
        itemsPerPage:
          type: integer
        Resources:
          type: array
          items:
            $ref: '#/components/schemas/SCIMUserResponse'
    SCIMPatchRequest:
      type: object
      required:
        - schemas
        - Operations
      properties:
        schemas:
          type: array
          items:
            type: string
          example:
            - urn:ietf:params:scim:api:messages:2.0:PatchOp
        Operations:
          type: array
          items:
            type: object
            properties:
              op:
                type: string
                enum:
                  - add
                  - remove
                  - replace
              path:
                type: string
              value: {}
    SCIMGroupRequest:
      type: object
      required:
        - schemas
        - displayName
      properties:
        schemas:
          type: array
          items:
            type: string
          example:
            - urn:ietf:params:scim:schemas:core:2.0:Group
        displayName:
          type: string
          example: Developers
        members:
          type: array
          description: List of User members belonging to this group.
          items:
            type: object
            properties:
              value:
                type: string
                format: uuid
                description: User ID
              display:
                type: string
                description: User display name
    SCIMGroupResponse:
      allOf:
        - $ref: '#/components/schemas/SCIMGroupRequest'
        - type: object
          properties:
            id:
              type: string
              format: uuid
            meta:
              type: object
              properties:
                resourceType:
                  type: string
                  example: Group
                created:
                  type: string
                  format: date-time
                lastModified:
                  type: string
                  format: date-time
    SCIMGroupListResponse:
      type: object
      properties:
        totalResults:
          type: integer
        startIndex:
          type: integer
        itemsPerPage:
          type: integer
        Resources:
          type: array
          items:
            $ref: '#/components/schemas/SCIMGroupResponse'
