---
type: api
title: Create a snapshot repository for Elasticsearch resource
description: Important: This API is currently in Tech Preview. While available for use, it is subject to change. Creates a snapshot dependency, allowing this cluster to access snapshots from the source deployment. Currently unavailable in self-hosted ECE.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud/operation/operation-create-deployment-es-resource-snapshot-repository
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud/operation/operation-create-deployment-es-resource-snapshot-repository
products:
  - Elastic Cloud Hosted
---

# Create a snapshot repository for Elasticsearch resource

Availability:

- Server: `https://api.elastic-cloud.com/api/v1`

## Paths

- `POST` `/deployments/{deployment_id}/elasticsearch/{ref_id}/snapshot/repository`

#### Path Parameters

- `deployment_id` (string)
  Identifier for the Deployment
- `ref_id` (string)
  User-specified RefId for the Resource (or '_main' if there is only one)

## Description

Important: This API is currently in Tech Preview. While available for use, it is subject to change. Creates a snapshot dependency, allowing this cluster to access snapshots from the source deployment. Currently unavailable in self-hosted ECE.

## Request Body

`application/json`

The source deployment to link snapshots from

- `source_deployment_id` (string) — required
  Source deployment ID whose snapshots will be accessible from the target cluster

## Responses

#### `202`

The request was accepted and the configuration change will be processed asynchronously

`application/json`

- `message` (string)
  Message indicating the request status
#### `400`

* Cannot create a snapshot dependency from a deployment to itself. (code: `deployments.snapshot_dependency_cannot_link_to_self`)
* Snapshot repository linking is not currently supported in this environment (e.g. self-hosted ECE). (code: `deployments.snapshot_dependency_not_supported_in_env`)
* The request failed validation. (code: `clusters.cluster_invalid_plan`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `404`

* The Resource specified by {ref_id} cannot be found. (code: `deployments.deployment_resource_not_found`)
* The source deployment cannot be found. (code: `deployments.snapshot_dependency_source_not_found`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `500`

Failed to create snapshot dependency. (code: `deployments.snapshot_dependency_internal_error`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code Examples

#### Console

```console
POST /deployments/{deployment_id}/elasticsearch/{ref_id}/snapshot/repository
```

#### curl

```curl
curl -X POST "https://api.elastic-cloud.com/api/v1/deployments/{deployment_id}/elasticsearch/{ref_id}/snapshot/repository"
```

