> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.middesk.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.middesk.com/_mcp/server.

# Update a webhook event schema

PATCH https://api.middesk.com/v1/webhooks/{webhook_id}/event_schemas/{id}
Content-Type: application/json

Updates the GraphQL selection set for a webhook event schema. The namespace is immutable. Changes apply to future event snapshots only. See [Customize webhook payloads](https://docs.middesk.com/build/webhooks#customize-webhook-payloads) for general guidance. For agent-specific event behavior, see [Agent webhook events](https://docs.middesk.com/work-with-agents/webhooks).

Reference: https://docs.middesk.com/api-reference/webhooks/update-webhook-event-schema

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `webhook_id` (string, required) — Webhook ID
- `id` (string, required) — Webhook event schema ID

### Body (application/json)

This endpoint expects an object.

- `schema` (string, required) — GraphQL selection set rooted at the event object for the namespace. Updates affect future event snapshots only; existing snapshots retain the payload captured when the event was created.

## Response

### 200

webhook event schema updated

- `object` (enum, required)
  - Allowed values: `webhook_event_schema`
- `id` (string, required) — Unique identifier for this webhook event schema.
- `namespace` (string, required) — Event namespace for the schema override. Currently supported business event namespaces are business.created and business.updated.
- `schema` (string, required) — GraphQL selection set rooted at the event object for the namespace. For `business.updated`, select fields directly from the Business object. The selection replaces only `data.object` in delivered webhook payloads.
- `created_at` (datetime, required)
- `updated_at` (datetime, required)

## Errors

### 404 Update Webhook Event Schema Request Not Found Error

webhook event schema not found

- `errors` (list of ErrorResponseErrorsItem, required)

### 422 Update Webhook Event Schema Request Unprocessable Entity Error

invalid request

- `errors` (list of ErrorResponseErrorsItem, required)

## Types

### ErrorResponseErrorsItem

- `message` (string, required)
- `parameter` (string, optional) — Request parameter associated with the error, when applicable

## Examples

**Request**

```json
{
  "schema": "{ id name addresses { full_address } }"
}
```

**Response**

```json
{
  "object": "webhook_event_schema",
  "id": "3f2a1c9e-8b4d-4e21-9c77-1a2b3c4d5e6f",
  "namespace": "business.updated",
  "schema": "{ id name addresses { full_address } }",
  "created_at": "2025-01-07T12:00:00Z",
  "updated_at": "2025-01-07T12:00:00Z"
}
```

**SDK Code**

```python Webhook event schema
import requests

url = "https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id"

payload = { "schema": "{ id name addresses { full_address } }" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Webhook event schema
const url = 'https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"schema":"{ id name addresses { full_address } }"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Webhook event schema
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id"

	payload := strings.NewReader("{\n  \"schema\": \"{ id name addresses { full_address } }\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Webhook event schema
require 'uri'
require 'net/http'

url = URI("https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"schema\": \"{ id name addresses { full_address } }\"\n}"

response = http.request(request)
puts response.read_body
```

```java Webhook event schema
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"schema\": \"{ id name addresses { full_address } }\"\n}")
  .asString();
```

```php Webhook event schema
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id', [
  'body' => '{
  "schema": "{ id name addresses { full_address } }"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Webhook event schema
using RestSharp;

var client = new RestClient("https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"schema\": \"{ id name addresses { full_address } }\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Webhook event schema
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["schema": "{ id name addresses { full_address } }"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.middesk.com/v1/webhooks/webhook_id/event_schemas/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```