Tuya Device Control API

Control and command IoT devices

OpenAPI Specification

tuya-device-control-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Tuya Device Management Device Control API
  description: The Tuya Device Management API provides endpoints for querying, controlling, and managing IoT devices registered to a Tuya cloud project. Capabilities include device information retrieval, device control, factory reset, device renaming, sub-device listing, operation log queries, and user-device association management.
  version: '1.0'
  contact:
    name: Tuya Developer Support
    url: https://developer.tuya.com/en/
    email: developer@tuya.com
  termsOfService: https://developer.tuya.com/en/docs/iot/compliance?id=Ka9t0qa3qihn3
servers:
- url: https://openapi.tuyaus.com
  description: Tuya US Data Center
- url: https://openapi.tuyaeu.com
  description: Tuya EU Data Center
- url: https://openapi.tuyain.com
  description: Tuya India Data Center
security:
- tuyaApiKey: []
tags:
- name: Device Control
  description: Control and command IoT devices
paths:
  /v1.0/devices/{device_id}/commands:
    post:
      operationId: sendDeviceCommands
      summary: Send Device Commands
      description: Send one or more control commands to a device. Commands correspond to device data points (DPs) defined in the product schema.
      tags:
      - Device Control
      parameters:
      - $ref: '#/components/parameters/DeviceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                commands:
                  type: array
                  description: List of commands to send to the device
                  items:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Data point code (e.g., switch_1, bright_value)
                      value:
                        description: Command value matching the data point type
              required:
              - commands
      responses:
        '200':
          description: Commands sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: Invalid command
        '401':
          description: Unauthorized
        '404':
          description: Device not found
  /v1.0/devices/{device_id}/status:
    get:
      operationId: getDeviceStatus
      summary: Get Device Status
      description: Retrieve the current status of all data points for a device.
      tags:
      - Device Control
      parameters:
      - $ref: '#/components/parameters/DeviceId'
      responses:
        '200':
          description: Device status data points
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceStatusResponse'
        '401':
          description: Unauthorized
        '404':
          description: Device not found
  /v1.0/devices/{device_id}/reset-factory:
    put:
      operationId: resetDeviceFactory
      summary: Reset Device to Factory Settings
      description: Restore a device to its factory default settings and unpair it from the current account.
      tags:
      - Device Control
      parameters:
      - $ref: '#/components/parameters/DeviceId'
      responses:
        '200':
          description: Device reset initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '401':
          description: Unauthorized
        '404':
          description: Device not found
components:
  schemas:
    DeviceStatusResponse:
      type: object
      properties:
        result:
          type: array
          items:
            $ref: '#/components/schemas/DataPoint'
        success:
          type: boolean
        t:
          type: integer
          format: int64
    SuccessResponse:
      type: object
      properties:
        result:
          type: boolean
          description: Whether the operation succeeded
        success:
          type: boolean
          description: Request success flag
        t:
          type: integer
          format: int64
          description: Response timestamp in milliseconds
    DataPoint:
      type: object
      properties:
        code:
          type: string
          description: Data point code identifier
        value:
          description: Current value of the data point
  parameters:
    DeviceId:
      name: device_id
      in: path
      required: true
      description: Unique device identifier
      schema:
        type: string
  securitySchemes:
    tuyaApiKey:
      type: apiKey
      in: header
      name: client_id
      description: Tuya API uses HMAC-SHA256 signed requests. Include your Access ID as the client_id header and provide a sign header computed from your Access ID, Access Secret, and timestamp.