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

# Lock or unlock

> Start a new lock session or complete (unlock) the active session. User IDs (target and keyholders) are validated against your accessible users before the action is performed.



## OpenAPI

````yaml https://dashboard.researchanddesire.com/openapi.yaml post /lkbx/session/current
openapi: 3.1.0
info:
  title: Research And Desire API
  description: >
    The Research And Desire API provides programmatic access to your devices and
    data.


    All responses follow a standard envelope format:

    - Success: `{ "ok": true, "data": <result> }`

    - Error: `{ "ok": false, "error": "<message>" }`


    ## Pagination


    List endpoints support pagination via query parameters:

    - `limit`: Number of records to return (default: 50, max: 100)

    - `offset`: Number of records to skip (default: 0)


    Paginated responses include pagination metadata alongside the data array.


    ## Authentication


    All endpoints require a Bearer token in the Authorization header.

    Tokens can be created in the Dashboard settings (requires Ultra
    subscription).
  version: 1.0.0
  contact:
    name: Research And Desire Support
    url: https://www.researchanddesire.com/support
servers:
  - url: https://dashboard.researchanddesire.com/api/v1
    description: Production API
security:
  - bearerAuth: []
tags:
  - name: Users
    description: User account information
  - name: DTT
    description: Deepthroat Trainer devices
  - name: DTT Templates
    description: Deepthroat Trainer training program templates
  - name: DTT Sessions
    description: Deepthroat Trainer training session history
  - name: LKBX
    description: Chastity Lockbox devices
  - name: Lock Templates
    description: Lock templates
  - name: Lock Sessions
    description: Lock session management
  - name: OSSM
    description: Open Source Sex Machine devices
paths:
  /lkbx/session/current:
    post:
      tags:
        - Lock Sessions
      summary: Lock or unlock
      description: >-
        Start a new lock session or complete (unlock) the active session. User
        IDs (target and keyholders) are validated against your accessible users
        before the action is performed.
      operationId: lockOrUnlock
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LockUnlockRequest'
            examples:
              lock:
                summary: Start a new lock
                value:
                  action: lock
                  lockSettingsId: 3
                  keyholderIds:
                    - 100
                    - 101
              lockTestMode:
                summary: Start a test lock
                value:
                  action: lock
                  lockSettingsId: 3
                  isTestLock: true
              unlock:
                summary: Complete active lock
                value:
                  action: unlock
              lockForPartner:
                summary: Lock a partner
                value:
                  action: lock
                  lockSettingsId: 3
                  targetUserId: 50
      responses:
        '200':
          description: Lock session completed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnlockSuccessResponse'
              example:
                ok: true
                data:
                  message: Lock session completed
        '201':
          description: Lock session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LockCreatedResponse'
              example:
                ok: true
                data:
                  lockSessionId: 8
        '400':
          description: Invalid request or operation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidAction:
                  summary: Invalid action
                  value:
                    ok: false
                    error: Action must be "lock" or "unlock"
                alreadyLocked:
                  summary: Already locked
                  value:
                    ok: false
                    error: You already have an active lock.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Inaccessible user ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                inaccessibleTarget:
                  summary: Inaccessible target user
                  value:
                    ok: false
                    error: 'targetUserId contains inaccessible user IDs: 123'
                inaccessibleKeyholder:
                  summary: Inaccessible keyholder
                  value:
                    ok: false
                    error: 'keyholderIds contains inaccessible user IDs: 456, 789'
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                ok: false
                error: User not found
components:
  schemas:
    LockUnlockRequest:
      type: object
      required:
        - action
      properties:
        action:
          type: string
          enum:
            - lock
            - unlock
          description: Action to perform
        lockSettingsId:
          type: integer
          description: Lock template ID (for lock action)
        keyholderIds:
          type: array
          items:
            type: integer
          description: >-
            User IDs to assign as keyholders (for lock action). All IDs must be
            users you have access to.
        targetUserId:
          type: integer
          description: >-
            User to lock/unlock (defaults to authenticated user). Must be a user
            you have access to.
        isTestLock:
          type: boolean
          description: >-
            Override test lock setting from template. When true, the lock owner
            can unlock without a keyholder. Only used with lock action.
    UnlockSuccessResponse:
      type: object
      required:
        - ok
        - data
      properties:
        ok:
          type: boolean
          const: true
        data:
          type: object
          required:
            - message
          properties:
            message:
              type: string
    LockCreatedResponse:
      type: object
      required:
        - ok
        - data
      properties:
        ok:
          type: boolean
          const: true
        data:
          type: object
          required:
            - lockSessionId
          properties:
            lockSessionId:
              type: integer
              description: ID of the created lock session
    ErrorResponse:
      type: object
      required:
        - ok
        - error
      properties:
        ok:
          type: boolean
          const: false
        error:
          type: string
  responses:
    Unauthorized:
      description: Authentication required or token invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            ok: false
            error: Unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        API tokens can be created in the Dashboard settings.
        Requires an Ultra subscription.

````