Create or update a watch
When a watch is registered, a new document that represents the watch is added to the .watches
index and its trigger is immediately registered with the relevant trigger engine.
Typically for the schedule
trigger, the scheduler is the trigger engine.
IMPORTANT: You must use Kibana or this API to create a watch.
Do not add a watch directly to the .watches
index by using the Elasticsearch index API.
If Elasticsearch security features are enabled, do not give users write privileges on the .watches
index.
When you add a watch you can also define its initial active state by setting the active parameter.
When Elasticsearch security features are enabled, your watch can index or search only on indices for which the user that stored the watch has privileges.
If the user is able to read index a
, but not index b
, the same will apply when the watch runs.
Path parameters
-
Watch ID
Query parameters
-
active boolean
Specify whether the watch is in/active by default
-
if_primary_term number
only update the watch if the last operation that has changed the watch has the specified primary term
-
if_seq_no number
only update the watch if the last operation that has changed the watch has the specified sequence number
-
version number
Explicit version number for concurrency control
curl \
-X PUT http://api.example.com/_watcher/watch/{id} \
-H "Content-Type: application/json" \
-d '{"actions":{"additionalProperty1":{"action_type":"email","condition":{"always":{},"array_compare":{"additionalProperty1":{"path":"string"},"additionalProperty2":{"path":"string"}},"compare":{"additionalProperty1":{},"additionalProperty2":{}},"never":{},"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"}},"foreach":"string","max_iterations":42.0,"name":"string","throttle_period":"string","":{"auth":{"basic":{"password":"string","username":"string"}},"body":"string","connection_timeout":"string","headers":{"additionalProperty1":"string","additionalProperty2":"string"},"host":"string","method":"head","params":{"additionalProperty1":"string","additionalProperty2":"string"},"path":"string","port":42.0,"proxy":{"host":"string","port":42.0},"read_timeout":"string","scheme":"http","url":"string"},"transform":{"chain":[{}],"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"},"search":{"request":{"body":{"query":{}},"indices":["string"],"indices_options":{"allow_no_indices":true,"expand_wildcards":"string","ignore_unavailable":true,"ignore_throttled":true},"search_type":"query_then_fetch","template":{"explain":true,"id":"string","params":{},"profile":true,"source":"string"},"rest_total_hits_as_int":true},"timeout":"string"}},"index":{"index":"string","doc_id":"string","refresh":"true","op_type":"index","timeout":"string","execution_time_field":"string"},"logging":{"level":"string","text":"string","category":"string"},"slack":{"account":"string","message":{"attachments":[{"author_icon":"string","author_link":"string","author_name":"string","color":"string","fallback":"string","fields":[{}],"footer":"string","footer_icon":"string","image_url":"string","pretext":"string","text":"string","thumb_url":"string","title":"string","title_link":"string"}],"dynamic_attachments":{"attachment_template":{"author_icon":"string","author_link":"string","author_name":"string","color":"string","fallback":"string","fields":[{}],"footer":"string","footer_icon":"string","image_url":"string","pretext":"string","text":"string","thumb_url":"string","title":"string","title_link":"string"},"list_path":"string"},"from":"string","icon":"string","text":"string","to":["string"]}}},"additionalProperty2":{"action_type":"email","condition":{"always":{},"array_compare":{"additionalProperty1":{"path":"string"},"additionalProperty2":{"path":"string"}},"compare":{"additionalProperty1":{},"additionalProperty2":{}},"never":{},"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"}},"foreach":"string","max_iterations":42.0,"name":"string","throttle_period":"string","":{"auth":{"basic":{"password":"string","username":"string"}},"body":"string","connection_timeout":"string","headers":{"additionalProperty1":"string","additionalProperty2":"string"},"host":"string","method":"head","params":{"additionalProperty1":"string","additionalProperty2":"string"},"path":"string","port":42.0,"proxy":{"host":"string","port":42.0},"read_timeout":"string","scheme":"http","url":"string"},"transform":{"chain":[{}],"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"},"search":{"request":{"body":{"query":{}},"indices":["string"],"indices_options":{"allow_no_indices":true,"expand_wildcards":"string","ignore_unavailable":true,"ignore_throttled":true},"search_type":"query_then_fetch","template":{"explain":true,"id":"string","params":{},"profile":true,"source":"string"},"rest_total_hits_as_int":true},"timeout":"string"}},"index":{"index":"string","doc_id":"string","refresh":"true","op_type":"index","timeout":"string","execution_time_field":"string"},"logging":{"level":"string","text":"string","category":"string"},"slack":{"account":"string","message":{"attachments":[{"author_icon":"string","author_link":"string","author_name":"string","color":"string","fallback":"string","fields":[{}],"footer":"string","footer_icon":"string","image_url":"string","pretext":"string","text":"string","thumb_url":"string","title":"string","title_link":"string"}],"dynamic_attachments":{"attachment_template":{"author_icon":"string","author_link":"string","author_name":"string","color":"string","fallback":"string","fields":[{}],"footer":"string","footer_icon":"string","image_url":"string","pretext":"string","text":"string","thumb_url":"string","title":"string","title_link":"string"},"list_path":"string"},"from":"string","icon":"string","text":"string","to":["string"]}}}},"condition":{"always":{},"array_compare":{"additionalProperty1":{"path":"string"},"additionalProperty2":{"path":"string"}},"compare":{"additionalProperty1":{},"additionalProperty2":{}},"never":{},"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"}},"input":{"chain":{"inputs":[{"*":{}}]},"http":{"extract":["string"],"request":{"auth":{"basic":{"password":"string","username":"string"}},"body":"string","connection_timeout":"string","headers":{"additionalProperty1":"string","additionalProperty2":"string"},"host":"string","method":"head","params":{"additionalProperty1":"string","additionalProperty2":"string"},"path":"string","port":42.0,"proxy":{"host":"string","port":42.0},"read_timeout":"string","scheme":"http","url":"string"},"response_content_type":"json"},"search":{"extract":["string"],"request":{"body":{"query":{}},"indices":["string"],"indices_options":{"allow_no_indices":true,"expand_wildcards":"string","ignore_unavailable":true,"ignore_throttled":true},"search_type":"query_then_fetch","template":{"explain":true,"id":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"profile":true,"source":"string"},"rest_total_hits_as_int":true},"timeout":"string"},"simple":{"additionalProperty1":{},"additionalProperty2":{}}},"metadata":{"additionalProperty1":{},"additionalProperty2":{}},"throttle_period":"string","transform":{"chain":[{}],"script":{"lang":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"source":"string","id":"string"},"search":{"request":{"body":{"query":{}},"indices":["string"],"indices_options":{"allow_no_indices":true,"expand_wildcards":"string","ignore_unavailable":true,"ignore_throttled":true},"search_type":"query_then_fetch","template":{"explain":true,"id":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"profile":true,"source":"string"},"rest_total_hits_as_int":true},"timeout":"string"}},"trigger":{"schedule":{"timezone":"string","cron":"string","daily":{"at":["string"]},"hourly":{"minute":[42.0]},"interval":"string","monthly":{"at":["string"],"on":[42.0]},"weekly":{"at":["string"],"on":["sunday"]},"yearly":{"at":["string"],"int":["january"],"on":[42.0]}}}}'
{
"actions": {
"additionalProperty1": {
"action_type": "email",
"condition": {
"always": {},
"array_compare": {
"additionalProperty1": {
"path": "string"
},
"additionalProperty2": {
"path": "string"
}
},
"compare": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"never": {},
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
}
},
"foreach": "string",
"max_iterations": 42.0,
"name": "string",
"throttle_period": "string",
"": {
"auth": {
"basic": {
"password": "string",
"username": "string"
}
},
"body": "string",
"connection_timeout": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"host": "string",
"method": "head",
"params": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"path": "string",
"port": 42.0,
"proxy": {
"host": "string",
"port": 42.0
},
"read_timeout": "string",
"scheme": "http",
"url": "string"
},
"transform": {
"chain": [
{}
],
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
},
"search": {
"request": {
"body": {
"query": {}
},
"indices": [
"string"
],
"indices_options": {
"allow_no_indices": true,
"expand_wildcards": "string",
"ignore_unavailable": true,
"ignore_throttled": true
},
"search_type": "query_then_fetch",
"template": {
"explain": true,
"id": "string",
"params": {},
"profile": true,
"source": "string"
},
"rest_total_hits_as_int": true
},
"timeout": "string"
}
},
"index": {
"index": "string",
"doc_id": "string",
"refresh": "true",
"op_type": "index",
"timeout": "string",
"execution_time_field": "string"
},
"logging": {
"level": "string",
"text": "string",
"category": "string"
},
"slack": {
"account": "string",
"message": {
"attachments": [
{
"author_icon": "string",
"author_link": "string",
"author_name": "string",
"color": "string",
"fallback": "string",
"fields": [
{}
],
"footer": "string",
"footer_icon": "string",
"image_url": "string",
"pretext": "string",
"text": "string",
"thumb_url": "string",
"title": "string",
"title_link": "string"
}
],
"dynamic_attachments": {
"attachment_template": {
"author_icon": "string",
"author_link": "string",
"author_name": "string",
"color": "string",
"fallback": "string",
"fields": [
{}
],
"footer": "string",
"footer_icon": "string",
"image_url": "string",
"pretext": "string",
"text": "string",
"thumb_url": "string",
"title": "string",
"title_link": "string"
},
"list_path": "string"
},
"from": "string",
"icon": "string",
"text": "string",
"to": [
"string"
]
}
}
},
"additionalProperty2": {
"action_type": "email",
"condition": {
"always": {},
"array_compare": {
"additionalProperty1": {
"path": "string"
},
"additionalProperty2": {
"path": "string"
}
},
"compare": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"never": {},
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
}
},
"foreach": "string",
"max_iterations": 42.0,
"name": "string",
"throttle_period": "string",
"": {
"auth": {
"basic": {
"password": "string",
"username": "string"
}
},
"body": "string",
"connection_timeout": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"host": "string",
"method": "head",
"params": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"path": "string",
"port": 42.0,
"proxy": {
"host": "string",
"port": 42.0
},
"read_timeout": "string",
"scheme": "http",
"url": "string"
},
"transform": {
"chain": [
{}
],
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
},
"search": {
"request": {
"body": {
"query": {}
},
"indices": [
"string"
],
"indices_options": {
"allow_no_indices": true,
"expand_wildcards": "string",
"ignore_unavailable": true,
"ignore_throttled": true
},
"search_type": "query_then_fetch",
"template": {
"explain": true,
"id": "string",
"params": {},
"profile": true,
"source": "string"
},
"rest_total_hits_as_int": true
},
"timeout": "string"
}
},
"index": {
"index": "string",
"doc_id": "string",
"refresh": "true",
"op_type": "index",
"timeout": "string",
"execution_time_field": "string"
},
"logging": {
"level": "string",
"text": "string",
"category": "string"
},
"slack": {
"account": "string",
"message": {
"attachments": [
{
"author_icon": "string",
"author_link": "string",
"author_name": "string",
"color": "string",
"fallback": "string",
"fields": [
{}
],
"footer": "string",
"footer_icon": "string",
"image_url": "string",
"pretext": "string",
"text": "string",
"thumb_url": "string",
"title": "string",
"title_link": "string"
}
],
"dynamic_attachments": {
"attachment_template": {
"author_icon": "string",
"author_link": "string",
"author_name": "string",
"color": "string",
"fallback": "string",
"fields": [
{}
],
"footer": "string",
"footer_icon": "string",
"image_url": "string",
"pretext": "string",
"text": "string",
"thumb_url": "string",
"title": "string",
"title_link": "string"
},
"list_path": "string"
},
"from": "string",
"icon": "string",
"text": "string",
"to": [
"string"
]
}
}
}
},
"condition": {
"always": {},
"array_compare": {
"additionalProperty1": {
"path": "string"
},
"additionalProperty2": {
"path": "string"
}
},
"compare": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"never": {},
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
}
},
"input": {
"chain": {
"inputs": [
{
"*": {}
}
]
},
"http": {
"extract": [
"string"
],
"request": {
"auth": {
"basic": {
"password": "string",
"username": "string"
}
},
"body": "string",
"connection_timeout": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"host": "string",
"method": "head",
"params": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"path": "string",
"port": 42.0,
"proxy": {
"host": "string",
"port": 42.0
},
"read_timeout": "string",
"scheme": "http",
"url": "string"
},
"response_content_type": "json"
},
"search": {
"extract": [
"string"
],
"request": {
"body": {
"query": {}
},
"indices": [
"string"
],
"indices_options": {
"allow_no_indices": true,
"expand_wildcards": "string",
"ignore_unavailable": true,
"ignore_throttled": true
},
"search_type": "query_then_fetch",
"template": {
"explain": true,
"id": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"profile": true,
"source": "string"
},
"rest_total_hits_as_int": true
},
"timeout": "string"
},
"simple": {
"additionalProperty1": {},
"additionalProperty2": {}
}
},
"metadata": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"throttle_period": "string",
"transform": {
"chain": [
{}
],
"script": {
"lang": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"source": "string",
"id": "string"
},
"search": {
"request": {
"body": {
"query": {}
},
"indices": [
"string"
],
"indices_options": {
"allow_no_indices": true,
"expand_wildcards": "string",
"ignore_unavailable": true,
"ignore_throttled": true
},
"search_type": "query_then_fetch",
"template": {
"explain": true,
"id": "string",
"params": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"profile": true,
"source": "string"
},
"rest_total_hits_as_int": true
},
"timeout": "string"
}
},
"trigger": {
"schedule": {
"timezone": "string",
"cron": "string",
"daily": {
"at": [
"string"
]
},
"hourly": {
"minute": [
42.0
]
},
"interval": "string",
"monthly": {
"at": [
"string"
],
"on": [
42.0
]
},
"weekly": {
"at": [
"string"
],
"on": [
"sunday"
]
},
"yearly": {
"at": [
"string"
],
"int": [
"january"
],
"on": [
42.0
]
}
}
}
}
{
"created": true,
"_id": "string",
"_primary_term": 42.0,
"_seq_no": 42.0,
"_version": 42.0
}