# Update an existing record

`PUT /api/products/{id}`

Authentication (security requirement alternatives):

```json
[
  {
    "bearer": []
  }
]
```

- bearer: http (bearer), header JWT. Enter JWT token

Parameters:

- `id` (path, string, required)
  Type: string

Request body: application/json (required)

Type: object

Schema: [UpdateProductDTO](https://sourcey-gauzy.pages.dev/api-reference/models/updateproductdto/index.md)

- `name` (optional)
  Type: string

- `description` (optional)
  Type: string

- `enabled` (optional)
  Type: boolean

- `code` (optional)
  Type: string

- `imageUrl` (optional)
  Type: string

- `featuredImage` (optional)
  Type: object

- `variants` (optional)
  Type: string

- `productTypeId` (optional)
  Type: string

- `productCategoryId` (optional)
  Type: string

- `productType` (optional)
  Type: object

- `productCategory` (optional)
  Type: object

- `tags` (optional)
  Type: array
  
  Items:
    Type: object

- `type` (optional)
  Type: object

- `category` (optional)
  Type: object

- `optionGroupUpdateInputs` (optional)
  Type: array
  
  Items:
    Type: object

- `optionGroupCreateInputs` (optional)
  Type: object

- `optionGroupDeleteInputs` (optional)
  Type: object

- `optionDeleteInputs` (optional)
  Type: object

- `translations` (optional)
  Type: object

- `language` (optional)
  Type: string

Responses:

- 201: The record has been successfully edited.

- 400: Invalid input, The response body may contain clues as to what went wrong

- 401: Unauthorized

- 403: Forbidden

- 404: Record not found

## Examples

### cURL

```bash
curl -X PUT 'http://localhost:3000/api/products/string' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "string",
  "description": "string",
  "enabled": true,
  "code": "string",
  "imageUrl": "string",
  "featuredImage": {},
  "variants": "string",
  "productTypeId": "string",
  "productCategoryId": "string",
  "productType": {},
  "productCategory": {},
  "tags": [
    {}
  ],
  "type": {},
  "category": {},
  "optionGroupUpdateInputs": [
    {}
  ],
  "optionGroupCreateInputs": {},
  "optionGroupDeleteInputs": {},
  "optionDeleteInputs": {},
  "translations": {},
  "language": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "name": "string",
  "description": "string",
  "enabled": true,
  "code": "string",
  "imageUrl": "string",
  "featuredImage": {},
  "variants": "string",
  "productTypeId": "string",
  "productCategoryId": "string",
  "productType": {},
  "productCategory": {},
  "tags": [
    {}
  ],
  "type": {},
  "category": {},
  "optionGroupUpdateInputs": [
    {}
  ],
  "optionGroupCreateInputs": {},
  "optionGroupDeleteInputs": {},
  "optionDeleteInputs": {},
  "translations": {},
  "language": "string"
}`;

const response = await fetch('http://localhost:3000/api/products/string', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "name": "string",
  "description": "string",
  "enabled": true,
  "code": "string",
  "imageUrl": "string",
  "featuredImage": {},
  "variants": "string",
  "productTypeId": "string",
  "productCategoryId": "string",
  "productType": {},
  "productCategory": {},
  "tags": [
    {}
  ],
  "type": {},
  "category": {},
  "optionGroupUpdateInputs": [
    {}
  ],
  "optionGroupCreateInputs": {},
  "optionGroupDeleteInputs": {},
  "optionDeleteInputs": {},
  "translations": {},
  "language": "string"
}'''

response = requests.put(
    'http://localhost:3000/api/products/string',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
