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

# Call a service on an entity

> Executes a service action on a specific entity. E.g. domain=light, service=turn_on.



## OpenAPI

````yaml https://portal.unicontrol.me/v1/openapi post /v1/service/{domain}/{service}
openapi: 3.1.0
info:
  title: Unicontrol API
  description: Welcome
  version: 1.0.0
servers:
  - url: http://0.0.0.0:3000
    description: Local Server
  - url: https://portal.test.flexhome.casa
    description: Development
  - url: https://portal.unicontrol.me
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/service/{domain}/{service}:
    post:
      tags:
        - Services
      summary: Call a service on an entity
      description: >-
        Executes a service action on a specific entity. E.g. domain=light,
        service=turn_on.
      operationId: postV1ServiceByDomainByService
      parameters:
        - in: path
          name: domain
          required: true
          schema:
            type: string
          description: 'Domínio da entidade (ex: light, switch, cover)'
        - in: path
          name: service
          required: true
          schema:
            type: string
          description: 'Serviço a executar (ex: turn_on, turn_off, set_value)'
        - in: header
          name: X-Organization-Id
          required: false
          schema:
            type: string
          description: >-
            ID da organização para contexto (opcional). Quando presente, filtra
            recursos da org.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - entity_id
              properties:
                entity_id:
                  type: string
                  description: entity_id da entidade alvo
                data:
                  type: object
                  description: 'Dados adicionais do serviço (ex: brightness, color)'
            example:
              entity_id: light.sala
              data:
                brightness: 200
        required: true
      responses:
        '200':
          description: Service executed
          content:
            application/json:
              schema:
                type: object
              example:
                entity_id: light.sala
                data:
                  brightness: 200
        '400':
          description: Dados inválidos
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: validation error
        '401':
          description: Não autenticado
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: unauthorized
        '403':
          description: No permission to control this entity
          content:
            application/json:
              example:
                error: forbidden
        '404':
          description: Recurso não encontrado
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: not found
        '501':
          description: Service not implemented for this integration
          content:
            application/json:
              example:
                message: 'Service not found: light.turn_rainbow'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````