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

# Modifica Contatto

> Aggiorna un contatto esistente nella rubrica

# PUT /v1/contacts/{id}

Modifica un contatto esistente. Sono aggiornati solo i campi presenti nel body: i campi omessi mantengono il valore corrente.

<Note>
  La modifica dei contatti esistenti è **sempre consentita**, anche per gli account che hanno raggiunto il limite di 4000 contatti.
</Note>

## Parametri URL

| Parametro | Tipo | Descrizione                   |
| --------- | ---- | ----------------------------- |
| `id`      | int  | ID del contatto da modificare |

## Request Body

| Campo     | Tipo           | Obbligatorio | Descrizione                                             |
| --------- | -------------- | ------------ | ------------------------------------------------------- |
| `number`  | string         | ❌            | Numero di telefono (max 25 caratteri)                   |
| `name`    | string         | ❌            | Nome del contatto (max 80 caratteri)                    |
| `company` | string \| null | ❌            | Azienda (max 50 caratteri) — `null` o `""` per svuotare |
| `notes`   | string \| null | ❌            | Note (max 255 caratteri) — `null` o `""` per svuotare   |

## Richiesta

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT https://api.mycentralino.com/v1/contacts/12345 \
    -H "X-API-KEY: sk_mycentralino_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Mario Bianchi",
      "notes": "Aggiornato"
    }'
  ```

  ```php PHP theme={null}
  <?php
  $id = 12345;
  $data = [
      'name' => 'Mario Bianchi',
      'notes' => 'Aggiornato'
  ];

  $ch = curl_init("https://api.mycentralino.com/v1/contacts/{$id}");
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      CURLOPT_POSTFIELDS => json_encode($data),
      CURLOPT_HTTPHEADER => [
          'X-API-KEY: sk_mycentralino_your_api_key',
          'Content-Type: application/json'
      ]
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  print_r(json_decode($response, true));
  ```

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

  headers = {
      'X-API-KEY': 'sk_mycentralino_your_api_key',
      'Content-Type': 'application/json'
  }
  contact_id = 12345
  data = {
      'name': 'Mario Bianchi',
      'notes': 'Aggiornato'
  }

  response = requests.put(
      f'https://api.mycentralino.com/v1/contacts/{contact_id}',
      headers=headers,
      json=data
  )
  print(response.json())
  ```
</CodeGroup>

## Risposta Successo

```json theme={null}
{
  "success": true,
  "data": {
    "id": 12345,
    "number": "3331234567",
    "name": "Mario Bianchi",
    "company": "ACME S.r.l.",
    "notes": "Aggiornato"
  }
}
```

## Errori

### 400 - Dati non validi

```json theme={null}
{
  "success": false,
  "error": "Il campo \"name\" supera i 80 caratteri."
}
```

### 404 - Contatto non trovato

```json theme={null}
{
  "success": false,
  "error": "Contatto non trovato"
}
```

### 409 - Numero già presente

```json theme={null}
{
  "success": false,
  "error": "Esiste gia' un contatto con questo numero in rubrica."
}
```

## Note

* I campi non inclusi nel body **non vengono modificati** (aggiornamento parziale).
* Per svuotare `company` o `notes`, invia il campo con valore `null` o stringa vuota.
