put-lifecycle.asciidoc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-put-lifecycle]]
  4. === Create Lifecycle Policy API
  5. ++++
  6. <titleabbrev>Create Policy</titleabbrev>
  7. ++++
  8. beta[]
  9. Creates or updates lifecycle policy.
  10. ==== Request
  11. `PUT _ilm/policy/<policy_id>`
  12. ==== Description
  13. Creates a lifecycle policy. If the specified policy exists, the policy is
  14. replaced and the policy version is incremented.
  15. NOTE: Only the latest version of the policy is stored, you cannot revert to
  16. previous versions.
  17. ==== Path Parameters
  18. `policy` (required)::
  19. (string) Identifier for the policy.
  20. ==== Request Parameters
  21. include::{docdir}/rest-api/timeoutparms.asciidoc[]
  22. ==== Authorization
  23. You must have the `manage_ilm` cluster privilege to use this API. You must
  24. also have the `manage` index privilege on all indices being managed by `policy`.
  25. All operations executed by {Ilm} for a policy are executed as the user that
  26. put the latest version of a policy.
  27. For more information, see {stack-ov}/security-privileges.html[Security Privileges].
  28. ==== Examples
  29. The following example creates a new policy named `my_policy`:
  30. [source,js]
  31. --------------------------------------------------
  32. PUT _ilm/policy/my_policy
  33. {
  34. "policy": {
  35. "phases": {
  36. "warm": {
  37. "min_age": "10d",
  38. "actions": {
  39. "forcemerge": {
  40. "max_num_segments": 1
  41. }
  42. }
  43. },
  44. "delete": {
  45. "min_age": "30d",
  46. "actions": {
  47. "delete": {}
  48. }
  49. }
  50. }
  51. }
  52. }
  53. --------------------------------------------------
  54. // CONSOLE
  55. // TEST
  56. If the request succeeds, you receive the following result:
  57. [source,js]
  58. ----
  59. {
  60. "acknowledged": true
  61. }
  62. ----
  63. // CONSOLE
  64. // TESTRESPONSE