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

# Update Webhook

Updates an existing webhook configuration.

## Overview

Update webhook settings including URL, subscribed events, custom headers, and active status. Only provided fields are updated; omitted fields remain unchanged.

## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer token with `write:webhooks` scope
</ParamField>

## Path Parameters

<ParamField path="id" type="string" required>
  The webhook configuration ID (UUID v4)
</ParamField>

## Request Body

All fields are optional. Only provided fields are updated.

<ParamField body="url" type="string">
  The HTTPS endpoint URL to receive webhook notifications. Maximum 2048 characters.
</ParamField>

<ParamField body="events" type="array">
  Array of event type strings to subscribe to:

  * `"ANALYSIS_COMPLETED"` - Analysis finished successfully
  * `"ANALYSIS_FAILED"` - Analysis processing failed
  * `"PING"` - Test event for connectivity
  * `"INTERVIEW_COMPLETED"` - Interview finished with analysis
  * `"INTERVIEW_FAILED"` - Technical failure during interview
  * `"INTERVIEW_STARTED"` - Interview session began
  * `"INTERVIEW_RESCHEDULED"` - A follow-up call attempt has been scheduled
  * `"INTERVIEW_CANCELLED"` - Interview terminated without completing
  * `"SOURCING_COMPLETED"` - Sourcing run finished with scored candidates
  * `"SOURCING_FAILED"` - Sourcing run terminated with an error
  * `"ENRICH_COMPLETED"` - Enrichment run completed
  * `"ENRICH_FAILED"` - Enrichment run terminated with an error
</ParamField>

<ParamField body="name" type="string">
  Human-readable name for the webhook. Maximum 255 characters.
</ParamField>

<ParamField body="description" type="string">
  Description of what this webhook is used for.
</ParamField>

<ParamField body="headers" type="array">
  Custom headers to include in webhook requests. Maximum 50 headers.

  <Warning>
    This replaces all existing headers. Include all headers you want to keep.
  </Warning>
</ParamField>

<ParamField body="isActive" type="boolean">
  Whether the webhook is active. Set to `false` to temporarily disable the webhook.
</ParamField>

## Response

Returns the updated webhook configuration.

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH https://api.instaview.sk/webhooks/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer sk_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://api.example.com/webhooks/instaview-v2",
      "events": ["ANALYSIS_COMPLETED", "ANALYSIS_FAILED", "INTERVIEW_COMPLETED", "INTERVIEW_FAILED"]
    }'
  ```

  ```javascript Node.js theme={null}
  const webhookId = '550e8400-e29b-41d4-a716-446655440000';

  const response = await fetch(
    `https://api.instaview.sk/webhooks/${webhookId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${process.env.INSTAVIEW_API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        url: 'https://api.example.com/webhooks/instaview-v2',
        events: ["ANALYSIS_COMPLETED", "ANALYSIS_FAILED", "INTERVIEW_COMPLETED", "INTERVIEW_FAILED"]
      })
    }
  );

  const { data } = await response.json();
  console.log(`Webhook updated: ${data.url}`);
  ```

  ```python Python theme={null}
  webhook_id = '550e8400-e29b-41d4-a716-446655440000'

  response = requests.patch(
      f'https://api.instaview.sk/webhooks/{webhook_id}',
      headers={
          'Authorization': f'Bearer {os.environ["INSTAVIEW_API_KEY"]}',
          'Content-Type': 'application/json'
      },
      json={
          'url': 'https://api.example.com/webhooks/instaview-v2',
          'events': ["ANALYSIS_COMPLETED", "ANALYSIS_FAILED", "INTERVIEW_COMPLETED", "INTERVIEW_FAILED"]
      }
  )

  data = response.json()['data']
  print(f'Webhook updated: {data["url"]}')
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "apiKeyId": "api-key-uuid",
    "url": "https://api.example.com/webhooks/instaview-v2",
    "name": "Production Webhook",
    "description": "Receives interview completion notifications",
    "headers": [
      { "name": "Authorization", "isMasked": true }
    ],
    "events": [
      "analysis.completed",
      "analysis.failed",
      "interview.completed",
      "interview.failed"
    ],
    "isActive": true,
    "maxRetries": 3,
    "timeoutMs": 30000,
    "consecutiveFailures": 0,
    "circuitOpenedAt": null,
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T12:00:00Z"
  }
}
```

## Common Update Scenarios

### Disable Webhook Temporarily

```javascript theme={null}
await fetch(`https://api.instaview.sk/webhooks/${webhookId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    isActive: false
  })
});
```

### Update Event Subscriptions

```javascript theme={null}
await fetch(`https://api.instaview.sk/webhooks/${webhookId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    events: ["ANALYSIS_COMPLETED", "ANALYSIS_FAILED", "PING", "INTERVIEW_COMPLETED", "INTERVIEW_FAILED", "INTERVIEW_STARTED", "SOURCING_COMPLETED", "SOURCING_FAILED", "ENRICH_COMPLETED", "ENRICH_FAILED"]
  })
});
```

### Update Custom Headers

```javascript theme={null}
// Note: This replaces ALL headers
await fetch(`https://api.instaview.sk/webhooks/${webhookId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    headers: [
      { name: 'Authorization', value: 'Bearer new-token' },
      { name: 'X-Environment', value: 'production' }
    ]
  })
});
```

## Error Responses

<AccordionGroup>
  <Accordion title="400 - Validation Error">
    ```json theme={null}
    {
      "success": false,
      "error": {
        "code": "VALIDATION_ERROR",
        "message": "url must be a valid URL"
      }
    }
    ```
  </Accordion>

  <Accordion title="404 - Webhook Not Found">
    ```json theme={null}
    {
      "success": false,
      "error": {
        "code": "RESOURCE_NOT_FOUND",
        "message": "Webhook configuration not found"
      }
    }
    ```
  </Accordion>

  <Accordion title="403 - Access Denied">
    ```json theme={null}
    {
      "success": false,
      "error": {
        "code": "RESOURCE_ACCESS_DENIED",
        "message": "Access denied to this webhook configuration"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Get Webhook" icon="eye" href="/api-reference/webhooks/get-webhook">
    View webhook configuration details
  </Card>

  <Card title="Reset Circuit" icon="rotate-right" href="/api-reference/webhooks/reset-circuit">
    Reset circuit breaker for failed webhook
  </Card>
</CardGroup>
