# Update Event

> PATCH /events/:id — update a custom event definition's payload schema.

`PATCH /events/:id`

Updates a [custom event](https://www.sendping.co/docs/automations/custom-events) definition's payload `schema` in place. The event **name is immutable** — renaming it would silently detach every automation whose trigger or wait step references it, so create a new event instead. Pass `schema` as a flat `key → type` map (`string` | `number` | `boolean` | `date`), or `null` to clear validation.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The ID of the event definition to update. |

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `schema` | object | null | No | The replacement payload schema (flat key→type map), or `null` to remove validation. Treat this as required: the request **always** replaces the stored schema, so omitting `schema` has the same effect as sending `null` — the schema is cleared and payload validation stops. Passing `name` is rejected with `422 validation_error`. |

> **Warning:** This is a full replacement, not a merge. `PATCH /events/:id` with an empty body — or with any other field but no `schema` — removes the payload schema and future [/events/send](https://www.sendping.co/docs/api/events-send) payloads stop being validated. Always send the complete schema you want to keep.

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.events.update('b6d24b8e-af0b-4c3c-be0c-359bbd97381e', {
  "schema": { "plan": "string", "seats": "number" }
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Events.update("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", {
  "schema": {
    "plan": "string",
    "seats": "number"
  }
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->events->update('b6d24b8e-af0b-4c3c-be0c-359bbd97381e', [
  'schema' => [
    'plan' => "string",
    'seats' => "number"
  ]
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Events.update("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", {
  "schema": {
    "plan": "string",
    "seats": "number"
  }
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

definition, err := client.Events.Update("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", &sendping.UpdateEventRequest{
    Schema: map[string]string{"plan": "string", "seats": "number"},
})
```

**Rust**

```rust
use sendping::{EventFieldType, SendPing, UpdateEventOptions};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = UpdateEventOptions::new()
    .with_schema_field("plan", EventFieldType::String)
    .with_schema_field("seats", EventFieldType::Number);
let _definition = mb.events.update("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.UpdateEventRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

UpdateEventRequest request = UpdateEventRequest.builder()
        .schema("plan", "string")
        .schema("seats", "number")
        .build();

SendPingResponse response = sendping.events().update(
        "b6d24b8e-af0b-4c3c-be0c-359bbd97381e",
        request);
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.EventUpdateAsync("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", new Dictionary<string, string>
{
    ["plan"] = "string",
    ["seats"] = "number",
});
```

**cURL**

```bash
curl -X PATCH 'https://www.sendping.co/api/events/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "schema": { "plan": "string", "seats": "number" }
}'
```

**CLI**

```bash
sendping events update b6d24b8e-af0b-4c3c-be0c-359bbd97381e \
  --schema '{"plan":"string","seats":"number"}'
```

### Response

```json
{
  "object": "event",
  "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e",
  "name": "user.created",
  "schema": { "plan": "string", "seats": "number" },
  "created_at": "2026-06-23T10:00:00.000Z",
  "updated_at": "2026-06-24T09:00:00.000Z"
}
```

An unknown id returns `404 not_found`; sending `name` or an invalid `schema` returns `422 validation_error`. See [Errors](https://www.sendping.co/docs/api/errors).
