Zod
To declare a data type called Hello
with methods messages
and
send
, put the following in a .ts
file:
import { z } from "zod/v4";
export const api = {
Hello: {
state: {
messages: z.array(z.string()).default(() => []).meta({ tag: 1 }),
},
methods: {
messages: {
kind: "reader",
request: {},
response: {
messages: z.array(z.string()).meta({ tag: 1 }),
},
},
send: {
kind: "writer",
request: {
message: z.string().meta({ tag: 1 }),
},
response: z.void(),
},
},
},
};
important
Reboot requires zod/v4
.
Depending on its kind, a method
might be able to only read (e.g., reader
) or both read and write
(e.g., writer
) the state.
In the example above, Hello
has just one reader
and one writer
method, but it can have any number of reader
, writer
,
transaction
, and workflow
methods.
To learn more about how you implement each data type's methods see Implementing your API.