---
title: "EventWolf SDK event types"
description: "List, read, register, validate, and deprecate event types with the EventWolf SDK, using a project key or workspace key."
url: "https://agentpost.tools/docs/eventwolf/sdk/event-types"
kind: sdk
---

# Event types

`client.eventTypes` reads and manages the [type registry](/docs/eventwolf/concepts/event-types.md). Every method takes its request and returns the contract’s typed response. Use a project’s secret key for changes; a [workspace key](/docs/platform/concepts/workspace-keys.md) with the client’s `project` option can only list and get types.

The examples use `request.assigned` from the [EventWolf quickstart](/docs/eventwolf/quickstart.md).

## Read types

```ts
import { createClient } from '@agentpost-tools/eventwolf-sdk';

const client = createClient({ token: process.env.AGENTPOST_SECRET_KEY });
const page = await client.eventTypes.list({ origin: 'registered', limit: 20 });
const { eventType } = await client.eventTypes.get('request.assigned');
```

`list` takes optional `origin`, `status`, `after`, and `limit`. When the page has `next`, pass it as `after` with the same filters to read the next page. `get` returns the type with every schema version.

## Register or update a type

```ts
const registered = await client.eventTypes.put('request.assigned', {
  description: 'A request assigned to a person',
  schema: {
    type: 'object',
    required: ['assignee'],
    properties: {
      assignee: {
        type: 'object',
        required: ['id'],
        properties: { id: { type: 'string' } },
      },
    },
  },
  refPaths: { 'assignee.id': { type: 'user' } },
});
```

An omitted field keeps its value. A different schema makes a new version; `schema: null` removes the current schema, and `refPaths: null` removes the reference paths. The answer holds `eventType`.

## Check a schema

```ts
const checked = await client.eventTypes.validate('request.assigned', {
  items: [{ data: { assignee: { id: 'u_ana' } } }],
});
const first = checked.items[0];
```

`validate` checks 1 to 200 `items` without writing anything. Send `{}` for an event without data. Pass `schema` to try a candidate schema, or omit it to use the type’s current schema. If the type has no current schema, you must pass one. The answer includes the schema source and one `{ valid, issues }` in `items` per event, in the order sent.

To check a candidate schema against the type’s newest stored events, `checkRecent` reads them with `events.query` and checks their data in one `validate` call. `count` is how many to read, 1 to 200, and is required. Reading events takes read access to them.

```ts
const recent = await client.eventTypes.checkRecent('request.assigned', {
  schema: {
    type: 'object',
    required: ['assignee'],
    properties: {
      assignee: {
        type: 'object',
        required: ['id'],
        properties: { id: { type: 'string', minLength: 1 } },
      },
    },
  },
  count: 50,
});
const rejected = recent.events.filter((e) => !e.valid);
```

The answer holds `events`, newest first, each with its `sequence`, `id`, `valid`, and `issues`, and the `schema` the check used. When the type has no stored events, `events` is empty and nothing is sent to check.

## Deprecate a type

```ts
const deprecated = await client.eventTypes.deprecate('request.assigned');
```

The answer holds `eventType` with `status: 'deprecated'`. Its events are still accepted and checked.

## Errors

These methods take the same optional `CallOptions` as the other JSON calls, such as `{ signal }`. Pass `{ idempotencyKey }` to `put` or `deprecate` to retry a write, as [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) describes. `validate` and `checkRecent` write nothing and need no idempotency key. A method throws `EventwolfApiError` when the API answers with an error. With a workspace key, the API answers `forbidden` to `put`, `validate`, and `deprecate`, and to the validation call that `checkRecent` makes when it finds events. The [event types reference](/docs/eventwolf/reference/event-types.md) has every field and error.
