REST API / Service Calls / Specify Target

Hi all,

I want to call services using the REST API.

POST /api/services/<domain>/<service>

How can I specify targets apart from entities?

I have tried different JSON structures, but without success. Only with single entities I was successful.

Hi,
it’s been a while since the last message but maybe someone finds this interessting.

to call a service with a target entity simply add “entity_id” to your json data.
For example:

curlData='{
  "entity_id": "tts.piper",
  "media_player_entity_id": "media_player.sonos_one",
  "message": "May the force be with you"
}';

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $token" \
  -d "$curlData" \
  http://192.168.1.1:8123/api/services/tts/speak
1 Like