---
type: api
title: Create an index from a source index
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-indices-create-from
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-indices-create-from
products:
  - Elasticsearch Serverless
---

# Create an index from a source index


Availability:

## Paths

- `POST` (also `PUT`) `/_create_from/{source}/{dest}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `source` (string IndexName)
  The source index or data stream name
- `dest` (string IndexName)
  The destination index or data stream name

## Description

Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values.

[Creating an index from source](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/create-index-from-source)

## Request Body

`application/json`

- `mappings_override` ({} TypeMapping) — optional
  Mappings overrides to be applied to the destination index (optional)
  - `all_field` ({} AllField) — optional
    - `analyzer` (string) — required
    - `enabled` (boolean) — required
    - `omit_norms` (boolean) — required
    - `search_analyzer` (string) — required
    - `similarity` (string) — required
    - `store` (boolean) — required
    - `store_term_vector_offsets` (boolean) — required
    - `store_term_vector_payloads` (boolean) — required
    - `store_term_vector_positions` (boolean) — required
    - `store_term_vectors` (boolean) — required
  - `date_detection` (boolean) — optional
  - `dynamic` (enum DynamicMapping) — optional
    Values: `strict`, `runtime`, `true`, `false`
  - `dynamic_date_formats` ([] string) — optional
  - `dynamic_templates` ([] string to DynamicTemplate) — optional
  - `_field_names` ({} FieldNamesField) — optional
    - `enabled` (boolean) — required
  - `index_field` ({} IndexField) — optional
    - `enabled` (boolean) — required
  - `_meta` (Metadata) — optional
  - `numeric_detection` (boolean) — optional
  - `properties` (map string to Property) — optional
  - `_routing` ({} RoutingField) — optional
    - `required` (boolean) — required
  - `_size` ({} SizeField) — optional
    - `enabled` (boolean) — required
  - `_source` ({} SourceField) — optional
    - `enabled` (boolean) — optional
    - `excludes` ([] string) — optional
    - `includes` ([] string) — optional
    - `mode` (enum SourceFieldMode) — optional
      

Supported values include:
  - `disabled`
  - `stored`
  - `synthetic`: Instead of storing source documents on disk exactly as you send them,
 Elasticsearch can reconstruct source content on the fly upon retrieval.
      Values: `disabled`, `stored`, `synthetic`
  - `runtime` (map string to RuntimeField) — optional
    Map values ({} RuntimeField)
    - `fields` (map string to CompositeSubField) — optional
      For type `composite`
      Map values ({} CompositeSubField)
      - `type` (enum RuntimeFieldType) — required
        Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
    - `fetch_fields` ([] RuntimeFieldFetchFields) — optional
      For type `lookup`
      - `field` (string Field) — required
      - `format` (string) — optional
    - `format` (string) — optional
      A custom format for `date` type runtime fields.
    - `input_field` (string Field) — optional
      For type `lookup`
    - `target_field` (string Field) — optional
      For type `lookup`
    - `target_index` (string IndexName) — optional
      For type `lookup`
    - `script` (string Script) — optional
      Painless script executed at query time.
    - `on_script_error` (enum OnScriptError) — optional
      Values: `fail`, `continue`
    - `type` (enum RuntimeFieldType) — required
      Field type, which can be: `boolean`, `composite`, `date`, `double`, `geo_point`, `ip`,`keyword`, `long`, or `lookup`.
      Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
  - `enabled` (boolean) — optional
  - `subobjects` (enum Subobjects) — optional
    Values: `true`, `false`
  - `_data_stream_timestamp` ({} DataStreamTimestamp) — optional
    - `enabled` (boolean) — required
- `settings_override` (IndexSettings) — optional
  Settings overrides to be applied to the destination index (optional)
- `remove_index_blocks` (boolean · default: true) — optional
  If index blocks should be removed when creating destination index (optional)

## Response

`application/json`

- `acknowledged` (boolean)
- `index` (string IndexName)
- `shards_acknowledged` (boolean)
## Code Examples

#### Console

```console
POST _create_from/my-index/my-new-index
```

#### JavaScript

```javascript
const response = await client.indices.createFrom({
  source: "my-index",
  dest: "my-new-index",
  create_from: null,
});
```

#### Python

```python
resp = client.indices.create_from(
    source="my-index",
    dest="my-new-index",
    create_from=None,
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_create_from/my-index/my-new-index" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().createFrom(c -> c
    .dest("my-new-index")
    .source("my-index")
);
```

#### C#

```c#
var response = await client.Indices
    .CreateFromAsync(source: "my-index", dest: "my-new-index", d1 => d1
        .CreateFrom()
    );
```

#### PHP

```php
$requestFactory = Psr17FactoryDiscovery::findRequestFactory();
$request = $requestFactory->createRequest(
    "POST",
    "/_create_from/my-index/my-new-index",
);
$resp = $client->sendRequest($request);
```

#### Ruby

```ruby
response = client.indices.create_from(
  source: "my-index",
  dest: "my-new-index"
)
```

