> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Copy using an accessor

> Copies a part of the entity data to another location within the entity data, while leaving the original content unchanged.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Copies a part of the entity data to another location within the entity data, while leaving the original content unchanged. Instead of pointing at a single fixed path, you choose a way of reading values for the source and a way of writing values for the destination. That lets you copy several matching values at once, such as every product SKU in an order, and place them all under a new location in one step. If you do not need to keep the original, use [Move using an accessor](/references/transformer/accessor-move) instead.

This documentation describes: [Schema](/schemas/transformer/accessor-copy)

## Fields

<FormField property="source" label="Source" required diType="accessor">
  The way of reading the values you want to copy. Every value this reads is copied to the destination. For example, a pattern accessor matching `order.items.*.sku` reads the SKU of every item in an order.
</FormField>

<FormField property="destination" label="Destination" required diType="accessor">
  The way of writing the copied values into the entity. For example, a key accessor with a root of `skus` places the values under a new `skus` location.
</FormField>

<FormField property="stripEnclosures" label="Strip enclosures from keys">
  Controls how a source path that contains dots is treated at the destination. When on (the default), a path such as `order.items.0.sku` is read as a nested path, so the copied value keeps that nested structure under the destination. When off, the whole path is kept as a single literal key. Leave it on unless you specifically want the dotted path preserved as one key.
</FormField>

## Sample data

| Field                      | Value                                         |
| -------------------------- | --------------------------------------------- |
| Source                     | Pattern accessor matching `order.items.*.sku` |
| Destination                | Key accessor with root `skus`                 |
| Strip enclosures from keys | On (default)                                  |

Input:

```json theme={null}
{
    "order": {
        "items": [
            { "sku": "A1", "qty": 2 },
            { "sku": "B2", "qty": 5 }
        ]
    }
}
```

Output:

```json theme={null}
{
    "order": {
        "items": [
            { "sku": "A1", "qty": 2 },
            { "sku": "B2", "qty": 5 }
        ]
    },
    "skus": {
        "order": {
            "items": [
                { "sku": "A1" },
                { "sku": "B2" }
            ]
        }
    }
}
```

The original `order.items` is untouched, and a copy of every matched SKU now also lives under the new `skus` location, keeping the path it came from.

```json Configuration theme={null}
{
  "prototype": "accessor-copy",
  "parameters": {
    "source": { "prototype": "pattern", "parameters": { "pattern": "order.items.*.sku" } },
    "destination": { "prototype": "key", "parameters": { "root": "skus" } }
  }
}
```
