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

# Update Opportunity Status

> Update Opportunity Status

Update Opportunity Status

```http theme={null}
PUT https://services.leadconnectorhq.com/opportunities/{id}/status
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Path parameters

<ParamField path="id" type="string" required default="yWQobCRIhRguQtD2llvk">
  Opportunity Id
</ParamField>

## Body

<ParamField body="status" type="string" required>
  Posibles valores: 'open', 'won', 'lost', 'abandoned', 'all'
</ParamField>

<ParamField body="lostReasonId" type="string" default="CLu7BaljjqrEjBGKTNNe">
  lost reason Id
</ParamField>

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="succeded" type="boolean" default="True" />

  ```json theme={null}
  {
    "succeded": true
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://services.leadconnectorhq.com/opportunities/YOUR_id/status' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "status": "open",
    "lostReasonId": "CLu7BaljjqrEjBGKTNNe"
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/opportunities/YOUR_id/status', {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"status": "open", "lostReasonId": "CLu7BaljjqrEjBGKTNNe"}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'PUT',
      'https://services.leadconnectorhq.com/opportunities/YOUR_id/status',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"status": "open", "lostReasonId": "CLu7BaljjqrEjBGKTNNe"},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/opportunities/YOUR_id/status');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'status': 'open', 'lostReasonId': 'CLu7BaljjqrEjBGKTNNe'}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
