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

# Set clock sync

> Enable or disable built-in host wall-clock sync inside a VM sandbox.

Enable or disable the sandbox daemon’s built-in `CLOCK_REALTIME` syncer. Workloads inside the sandbox can call the same control surface over `/run/tensorlake/guest.sock` (`PUT /v1/clock-sync`); see [How clocks work in sandboxes](https://docs.tensorlake.ai/sandboxes/clocks.md).

## Example request

Set `SANDBOX_URL` to the `sandbox_url` returned by [Get Sandbox](https://docs.tensorlake.ai/api-reference/v2/sandboxes/get.md) and authenticate with your Tensorlake API key:

```bash theme={null}
curl -X PUT "${SANDBOX_URL%/}/api/v1/clock-sync" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'
```

This disables both periodic (10s) and post-resume `CLOCK_REALTIME` steps and waits for any in-flight `clock_settime` call to finish before returning `200 OK`.

Send `{"enabled": true}` to re-enable syncing and wake the corrector immediately to re-anchor guest `CLOCK_REALTIME` to host UTC.

## Behavior and errors

State lives in daemon memory, so it persists across resident suspend and resume, full-memory snapshots, and live migration, and resets to `enabled: true` on a fresh boot or filesystem-only snapshot restore.

* **`400 Bad Request`**: malformed JSON body
* **`413 Payload Too Large`**: request body exceeds 4 KB
* **`422 Unprocessable Entity`**: unknown field in JSON body
* **`501 Not Implemented`**: runtime doesn’t allow toggling wall-clock sync (`code: "CLOCK_SYNC_UNSUPPORTED"`), such as GPU sandboxes running under gVisor or VMs lacking `/dev/ptp0` (`KVM virtual PTP`) or `CAP_SYS_TIME`


## OpenAPI

````yaml put /api/v1/clock-sync
openapi: 3.1.0
info:
  title: Tensorlake API
  description: Tensorlake Cloud APIs for Sandboxes and Serverless Workflows
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.tensorlake.ai/
security:
  - bearerAuth: []
tags:
  - name: Tensorlake Cloud API
    description: Tensorlake Cloud APIs for Sandboxes and Serverless Workflows
paths:
  /api/v1/clock-sync:
    servers:
      - url: https://{identifier}.sandbox.tensorlake.ai
        description: >-
          Example sandbox proxy host for a specific running sandbox. For
          programmatic access, use the sandbox's `ingress_endpoint`.
        variables:
          identifier:
            default: example-sandbox
            description: The sandbox ID or sandbox name.
    put:
      tags:
        - sandbox-runtime
      summary: Set clock sync
      description: >
        Enable or disable the sandbox daemon's built-in `CLOCK_REALTIME` syncer

        on VM sandboxes. Disabling waits for any in-flight `clock_settime` call

        to finish before returning `200 OK`. Re-enabling immediately wakes the

        syncer to re-anchor guest `CLOCK_REALTIME` to host UTC.


        State lives in daemon memory and persists across resident
        suspend/resume,

        full-memory snapshots, and live migration. Fresh boots and

        filesystem-only snapshot restores reset `enabled` to `true`.
      operationId: sandbox_runtime_set_clock_sync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SandboxSetClockSyncRequest'
            example:
              enabled: false
      responses:
        '200':
          description: Updated wall-clock sync status
          headers:
            Cache-Control:
              description: Status must not be cached.
              schema:
                type: string
                enum:
                  - no-store
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxClockSyncStatus'
              example:
                enabled: false
                configurable: true
        '400':
          description: Malformed JSON request body
        '401':
          description: Unauthorized. Invalid or missing credentials
        '403':
          description: Forbidden. Your API key does not grant access to this sandbox
        '404':
          description: Sandbox not found
        '409':
          $ref: '#/components/responses/SandboxAutoResumeDisabled'
        '413':
          description: Request body exceeds the 4 KB limit
        '422':
          description: Unknown or invalid field in JSON request body
        '501':
          description: >-
            Wall-clock sync is not configurable on this runtime (code
            CLOCK_SYNC_UNSUPPORTED)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxProxyError'
              example:
                error: >-
                  Wall-clock sync is not configurable under gVisor: the host
                  clock is authoritative.
                code: CLOCK_SYNC_UNSUPPORTED
components:
  schemas:
    SandboxSetClockSyncRequest:
      type: object
      additionalProperties: false
      required:
        - enabled
      properties:
        enabled:
          type: boolean
          description: >-
            Set to false to disable periodic and post-resume host wall-clock
            steps, or true to re-enable and re-anchor immediately.
    SandboxClockSyncStatus:
      type: object
      required:
        - enabled
        - configurable
      properties:
        enabled:
          type: boolean
          description: >-
            Whether host UTC wall-clock syncing is currently active. Always true
            on runtimes where the host clock is authoritative (such as gVisor).
        configurable:
          type: boolean
          description: >-
            Whether this runtime allows toggling wall-clock sync via PUT
            /api/v1/clock-sync or /run/tensorlake/guest.sock.
        reason:
          type: string
          description: Human-readable explanation present when configurable is false.
    SandboxProxyError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
  responses:
    SandboxAutoResumeDisabled:
      description: >-
        The sandbox is suspended and automatic resume is disabled. The proxy
        rejects the request without waking it. Explicitly resume before
        retrying, or PATCH auto_resume to true to allow subsequent traffic to
        wake it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxProxyError'
          example:
            error: >-
              Sandbox 'parked-agent' is suspended and automatic resume is
              disabled; resume it explicitly before sending traffic.
            code: SANDBOX_AUTO_RESUME_DISABLED
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.