---
openapi: 3.1.0
info:
  title: Usakey SCIM 2.0 API
  version: '2026-10-18'
  description: >-
    SCIM 2.0 (RFC 7643 and RFC 7644) server that lets a customer's identity provider, such as Microsoft Entra ID or
    Okta, provision that customer's license users and groups in Usakey. It is separate from the Management API
    (public/openapi.yaml): it is authenticated with a SCIM token created for one customer in the Usakey console, it uses
    the SCIM media type and error schema, and it only reaches the users and groups of that customer that the SCIM setup
    manages. The token is sent as Authorization: Bearer. Requests are limited per token, per workspace and per address;
    429 responses carry Retry-After.
servers:
- url: https://usakey.jp/scim/v2
  description: Production URL
security:
- scimBearer: []
tags:
- name: SCIM discovery
- name: SCIM users
- name: SCIM groups
paths:
  "/ServiceProviderConfig":
    get:
      tags:
      - SCIM discovery
      summary: Describe the supported SCIM features
      operationId: scim_v2_service_provider_config
      x-controller-action: scim/v2/discovery#service_provider_config
      responses:
        '200':
          description: Service provider configuration
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/ServiceProviderConfig"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/ResourceTypes":
    get:
      tags:
      - SCIM discovery
      summary: List the resource types (User and Group)
      operationId: scim_v2_resource_types
      x-controller-action: scim/v2/discovery#resource_types
      responses:
        '200':
          description: Resource types
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/ListResponse"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/ResourceTypes/{id}":
    parameters:
    - "$ref": "#/components/parameters/Id"
    get:
      tags:
      - SCIM discovery
      summary: Fetch one resource type
      operationId: scim_v2_resource_type
      x-controller-action: scim/v2/discovery#resource_type
      responses:
        '200':
          description: Resource type
          content:
            application/scim+json:
              schema:
                type: object
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Schemas":
    get:
      tags:
      - SCIM discovery
      summary: List the schemas of the supported attributes
      description: Only the attributes Usakey stores are listed. Other attributes are accepted and ignored.
      operationId: scim_v2_schemas
      x-controller-action: scim/v2/discovery#schemas
      responses:
        '200':
          description: Schemas
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/ListResponse"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Schemas/{id}":
    parameters:
    - "$ref": "#/components/parameters/Id"
    get:
      tags:
      - SCIM discovery
      summary: Fetch one schema by its URN
      operationId: scim_v2_schema
      x-controller-action: scim/v2/discovery#schema
      responses:
        '200':
          description: Schema
          content:
            application/scim+json:
              schema:
                type: object
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Users":
    get:
      tags:
      - SCIM users
      summary: List users
      description: >-
        Lists the users of the SCIM setup's customer and issuer, excluding users whose use has ended. The filter
        supports eq on userName (case-insensitive), externalId, id, emails.value and active, joined with and.
      operationId: scim_v2_users_index
      x-controller-action: scim/v2/users#index
      parameters:
      - "$ref": "#/components/parameters/Filter"
      - "$ref": "#/components/parameters/StartIndex"
      - "$ref": "#/components/parameters/Count"
      responses:
        '200':
          description: Users
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/ListResponse"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    post:
      tags:
      - SCIM users
      summary: Create a user
      description: >-
        userName becomes the license user's subject. A user whose use ended with the same userName is reactivated and
        keeps its id. 409 uniqueness when the userName is already used (case-insensitive); 403 when the customer's or
        reseller's user limit is reached.
      operationId: scim_v2_users_create
      x-controller-action: scim/v2/users#create
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/UserInput"
      responses:
        '201':
          description: Created user
          headers:
            Location:
              schema:
                type: string
                format: uri
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/User"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Users/{id}":
    parameters:
    - "$ref": "#/components/parameters/Id"
    get:
      tags:
      - SCIM users
      summary: Fetch a user
      operationId: scim_v2_users_show
      x-controller-action: scim/v2/users#show
      responses:
        '200':
          description: User
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/User"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    put:
      tags:
      - SCIM users
      summary: Replace a user
      description: Replaces userName, the display name, the email address, externalId and active. Without active, the status stays.
      operationId: scim_v2_users_replace
      x-controller-action: scim/v2/users#replace
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/UserInput"
      responses:
        '200':
          description: Updated user
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/User"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    patch:
      tags:
      - SCIM users
      summary: Change part of a user
      description: >-
        add, replace and remove (case-insensitive, as Microsoft Entra ID sends them) on active (true/false or "True"/"False"),
        userName, displayName, externalId, name, name.givenName, name.familyName, name.formatted, emails and
        emails[...].value, with or without a path. Other attributes are ignored. active false suspends the user.
      operationId: scim_v2_users_patch
      x-controller-action: scim/v2/users#patch
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/PatchOp"
      responses:
        '200':
          description: Updated user
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/User"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    delete:
      tags:
      - SCIM users
      summary: End a user's use
      description: Ends the license user's use (deprovision), removing current license assignments and group memberships. The license records stay; the user is no longer returned.
      operationId: scim_v2_users_destroy
      x-controller-action: scim/v2/users#destroy
      responses:
        '204':
          description: Use ended
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Groups":
    get:
      tags:
      - SCIM groups
      summary: List groups
      description: >-
        Lists the active groups created through this SCIM setup. The filter supports eq on displayName
        (case-insensitive), externalId and id, and members[value eq "..."], joined with and.
        excludedAttributes=members leaves members out.
      operationId: scim_v2_groups_index
      x-controller-action: scim/v2/groups#index
      parameters:
      - "$ref": "#/components/parameters/Filter"
      - "$ref": "#/components/parameters/StartIndex"
      - "$ref": "#/components/parameters/Count"
      - "$ref": "#/components/parameters/ExcludedAttributes"
      responses:
        '200':
          description: Groups
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/ListResponse"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    post:
      tags:
      - SCIM groups
      summary: Create a group
      description: >-
        Creates a group of the customer. 409 uniqueness when another group of the customer has the same displayName,
        including one created in the console. A group deleted through SCIM comes back when created again with its name.
        Members must be users of this SCIM setup.
      operationId: scim_v2_groups_create
      x-controller-action: scim/v2/groups#create
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/GroupInput"
      responses:
        '201':
          description: Created group
          headers:
            Location:
              schema:
                type: string
                format: uri
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/Group"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
  "/Groups/{id}":
    parameters:
    - "$ref": "#/components/parameters/Id"
    get:
      tags:
      - SCIM groups
      summary: Fetch a group
      operationId: scim_v2_groups_show
      x-controller-action: scim/v2/groups#show
      parameters:
      - "$ref": "#/components/parameters/ExcludedAttributes"
      responses:
        '200':
          description: Group
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/Group"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    put:
      tags:
      - SCIM groups
      summary: Replace a group
      description: Replaces displayName, externalId and the members that belong to this SCIM setup. Members added in the console are kept.
      operationId: scim_v2_groups_replace
      x-controller-action: scim/v2/groups#replace
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/GroupInput"
      responses:
        '200':
          description: Updated group
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/Group"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    patch:
      tags:
      - SCIM groups
      summary: Change part of a group
      description: >-
        add, replace and remove members (a value list, or path members[value eq "..."] for remove), replace displayName
        and externalId, or replace with an object value. Each request is applied as a whole or not at all.
      operationId: scim_v2_groups_patch
      x-controller-action: scim/v2/groups#patch
      requestBody:
        required: true
        content:
          application/scim+json:
            schema:
              "$ref": "#/components/schemas/PatchOp"
      responses:
        '200':
          description: Updated group
          content:
            application/scim+json:
              schema:
                "$ref": "#/components/schemas/Group"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
    delete:
      tags:
      - SCIM groups
      summary: Delete a group
      description: Removes the memberships of this SCIM setup's users and archives the group. Assignment history stays.
      operationId: scim_v2_groups_destroy
      x-controller-action: scim/v2/groups#destroy
      responses:
        '204':
          description: Archived
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
components:
  securitySchemes:
    scimBearer:
      type: http
      scheme: bearer
      description: SCIM token created for one customer in the Usakey console (usk_scim_...). Only its HMAC digest is stored.
  parameters:
    Id:
      name: id
      in: path
      required: true
      schema:
        type: string
        maxLength: 256
    Filter:
      name: filter
      in: query
      required: false
      schema:
        type: string
        maxLength: 1000
      example: userName eq "alice@example.com"
    StartIndex:
      name: startIndex
      in: query
      required: false
      description: 1-based index of the first result. Values below 1 are treated as 1.
      schema:
        type: integer
        minimum: 1
    Count:
      name: count
      in: query
      required: false
      description: Number of results per page (default 100, at most 200). 0 returns only totalResults.
      schema:
        type: integer
        minimum: 0
        maximum: 200
    ExcludedAttributes:
      name: excludedAttributes
      in: query
      required: false
      description: members leaves group members out of the response.
      schema:
        type: string
  responses:
    BadRequest:
      description: The request is malformed (scimType invalidSyntax, invalidFilter, invalidValue, invalidPath or mutability).
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
    Unauthorized:
      description: The SCIM token is missing, unknown, revoked or expired.
      headers:
        WWW-Authenticate:
          schema:
            type: string
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
    Forbidden:
      description: The workspace is not active, its plan lacks SCIM, the SCIM setup or the customer's user management is stopped, or a user limit was reached.
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
    NotFound:
      description: The resource does not exist for this SCIM setup.
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
    Conflict:
      description: Another user or group already uses the value (scimType uniqueness).
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
    TooManyRequests:
      description: Too many requests. Retry after the number of seconds in Retry-After.
      headers:
        Retry-After:
          schema:
            type: integer
      content:
        application/scim+json:
          schema:
            "$ref": "#/components/schemas/Error"
  schemas:
    Error:
      type: object
      required:
      - schemas
      - status
      properties:
        schemas:
          type: array
          items:
            type: string
            const: urn:ietf:params:scim:api:messages:2.0:Error
        status:
          type: string
        scimType:
          type: string
        detail:
          type: string
    Meta:
      type: object
      properties:
        resourceType:
          type: string
        created:
          type: string
          format: date-time
        lastModified:
          type: string
          format: date-time
        location:
          type: string
          format: uri
        version:
          type: string
    Email:
      type: object
      properties:
        value:
          type: string
        type:
          type: string
        primary:
          type: boolean
    User:
      type: object
      required:
      - schemas
      - id
      - userName
      - active
      properties:
        schemas:
          type: array
          items:
            type: string
        id:
          type: string
        externalId:
          type: string
        userName:
          type: string
        displayName:
          type: string
        name:
          type: object
          properties:
            formatted:
              type: string
        emails:
          type: array
          items:
            "$ref": "#/components/schemas/Email"
        active:
          type: boolean
        meta:
          "$ref": "#/components/schemas/Meta"
    UserInput:
      type: object
      required:
      - userName
      properties:
        schemas:
          type: array
          items:
            type: string
        externalId:
          type: string
          maxLength: 512
        userName:
          type: string
          maxLength: 512
        displayName:
          type: string
          maxLength: 160
        name:
          type: object
          properties:
            formatted:
              type: string
            givenName:
              type: string
            familyName:
              type: string
        emails:
          type: array
          items:
            "$ref": "#/components/schemas/Email"
        active:
          type: boolean
      additionalProperties: true
    Member:
      type: object
      required:
      - value
      properties:
        value:
          type: string
        display:
          type: string
        "$ref":
          type: string
          format: uri
    Group:
      type: object
      required:
      - schemas
      - id
      - displayName
      properties:
        schemas:
          type: array
          items:
            type: string
        id:
          type: string
        externalId:
          type: string
        displayName:
          type: string
        members:
          type: array
          items:
            "$ref": "#/components/schemas/Member"
        meta:
          "$ref": "#/components/schemas/Meta"
    GroupInput:
      type: object
      required:
      - displayName
      properties:
        schemas:
          type: array
          items:
            type: string
        externalId:
          type: string
          maxLength: 512
        displayName:
          type: string
          maxLength: 160
        members:
          type: array
          maxItems: 1000
          items:
            "$ref": "#/components/schemas/Member"
      additionalProperties: true
    PatchOp:
      type: object
      required:
      - Operations
      properties:
        schemas:
          type: array
          items:
            type: string
        Operations:
          type: array
          minItems: 1
          maxItems: 100
          items:
            type: object
            required:
            - op
            properties:
              op:
                type: string
                description: add, replace or remove (case-insensitive)
              path:
                type: string
              value: {}
    ListResponse:
      type: object
      required:
      - schemas
      - totalResults
      - Resources
      properties:
        schemas:
          type: array
          items:
            type: string
            const: urn:ietf:params:scim:api:messages:2.0:ListResponse
        totalResults:
          type: integer
          minimum: 0
        startIndex:
          type: integer
          minimum: 1
        itemsPerPage:
          type: integer
          minimum: 0
        Resources:
          type: array
          items:
            type: object
    ServiceProviderConfig:
      type: object
      required:
      - schemas
      - patch
      - bulk
      - filter
      - authenticationSchemes
      properties:
        schemas:
          type: array
          items:
            type: string
        documentationUri:
          type: string
          format: uri
        patch:
          type: object
        bulk:
          type: object
        filter:
          type: object
        changePassword:
          type: object
        sort:
          type: object
        etag:
          type: object
        authenticationSchemes:
          type: array
          items:
            type: object
        meta:
          "$ref": "#/components/schemas/Meta"
