# Update a category

Source: https://developers.swell.is/backend-api/categories/update-a-category

Update an existing category.

## Arguments

- `id` (objectId, required): The unique identifier of the category.
- `active` (boolean): Set `true` to make the category visible to customers in a storefront, otherwise, it will be hidden from view.
- `description` (string): A long-form description of the category, often containing HTML or other markup languages.
- `image` (object): Images depicting the category.
  - `caption` (string): A brief description of the image.
  - `file` (object): An object representing the image file.
    - `data` (file): Set or overwrite file data. Use the following format when writing a file from binary data (for example an image): `data[$binary]=<base64 encoded binary daya>`.
    - `filename` (string): Optional file name.
- `images` (array of image): List of images depicting the category.
- `name` (string): A human-friendly name for the category.
- `prices` (object): Price rules to override `price` and `sale_price` when conditions match quantity or account group in a cart. Overrides product prices.
  - `price` (currency): Price applied when conditions are met.
  - `account_group` (string): Customer account group as a condition to apply price.
  - `quantity_max` (int): Maximum quantity as a condition to apply price.
  - `quantity_min` (int): Minimum quantity as a condition to apply price.
- `sale` (boolean): Indicates the variant is on sale and `sale_price` is used by default when the product is added to a cart. Overrides product sale.
- `sale_price` (currency): Sale price used by default when `sale=true`, overriding `price`. Overrides product sale price.
- `shipment_weight` (float): If specified, shipping is calculated based on this shipping weight. Otherwise, it will assume 1 lb/oz/kg depending on your default weight unit. Overrides product shipping weight.
- `sku` (string): Stock keeping unit (SKU) used to track inventory in a warehouse.
- `slug` (string): Unique identifier typically used in URLs. Defaults to `name` converted to lowercase and hyphenated. If the category has a parent, the default slug will be prefixed with the parent slug. Maximum length of 1,000 characters.

## Example request

`PUT /categories/:id`

**cURL**

```bash
$ curl https://api.swell.store/categories/5ca9871f9b14d199072432a1 \
  -u store-id:secret-key \
  -d price=9.99 \
  -X PUT
```

**Node**

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

await swell.put('/categories/{id}', {
  id: '5ca9871f9b14d199072432a1',
  description: 'A bunch of widgets',
  active: false
});
```

**PHP**

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

$swell->put('/categories/{id}', [
  'id' => '5ca9871f9b14d199072432a1',
  'description' => 'A bunch of widgets',
  'active' => false
]);
```

## Example response

```json
{
  "id": "5ca9871f9b14d199072432a1",
  "active": false,
  "name": "Widgets",
  "slug": "widgets",
  "date_created": "2019-04-01T00:00:00.000Z"
  "date_updated": "2019-04-01T00:00:00.000Z",
  "description": 'A bunch of widgets',
  "images": [
    {
      "id": "5ca24abb9c077817e5fe2b37",
      "file": {
        "id": "5ca24abb9c077817e5fe2b38",
        "date_uploaded": "2019-04-02T00:26:23.399Z",
        "length": 66764,
        "md5": "99194f53bfdea832553e7fa8ae8fd80f",
        "content_type": "image/png",
        "url": "http://cdn.swell.store/test/5ca24abb9c077817e5fe2b36/99194f53bfdea832553e7fa8ae8fd80f",
        "width": 940,
        "height": 600
      }
    }
  ],
  "meta_title": null,
  "meta_keywords": null,
  "meta_description": null
}
```
