[[put-snapshot-repo-api]]
=== Create or update snapshot repository API
++++
<titleabbrev>Create or update snapshot repository</titleabbrev>
++++

Registers or updates a <<snapshots-register-repository,snapshot repository>>.

[source,console]
----
PUT /_snapshot/my_repository
{
  "type": "fs",
  "settings": {
    "location": "my_backup_location"
  }
}
----

[[put-snapshot-repo-api-request]]
==== {api-request-title}

`PUT /_snapshot/<repository>`

`POST /_snapshot/<repository>`

[[put-snapshot-repo-api-prereqs]]
==== {api-prereq-title}

* If the {es} {security-features} are enabled, you must have the `manage`
<<privileges-list-cluster,cluster privilege>> to use this API.

// tag::put-repo-api-prereqs[]
* To register a snapshot repository, the cluster's global metadata must be
writeable. Ensure there aren't any <<cluster-read-only,cluster blocks>> that
prevent write access.
// end::put-repo-api-prereqs[]

[[put-snapshot-repo-api-path-params]]
==== {api-path-parms-title}

`<repository>`::
(Required, string)
Name of the snapshot repository to register or update.

[[put-snapshot-repo-api-query-params]]
==== {api-query-parms-title}

IMPORTANT: Several options for this API can be specified using a query parameter
or a request body parameter. If both parameters are specified, only the query
parameter is used.

`master_timeout`::
(Optional, <<time-units, time units>>) Specifies the period of time to wait for
a connection to the master node. If no response is received before the timeout
expires, the request fails and returns an error. Defaults to `30s`.

`timeout`::
(Optional, <<time-units, time units>>) Specifies the period of time to wait for
a response. If no response is received before the timeout expires, the request
fails and returns an error. Defaults to `30s`.

`verify`::
(Optional, Boolean)
If `true`, the request verifies the repository is functional on all master and
data nodes in the cluster. If `false`, this verification is skipped. Defaults to
`true`.
+
You can manually perform this verification using the
<<verify-snapshot-repo-api,verify snapshot repository API>>.

[role="child_attributes"]
[[put-snapshot-repo-api-request-body]]
==== {api-request-body-title}

[[put-snapshot-repo-api-request-type]]
`type`::
(Required, string)
Repository type.
+
.Valid values for `type`
[%collapsible%open]
====

`azure`:: <<repository-azure>>
`gcs`:: <<repository-gcs>>
`s3`:: <<repository-s3>>
`fs`:: <<snapshots-filesystem-repository>>
`source`:: <<snapshots-source-only-repository>>
`url`:: <<snapshots-read-only-repository>>

Other repository types are available through official plugins:

`hdfs`:: {plugins}/repository-hdfs.html[Hadoop Distributed File System (HDFS) repository]
====

[[put-snapshot-repo-api-settings-param]]
`settings`::
(Required, object)
Settings for the repository. Supported settings vary based on the repository
type:
+
--
* <<repository-azure>>
* <<repository-gcs>>
* <<repository-s3>>
* <<snapshots-filesystem-repository>>
* <<snapshots-read-only-repository>>
* <<snapshots-source-only-repository>>

Other repository types are available through official plugins:

* {plugins}/repository-hdfs.html[Hadoop Distributed File System (HDFS) repository]
--

`verify`::
(Optional, Boolean)
If `true`, the request verifies the repository is functional on all master and
data nodes in the cluster. If `false`, this verification is skipped. Defaults to
`true`.
+
You can manually perform this verification using the
<<snapshots-repository-verification,verify snapshot repository API>>.
