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

# Mettre à jour un produit parent

> Mettre à jour un produit parent existant

## Autorisation

<ParamField header="Authorization" type="string" required>
  Token Bearer pour l'authentification. Format : `Bearer qwoty_your_token`
</ParamField>

## Paramètres de chemin

<ParamField path="id" type="string" required>
  UUID du produit parent à mettre à jour
</ParamField>

## Corps de la requête

<ParamField body="recurrence_type" type="string">
  Modèle de facturation (`one_off` ou `recurring`)
</ParamField>

<ParamField body="name" type="string">
  Nom du produit parent
</ParamField>

<ParamField body="description" type="string">
  Description du produit
</ParamField>

<ParamField body="is_active" type="boolean">
  Statut actif
</ParamField>

<ParamField body="id_crm" type="string">
  ID CRM externe
</ParamField>

<ParamField body="id_erp" type="string">
  ID ERP externe
</ParamField>

<ParamField body="id_accounting" type="string">
  ID comptable externe
</ParamField>

`reference` ne fait pas partie du payload du produit parent pour PATCH (il est stocké sur la variante par défaut). L'envoi de `reference` dans le corps entraîne une erreur de validation.

## Exemples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH https://qwoty.app/api/product-parents/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Product Name",
      "description": "Updated description",
      "is_active": false
    }'
  ```

  ```javascript JavaScript theme={null}
  const productParentId = '550e8400-e29b-41d4-a716-446655440000'

  const response = await fetch(
    `https://qwoty.app/api/product-parents/${productParentId}`,
    {
      method: 'PATCH',
      headers: {
        Authorization: 'Bearer qwoty_your_token',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        name: 'Updated Product Parent Name',
        description: 'Updated description',
        recurrence_type: 'one_off',
      }),
    },
  )

  const data = await response.json()
  ```

  ```python Python theme={null}
  import requests

  product_parent_id = '550e8400-e29b-41d4-a716-446655440000'

  response = requests.patch(
    f'https://qwoty.app/api/product-parents/{product_parent_id}',
      headers={
          'Authorization': 'Bearer qwoty_your_token',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Updated Product Parent Name',
          'description': 'Updated description',
          'recurrence_type': 'one_off'
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Réponse

<ResponseField name="success" type="boolean">
  Indique si la requête a été effectuée avec succès
</ResponseField>

<ResponseField name="data" type="object">
  L'objet produit parent mis à jour avec tous les champs
</ResponseField>

<ResponseExample>
  ```json Réponse de succès theme={null}
  {
    "success": true,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Updated Product Parent Name",
      "api_name": "updated_product_parent_name",
      "description": "Updated description",
      "is_active": true,
      "recurrence_type": "one_off",
      "id_crm": "crm_123",
      "id_erp": "erp_456",
      "id_accounting": "acc_789",
      "created_at": "2024-12-21T10:30:00Z",
      "updated_at": "2024-12-21T14:45:00Z"
    }
  }
  ```
</ResponseExample>

## Réponses d'erreur

<ResponseExample>
  ```json Non trouvé theme={null}
  {
    "success": false,
    "error": "Product parent not found"
  }
  ```

  ```json Erreur de validation theme={null}
  {
    "success": false,
    "error": "Validation error",
    "details": ["Field 'api_name' is creation-only and cannot be updated"]
  }
  ```

  ```json Non autorisé theme={null}
  {
    "success": false,
    "error": "Invalid API token"
  }
  ```
</ResponseExample>
