# Create an attribute

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

Create a new attribute.

## Arguments

- `name` (string, required): A human-friendly name for the attribute.
- `required` (boolean): Indicates the attribute requires a value when assigned 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`.
- `default` (mixed): Default value used when entering a value for the attribute.
- `filterable` (boolean): Indicates if the category is available in the storefront category page filters. Default: `false`.
- `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.
- `searchable` (boolean): Indicates if this attribute is searchable on the backend. Default: `false`.
- `variant` (boolean): Indicates if this attribute is a variant.

## Example request

`POST /attributes`

**cURL**

```bash
$ curl https://api.swell.store/attributes \
  -u store-id:secret-key \
  -d name=Material \
  -d visible=true \
  -d type=dropdown \
  -d values[0]=Cotton \
  -d values[1]=Polyester \
  -d values[2]=Wool
```

**Node**

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

await swell.post('/attributes', {
  name: 'Material',
  visible: true,
  type: 'dropdown',
  values: [
    'Cotton',
    'Polyester',
    'Wool'
  ],
});
```

**PHP**

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

$swell->post('/attributes', [
  'name' => 'Material',
  'visible' => true,
  'type' => 'dropdown',
  'values' => [
    'Cotton',
    'Polyester',
    'Wool'
  ],
]);
```

## Example response

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