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

# Update Event

> Update an existing pending event

## Overview

Update an existing event. Only pending events can be updated.

<RequestExample>
  ```typescript Update event schedule theme={null}
  import { cuey } from "cuey";

  const updatedEvent = await cuey.events.update("event-id", {
    webhook_url: "https://api.example.com/webhook",
    scheduled_at: "2025-01-01T00:00:00Z",
    payload: {
      message: "Updated message",
    },
  });
  ```
</RequestExample>

## Parameters

<ParamField path="id" type="string" required>
  The UUID of the event to update.
</ParamField>

<ParamField body="webhook_url" type="string" required>
  The full URL of the webhook endpoint to call. Must be a valid HTTP/HTTPS URL.
</ParamField>

<ParamField body="method" type="string">
  HTTP method to use for the webhook request. Options: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`. Defaults to `POST`.
</ParamField>

<ParamField body="scheduled_at" type="string" required>
  ISO 8601 timestamp when the event should execute. Must be in the future.
</ParamField>

<ParamField body="headers" type="object | null">
  Custom headers to include in the webhook request. Object with string keys and values.
</ParamField>

<ParamField body="payload" type="object | null">
  Payload to send with the webhook request. Can be any JSON-serializable object.
</ParamField>

<ParamField body="retry_config" type="object | null">
  Retry configuration for failed webhook attempts.

  <Expandable title="RetryConfig properties">
    <ParamField body="maxRetries" type="number" required>
      Maximum number of retry attempts. Range: 1-10.
    </ParamField>

    <ParamField body="backoffMs" type="number" required>
      Initial backoff delay in milliseconds. Range: 100-5000.
    </ParamField>

    <ParamField body="backoffType" type="string" required>
      Backoff strategy. Options: `exponential`, `linear`.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="event" type="Event" required>
  The updated event object.
</ResponseField>

<ResponseExample>
  ```json Success response theme={null}
  {
    "id": "event-uuid-here",
    "cron_id": null,
    "retry_of": null,
    "scheduled_at": "2025-01-01T00:00:00Z",
    "executed_at": null,
    "status": "pending",
    "webhook_url": "https://api.example.com/webhook",
    "method": "POST",
    "headers": null,
    "payload": {
      "message": "Updated message"
    },
    "retry_config": null,
    "response_status": null,
    "response_headers": null,
    "response_body": null,
    "response_duration": null,
    "response_error": null,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-16T12:00:00Z",
    "team_id": "team-uuid-here"
  }
  ```
</ResponseExample>

## Errors

<Warning>
  Only pending events can be updated. Events that are processing, successful, or failed cannot be updated.
</Warning>

* `NotFoundError`: If the event doesn't exist
* `BadRequestError`: If the event is not in pending status
* `ValidationError`: If the update data is invalid (e.g., `scheduled_at` is in the past)
* `UnauthorizedError`: If API key is invalid or missing

## Examples

### Update Event Schedule

```typescript theme={null}
import { cuey } from "cuey";

const event = await cuey.events.get("event-id");

if (event.status === "pending") {
  const updated = await cuey.events.update(event.id, {
    webhook_url: event.webhook_url,
    method: event.method,
    scheduled_at: new Date(Date.now() + 120000).toISOString(), // 2 minutes from now
    payload: {
      message: "Updated!",
    },
  });

  console.log("Event updated:", updated.id);
}
```
