{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/lights/:selector/toggle","auth":"required","examples":{"codes":[{"code":"curl -X POST \"https://api.lifx.com/v1/lights/all/toggle\" \\\n -H \"Authorization: Bearer [[app:Token]]\"","language":"curl"},{"language":"php","code":"<?php\n\n$link = \"https://api.lifx.com/v1/lights/all/toggle\";\n$authToken = \"[[app:Token]]\";\n\n$headers = array('Authorization: Bearer ' . $authToken);\n\n$ch = curl_init($link);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\ncurl_setopt($ch, CURLOPT_POST, true);\n$response = curl_exec($ch);\n\n?>"},{"code":"import requests\n\ntoken = \"[[app:Token]]\"\n\nheaders = {\n \"Authorization\": \"Bearer %s\" % token,\n}\n\nresponse = requests.post('https://api.lifx.com/v1/lights/all/toggle', headers=headers)","language":"python"}]},"method":"post","params":[{"name":"selector","type":"string","default":"","desc":"The [selector](doc:selectors) to limit which lights are toggled.","required":true,"in":"path","ref":"","_id":"55810dbba5474a0d00d9437f"},{"name":"duration","type":"double","default":"1.0","desc":"The time is seconds to spend perfoming the power toggle.","required":false,"in":"body","ref":"","_id":"55c2b44ae61e860d00312325"}],"results":{"codes":[{"status":"2XX","name":"","code":"{\n \"results\": [\n {\n \"id\": \"d3b2f2d97452\",\n \"label\": \"Left Lamp\",\n \"status\": \"ok\"\n }\n ]\n}","language":"json"}]},"settings":""},"next":{"description":"","pages":[]},"title":"Toggle Power","type":"endpoint","slug":"toggle-power","excerpt":"","body":"Turn off lights if any of them are on, or turn them on if they are all off. All lights matched by the selector will share the same power state after this action. Physically powered off lights are ignored.","updates":["56d803fe3513421d0093442f"],"order":5,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"55f28173f9f3991900f38a20","user":"557e2561eb75d80d00af3dab","editedParams":true,"project":"54ebb40d6423300d003672c0","version":{"version":"1","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["55f28172f9f3991900f38a14","55f28172f9f3991900f38a15","55f28172f9f3991900f38a16","55f66acb297b37170058accb","5d229ff5e59b8e003ab3a9da"],"_id":"55f28172f9f3991900f38a13","project":"54ebb40d6423300d003672c0","releaseDate":"2015-09-11T07:23:30.065Z","createdAt":"2015-09-11T07:23:30.065Z","__v":3},"category":{"sync":{"isSync":false,"url":""},"pages":["55f28173f9f3991900f38a1d","55f28173f9f3991900f38a1e","55f28173f9f3991900f38a1f","55f28173f9f3991900f38a20","55f28173f9f3991900f38a21","55f28173f9f3991900f38a22","55f28173f9f3991900f38a23","55f28173f9f3991900f38a24","55f28173f9f3991900f38a25","55f28173f9f3991900f38a26","55f28173f9f3991900f38a27","55f63d46fe4cce21005c785e","55f65cc16be5ea0d00bbbf4c"],"title":"API Endpoints","slug":"api-endpoints","order":2,"from_sync":false,"reference":false,"_id":"55f28172f9f3991900f38a16","__v":3,"createdAt":"2015-06-17T05:23:31.147Z","project":"54ebb40d6423300d003672c0","version":"55f28172f9f3991900f38a13"},"__v":2,"createdAt":"2015-06-17T06:03:39.251Z","editedParams2":true,"githubsync":"","parentDoc":null}
postToggle Power
Definition
{{ api_url }}{{ page_api_url }}
Parameters
Path Params
selector:
required
string
The [selector](doc:selectors) to limit which lights are toggled.
Body Params
duration:
double1.0
The time is seconds to spend perfoming the power toggle.