# Update an attribute

Source: https://developers.swell.is/backend-api/attributes/update-an-attribute

Update an existing attribute using the ID, that was returned when created. Updating performs a merge operation. To explicitly override values such as arrays, use the `$set` operator.

## Arguments

- `id` (string, required): Unique identifier for the attribute. Defaults to attribute `name` underscored. Default: `{"$formula":"underscore(name)"}`.
- `name` (string, required): A human-friendly name for the attribute.
- `default` (mixed): Default value used when entering a value for the attribute.
- `localized` (boolean): Indicates if this attribute supports localized content. Default: `false`.
- `multi` (boolean): When attribute `type=image` is indicated, the attribute contains multiple images.
- `products` (Product): Expandable list of products using the attribute.
- `required` (boolean): Set `true` to make the attribute require a value when added to a product. Default: `false`.
- `type` (enum): Input type used when entering a value for the attribute. Possible values: `short_text`, `long_text`, `asset`, `lookup`, `boolean`, `select`, `number`, `date`, `tags`, `icon`, `collection`, `field_group`.
- `values` (array of child_scalar): List of the attribute's associated select options used with attribute `type` of `checkbox`, `radio`, or `select`.
- `visible` (boolean): Indicates the attribute is visible to customers. Default: `false`.
- `variant` (boolean): Indicates if this attribute is a variant.

## Example request

`PUT /attributes/:id`

**cURL**

```bash
$ curl https://api.swell.store/attributes/material \
  -u store-id:secret-key \
  -d required=true \
  -X PUT
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.put('/attributes/{id}', {
  id: 'material',
  required: true
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->put('/attributes/{id}', [
  'id' => 'material',
  'required' => true
]);
```

## Example response

```json
{
  "id": "material",
  "name": "Material",
  "date_created": "2019-04-01T00:00:00.000Z",
  "date_updated": "2019-04-01T00:00:00.000Z",
  "required": true,
  "visible": true,
  "type": "dropdown",
  "values": [
    "Cotton",
    "Polyester",
    "Wool"
  ]
}
```
