<commit_before>[role="xpack"]
[testenv="basic"]
[[update-license]]
=== Update license API
++++
<titleabbrev>Update license</titleabbrev>
++++

This API enables you to update your license.

[float]
==== Request

`PUT /_license`

[float]
==== Description

You can update your license at runtime without shutting down your nodes.
License updates take effect immediately.  If the license you are installing does
not support all of the features that were available with your previous license,
however, you are notified in the response.  You must then re-submit the API
request with the `acknowledge` parameter set to `true`.

For more information about the different types of licenses, see
https://www.elastic.co/subscriptions.

[float]
==== Query Parameters

`acknowledge`::
  (boolean) Specifies whether you acknowledge the license changes. The default
  value is `false`.

[float]
==== Request Body

`licenses`::
  (array) A sequence of one or more JSON documents containing the license
  information.


[float]
==== Authorization

If {es} {security-features} are enabled, you need `manage` cluster privileges to
install the license.

If {es} {security-features} are enabled and you are installing a gold or platinum
license, you must enable TLS on the transport networking layer before you
install the license. See <<configuring-tls>>.

[float]
==== Examples

The following example updates to a basic license:

[source,js]
------------------------------------------------------------
POST /_license
{
  "licenses": [
    {
      "uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
      "type":"basic",
      "issue_date_in_millis":1411948800000,
      "expiry_date_in_millis":1914278399999,
      "max_nodes":1,
      "issued_to":"issuedTo",
      "issuer":"issuer",
      "signature":"xx"
    }
    ]
}
------------------------------------------------------------
// CONSOLE
// TEST[skip:license testing issues]

NOTE: These values are invalid; you must substitute the appropriate content
from your license file.

You can alternatively use a `curl` command, for example:

[source,js]
[source,shell]
------------------------------------------------------------
curl -XPUT -u <user> 'http://<host>:<port>/_license' -H "Content-Type: application/json" -d @license.json
------------------------------------------------------------
// NOTCONSOLE

On Windows machine, use the following command:

[source,shell]
------------------------------------------------------------
gc .\license.json |  Invoke-WebRequest -uri http://<host>:<port>/_license -Credential elastic -Method Put -ContentType "application/json"
------------------------------------------------------------<commit_msg>Update Windows command to support prettified json licenses (#40375)<commit_after>[role="xpack"]
[testenv="basic"]
[[update-license]]
=== Update license API
++++
<titleabbrev>Update license</titleabbrev>
++++

This API enables you to update your license.

[float]
==== Request

`PUT /_license`

[float]
==== Description

You can update your license at runtime without shutting down your nodes.
License updates take effect immediately.  If the license you are installing does
not support all of the features that were available with your previous license,
however, you are notified in the response.  You must then re-submit the API
request with the `acknowledge` parameter set to `true`.

For more information about the different types of licenses, see
https://www.elastic.co/subscriptions.

[float]
==== Query Parameters

`acknowledge`::
  (boolean) Specifies whether you acknowledge the license changes. The default
  value is `false`.

[float]
==== Request Body

`licenses`::
  (array) A sequence of one or more JSON documents containing the license
  information.


[float]
==== Authorization

If {es} {security-features} are enabled, you need `manage` cluster privileges to
install the license.

If {es} {security-features} are enabled and you are installing a gold or platinum
license, you must enable TLS on the transport networking layer before you
install the license. See <<configuring-tls>>.

[float]
==== Examples

The following example updates to a basic license:

[source,js]
------------------------------------------------------------
POST /_license
{
  "licenses": [
    {
      "uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
      "type":"basic",
      "issue_date_in_millis":1411948800000,
      "expiry_date_in_millis":1914278399999,
      "max_nodes":1,
      "issued_to":"issuedTo",
      "issuer":"issuer",
      "signature":"xx"
    }
    ]
}
------------------------------------------------------------
// CONSOLE
// TEST[skip:license testing issues]

NOTE: These values are invalid; you must substitute the appropriate content
from your license file.

You can alternatively use a `curl` command, for example:

[source,js]
[source,shell]
------------------------------------------------------------
curl -XPUT -u <user> 'http://<host>:<port>/_license' -H "Content-Type: application/json" -d @license.json
------------------------------------------------------------
// NOTCONSOLE

On Windows machine, use the following command:

[source,shell]
------------------------------------------------------------
Invoke-WebRequest -uri http://<host>:<port>/_xpack/license -Credential elastic -Method Put -ContentType "application/json" -InFile .\license.json
------------------------------------------------------------
{'fraction_non_alphanumeric': 0.23131014063656552, 'fraction_numerical': 0.019059955588452998, 'mean_word_length': 2.4015103838892387, 'pattern_counts': {'":': 18, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1880877', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1371, 'n_words': 514}