### Install @anima-labs/schemas with npm or bun Source: https://github.com/anima-labs-ai/schemas/blob/main/README.md Install the package using npm or bun. The bun command is an alternative to npm. ```bash npm install @anima-labs/schemas # or bun add @anima-labs/schemas ``` -------------------------------- ### Usage example for MessageListInput, MessageSearchInput, MessageListOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/message.md Example showing how to parse message list and search inputs and outputs using the exported schemas from @anima-labs/schemas. ```typescript import { MessageListInput, MessageSearchInput, MessageListOutput } from "@anima-labs/schemas"; const list = MessageListInput.parse({ agentId: "clxagent1...", direction: "INBOUND" }); const page = MessageListOutput.parse(await api.listMessages(list)); const search = MessageSearchInput.parse({ query: "invoice #{123}", filters: { channel: "EMAIL", status: "DELIVERED" }, pagination: { limit: 50 }, }); ``` -------------------------------- ### FeedbackListInput and FeedbackListOutput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/feedback.md Shows how to parse a FeedbackListInput and FeedbackListOutput. The example uses a limit of 50 and demonstrates accessing the pagination fields. ```typescript import { FeedbackListInput, FeedbackListOutput } from "@anima-labs/schemas"; const page = FeedbackListOutput.parse( await api.listFeedback(FeedbackListInput.parse({ limit: 50 })), ); if (page.pagination.hasMore) page.pagination.nextCursor; // feed into next call ``` -------------------------------- ### CreateApiKeyInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Shows how to parse input for creating an API key. The example passes an agentId and scopes, and the parsed result includes mode "LIVE" and the provided scopes. ```typescript import { CreateApiKeyInput } from "@anima-labs/schemas"; const input = CreateApiKeyInput.parse({ agentId: "clxagent1...", scopes: ["messages:write"] }); // { mode: "LIVE", scopes: ["messages:write"], ... } ``` -------------------------------- ### FeedbackInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/feedback.md Shows how to import and parse a FeedbackInput object. The example uses a bug type, a message, an email, and metadata. ```typescript import { FeedbackInput } from "@anima-labs/schemas"; const feedback = FeedbackInput.parse({ type: "bug", message: "Slug regex rejected a valid slug", email: "dev@example.com", metadata: { page: "/settings" }, }); ``` -------------------------------- ### InboxListInput and InboxListOutput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/inbox.md Shows how to parse list input and output. The example calls api.listInboxes with a parsed query and iterates over the resulting items. ```typescript import { InboxListInput, InboxListOutput } from "@anima-labs/schemas"; const { items } = InboxListOutput.parse( await api.listInboxes(InboxListInput.parse({ query: "support" })), ); for (const inbox of items) console.log(inbox.email, inbox.agentId); ``` -------------------------------- ### OpenClaw Self-Signup Usage Example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Shows how to parse input and output using the schemas. The apiKey is returned only once and must be stored securely. ```typescript import { OpenClawSelfSignupInput, OpenClawSelfSignupOutput } from "@anima-labs/schemas"; const input = OpenClawSelfSignupInput.parse({ openclawAgentId: "oc_42", organizationName: "Acme", organizationSlug: "acme", agentName: "Acme Agent", agentSlug: "acme-agent", email: "ops@acme.example", phoneNumber: "+14155550132", }); const result = OpenClawSelfSignupOutput.parse(await api.selfSignup(input)); // result.credentials.apiKey — store securely, it is not returned again ``` -------------------------------- ### CreateAgentInput - Usage Example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Shows how to parse a valid agent input and how to handle validation errors. The safeParse example demonstrates that both name and slug issues are reported together. ```typescript import { CreateAgentInput } from "@anima-labs/schemas"; const input = CreateAgentInput.parse({ orgId: "clxorgid0001...", name: "Support Agent", slug: "support-agent", provisionPhone: true, }); // { orgId, name, slug, provisionPhone: true, metadata: {} } const bad = CreateAgentInput.safeParse({ orgId: "clx...", name: "X", slug: "Bad_Slug!" }); if (!bad.success) { // issues for name (too short) and slug (regex mismatch) are both reported console.log(bad.error.issues.map((i) => i.path)); } ``` -------------------------------- ### Parsing an AgentOutput Example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Shows how to import and parse an AgentOutput object. The example logs the status field, which is 'ACTIVE'. ```typescript import { AgentOutput } from "@anima-labs/schemas"; const agent = AgentOutput.parse({ id: "clxagent1...", orgId: "clxorgid1...", name: "Support Agent", slug: "support-agent", status: "ACTIVE", apiKeyPrefix: "anim_", metadata: {}, emailIdentities: [], phoneIdentities: [], createdAt: "...", updatedAt: "...", }); console.log(agent.status); // "ACTIVE" ``` -------------------------------- ### Usage example for schemas namespace Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Shows how to import the schemas namespace and use it to parse input for creating an API key. ```typescript import { schemas } from "@anima-labs/schemas"; const input = schemas.CreateApiKeyInput.parse({ name: "ci", scopes: [] }); ``` -------------------------------- ### Usage example for BillingCheckoutInput and BillingSessionOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/billing.md Shows how to parse billing input and session output, then redirect to the session URL if present. Imports from @anima-labs/schemas. ```typescript import { BillingCheckoutInput, BillingSessionOutput } from "@anima-labs/schemas"; const checkout = BillingCheckoutInput.parse({ tier: "growth", successUrl: "https://app.example.com/billing?done=1", }); const session = BillingSessionOutput.parse({ url: "https://checkout.stripe.com/c/pay_..." }); if (session.url) window.location.assign(session.url); ``` -------------------------------- ### BillingUsageOutput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/billing.md Shows how to import and parse a usage object with BillingUsageOutput. The example uses period '2025-06' and sample usage counters. ```typescript import { BillingUsageOutput } from "@anima-labs/schemas"; const usage = BillingUsageOutput.parse({ period: "2025-06", usage: { message_sent: 3, message_received: 1, sms_sent: 0, sms_received: 0, call_minute: 0, embedding_generated: 12 }, }); ``` -------------------------------- ### Usage example for ListPhonesOutput and SendSmsInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/phone.md Shows how to parse ListPhonesInput and ListPhonesOutput, find the primary phone, and send an SMS using SendSmsInput. The example uses the @anima-labs/schemas package. ```typescript import { ListPhonesInput, ListPhonesOutput, SendSmsInput } from "@anima-labs/schemas"; const list = ListPhonesOutput.parse(await api.listPhones(ListPhonesInput.parse({ agentId: "clxagent1..." }))); const primary = list.items.find((p) => p.isPrimary); if (primary) await api.sendSms(SendSmsInput.parse({ agentId: "clxagent1...", to: primary.phoneNumber, body: "Hi" })); ``` -------------------------------- ### Import schemas from package root Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/index.md Shows how to import schemas directly from the package root. The example imports AgentOutput and AgentListInput. ```typescript import { AgentOutput, AgentListInput } from "@anima-labs/schemas"; ``` -------------------------------- ### Usage example for AgentListInput and AgentListOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Shows how to parse input, validate an API response, and paginate using the nextCursor. The example imports both schemas from @anima-labs/schemas and uses AgentListInput.parse for the initial query and subsequent cursor-based requests. ```typescript import { AgentListInput, AgentListOutput } from "@anima-labs/schemas"; const query = AgentListInput.parse({ status: "ACTIVE", limit: 10 }); const response: unknown = await api.listAgents(query); const { items, pagination } = AgentListOutput.parse(response); if (pagination.hasMore) { await api.listAgents(AgentListInput.parse({ cursor: pagination.nextCursor })); } ``` -------------------------------- ### SecurityPolicySchema usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/security.md Shows how to parse a policy with custom values and how parsing an empty object yields the documented defaults. The example imports from '@anima-labs/schemas' and demonstrates that all fields have defaults. ```typescript import { SecurityPolicySchema } from "@anima-labs/schemas"; const policy = SecurityPolicySchema.parse({ scanLevel: "strict", autoApproveBelow: "high", allowedDomains: ["example.com"], }); // { scanLevel: "strict", injectionScanEnabled: true, autoApproveBelow: "high", // allowedDomains: ["example.com"], blockedPatterns: [] } const defaults = SecurityPolicySchema.parse({}); // { scanLevel: "basic", injectionScanEnabled: true, autoApproveBelow: "medium", // allowedDomains: [], blockedPatterns: [] } ``` -------------------------------- ### Usage example for OrgListInput and OrgListOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/organization.md Shows how to parse an OrgListInput with a query and limit, pass it to an API call, parse the response as OrgListOutput, and iterate over the items. ```typescript import { OrgListInput, OrgListOutput } from "@anima-labs/schemas"; const page = OrgListOutput.parse( await api.listOrgs(OrgListInput.parse({ query: "acme", limit: 50 })), ); for (const org of page.items) console.log(org.id, org.tier); ``` -------------------------------- ### UpdateAgentInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Shows how to parse a partial update payload using UpdateAgentInput. The example passes an id and a status, demonstrating that other fields are optional. ```typescript import { UpdateAgentInput } from "@anima-labs/schemas"; const patch = UpdateAgentInput.parse({ id: "clxagent1...", status: "SUSPENDED" }); ``` -------------------------------- ### InvoiceListInput and InvoiceUpdateInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/invoice.md Shows how to parse an update and a list input using the schemas. ```typescript import { InvoiceListInput, InvoiceUpdateInput, InvoiceStatusSchema } from "@anima-labs/schemas"; const update = InvoiceUpdateInput.parse({ invoiceId: "inv_123", status: "confirmed", metadata: { reviewedBy: "ops@anima.dev" }, }); const list = InvoiceListInput.parse({ status: "confirmed" }); ``` -------------------------------- ### Update security policy usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/security.md Shows how to parse input and output for updating a security policy. The example uses UpdateSecurityPolicyInput.parse and UpdateSecurityPolicyOutput.parse with an api.updatePolicy call. The output's policy.injectionScanEnabled defaults to true. ```typescript import { UpdateSecurityPolicyInput, UpdateSecurityPolicyOutput } from "@anima-labs/schemas"; const input = UpdateSecurityPolicyInput.parse({ orgId: "org_1", agentId: "agent_2", policy: { scanLevel: "strict", allowedDomains: ["example.com"] }, }); const saved = UpdateSecurityPolicyOutput.parse(await api.updatePolicy(input)); console.log(saved.policy.injectionScanEnabled); // true (default applied) ``` -------------------------------- ### Usage example for VaultCredentialIdInput and related schemas Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Shows how to import and use VaultCredentialIdInput, TotpOutput, GeneratePasswordInput, and GeneratePasswordOutput. Parses inputs and outputs for getTotp and generatePassword API calls. ```typescript import { VaultCredentialIdInput, TotpOutput, GeneratePasswordInput, GeneratePasswordOutput } from "@anima-labs/schemas"; const target = VaultCredentialIdInput.parse({ agentId: "clxagent1...", id: "cred_1" }); const totp = TotpOutput.parse(await api.getTotp(target)); const pwd = GeneratePasswordOutput.parse( await api.generatePassword(GeneratePasswordInput.parse({ agentId: "clxagent1...", length: 24, special: true })), ); ``` -------------------------------- ### SendSmsInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/message.md Example of importing SendSmsInput from @anima-labs/schemas and parsing a sample SMS object. Demonstrates the expected shape with agentId, to, and body fields. ```typescript import { SendSmsInput } from "@anima-labs/schemas"; const sms = SendSmsInput.parse({ agentId: "clxagent1...", to: "+14155550132", body: "Your code is 123456", }); ``` -------------------------------- ### UpdateOrgInput Usage Example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/organization.md Shows how to import and use UpdateOrgInput to parse a patch object. The example passes a null clerkOrgId to unlink from Clerk and sets the tier to 'SCALE'. ```typescript import { UpdateOrgInput } from "@anima-labs/schemas"; const patch = UpdateOrgInput.parse({ id: "clxorgid1...", clerkOrgId: null, // unlink from Clerk tier: "SCALE", }); ``` -------------------------------- ### Usage example for ApprovalActionInput and ApprovalActionOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/security.md Shows how to parse an approval input and output using the schemas, including a call to an API function and logging the result status. ```typescript import { ApprovalActionInput, ApprovalActionOutput } from "@anima-labs/schemas"; const input = ApprovalActionInput.parse({ orgId: "org_1", messageId: "msg_2", action: "reject", reason: "Spam" }); const result = ApprovalActionOutput.parse(await api.approveOrReject(input)); console.log(result.status); // "REJECTED" | "SENT" | "FAILED" ``` -------------------------------- ### Using CreateCredentialInput and UpdateCredentialInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Shows how to parse data with CreateCredentialInput and UpdateCredentialInput. The example creates a login credential and then updates it with a new password and favorite flag. ```typescript import { CreateCredentialInput, UpdateCredentialInput } from "@anima-labs/schemas"; const created = CreateCredentialInput.parse({ agentId: "clxagent1...", type: "login", name: "dashboard", login: { username: "ops", password: "s3cret", uris: [{ uri: "https://app.example.com", match: "host" }] }, }); const updated = UpdateCredentialInput.parse({ agentId: "clxagent1...", login: { username: "ops", password: "new-s3cret" }, favorite: true, }); ``` -------------------------------- ### CreateOrgInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/organization.md Shows how to import and use CreateOrgInput to parse an organization object. The parsed result includes the tier and default settings. ```typescript import { CreateOrgInput } from "@anima-labs/schemas"; const org = CreateOrgInput.parse({ name: "Acme Inc", slug: "acme", tier: "DEVELOPER" }); // { tier: "DEVELOPER", settings: {} } ``` -------------------------------- ### InvoiceOutput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/invoice.md Shows how to parse an invoice from an API response and check its status and amount before approving. ```typescript import { InvoiceOutput } from "@anima-labs/schemas"; const invoice = InvoiceOutput.parse(await api.getInvoice(invoiceId)); if (invoice.status === "detected" && invoice.amountCents !== null) { await approve(invoice.id, invoice.amountCents, invoice.currency); } ``` -------------------------------- ### DateRange usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/common.md Parses a DateRange with explicit from and to ISO datetime strings. ```typescript import { DateRange } from "@anima-labs/schemas"; const range = DateRange.parse({ from: "2025-01-01T00:00:00.000Z", to: "2025-01-31T23:59:59.000Z", }); ``` -------------------------------- ### Usage example for RevokeApiKeyInput and RotateApiKeyInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Shows how to import and use the RevokeApiKeyInput and RotateApiKeyInput schemas to parse input objects with an id field. ```typescript import { RevokeApiKeyInput, RotateApiKeyInput } from "@anima-labs/schemas"; const revoke = RevokeApiKeyInput.parse({ id: "clxkey1..." }); const rotate = RotateApiKeyInput.parse({ id: "clxkey1..." }); ``` -------------------------------- ### Webhook schema usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/webhook.md Shows how to parse the webhook schemas with sample data and use the parsed values with a hypothetical API. Includes a conditional check on successRate and a call to listDeliveries. ```typescript import { CreateWebhookInput, TestWebhookInput, WebhookDeliveryListInput, WebhookStatsOutput } from "@anima-labs/schemas"; const created = CreateWebhookInput.parse({ url: "https://app.example.com/hooks", events: ["message.sent", "agent.created"], description: "prod app", }); const test = TestWebhookInput.parse({ id: "wbhook1234..." }); const stats = WebhookStatsOutput.parse(await api.webhookStats({ id: "wbhook1234..." })); if (stats.successRate < 90) { const deliveries = await api.listDeliveries(WebhookDeliveryListInput.parse({ webhookId: "wbhook1234...", limit: 20 })); // inspect WebhookDeliveryOutput records: statusCode, attempts, maxAttempts, nextAttemptAt } ``` -------------------------------- ### Parsing OpenClawCallbackInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Example of parsing query parameters with OpenClawCallbackInput and handling the error case. ```typescript import { OpenClawCallbackInput } from "@anima-labs/schemas"; const callback = OpenClawCallbackInput.parse(queryParams); if (callback.error) console.error("OAuth failed:", callback.error); else handleCode(callback.code!); ``` -------------------------------- ### Usage example: search and provision phone numbers Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/phone.md Demonstrates parsing search input, parsing search output, and provisioning a phone. ProvisionPhoneInput only carries agentId and preferred region/capabilities; the number is chosen server-side. ```typescript import { SearchNumbersInput, SearchNumbersOutput, ProvisionPhoneInput } from "@anima-labs/schemas"; const search = SearchNumbersInput.parse({ areaCode: "415", capabilities: ["sms", "voice"], limit: 5 }); const numbers = SearchNumbersOutput.parse(await api.searchNumbers(search)); if (numbers.items.length > 0) { // ProvisionPhoneInput carries only agentId + preferred region/capabilities — the number is chosen server-side const provision = ProvisionPhoneInput.parse({ agentId: "clxagent1...", capabilities: ["sms", "voice"] }); await api.provisionPhone(provision); } ``` -------------------------------- ### EmailListOutput schema definition and usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/email.md Defines the paginated email list output schema with items of MessageOutput and CursorPagination. The usage example shows parsing an EmailListInput and EmailListOutput with an API call. ```typescript export const EmailListOutput = z.object({ items: z.array(MessageOutput), pagination: CursorPagination, }); ``` ```typescript import { EmailListInput, EmailListOutput } from "@anima-labs/schemas"; const request = EmailListInput.parse({ agentId: "clxagent1...", limit: 25 }); const { items, pagination } = EmailListOutput.parse(await api.listEmails(request)); ``` -------------------------------- ### SendEmailInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/message.md Shows how to parse a valid email input using SendEmailInput. The parsed result includes default values for cc, bcc, headers, and metadata. ```typescript import { SendEmailInput } from "@anima-labs/schemas"; const email = SendEmailInput.parse({ agentId: "clxagent1...", to: ["a@example.com"], subject: "Hello", body: "World", bodyHtml: "

World

", }); // { cc: [], bcc: [], headers: {}, metadata: {} } ``` -------------------------------- ### Parsing and using MessageOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/message.md Shows how to import MessageOutput from @anima-labs/schemas and parse an incoming webhook body. After parsing, the example checks for an inbound SMS message and routes it to an agent. ```typescript import { MessageOutput } from "@anima-labs/schemas"; const msg = MessageOutput.parse(webhook.body); if (msg.channel === "SMS" && msg.direction === "INBOUND") { await routeToAgent(msg.agentId, msg.body); } ``` -------------------------------- ### Parse ListCredentialsOutput from searchCredentials API Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Example of parsing the output of api.searchCredentials using ListCredentialsOutput. The input is parsed with SearchCredentialsInput, which requires an agentId and a search string. ```typescript import { SearchCredentialsInput, ListCredentialsOutput } from "@anima-labs/schemas"; const page = ListCredentialsOutput.parse( await api.searchCredentials(SearchCredentialsInput.parse({ agentId: "clxagent1...", search: "aws" })), ); ``` -------------------------------- ### WebhookEventSchema usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/webhook.md Shows how to import and use WebhookEventSchema to parse a valid event string. The parse call with "message.received" succeeds. ```typescript import { WebhookEventSchema } from "@anima-labs/schemas"; WebhookEventSchema.parse("message.received"); // ok ``` -------------------------------- ### AddDomainInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/email.md Shows how to parse and validate a domain using AddDomainInput. The parse method lowercases the input, and safeParse returns an error with the message "Invalid domain format" for invalid domains. ```typescript import { AddDomainInput } from "@anima-labs/schemas"; const input = AddDomainInput.parse({ domain: "Example.COM" }); // input.domain === "example.com" (lowercased) const result = AddDomainInput.safeParse({ domain: "not_a_domain" }); if (!result.success) { console.log(result.error.issues[0].message); // "Invalid domain format" } ``` -------------------------------- ### EmailSendEmailInput Usage Example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/email.md Parses an email input with agentId, to, subject, body, and inReplyTo. The parsed result includes defaults for references, cc, bcc, headers, and metadata. ```typescript import { EmailSendEmailInput } from "@anima-labs/schemas"; const email = EmailSendEmailInput.parse({ agentId: "clxagent1...", to: ["cust@example.com"], subject: "Your receipt", body: "Hi — please find your receipt attached.", inReplyTo: "", }); // { references: [], cc: [], bcc: [], headers: {}, metadata: {}, ... } ``` -------------------------------- ### BillingTierSchema usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/billing.md Shows how to import and use BillingTierSchema to parse a tier value. The parse call returns the validated value, here 'growth'. ```typescript import { BillingTierSchema } from "@anima-labs/schemas"; const tier = BillingTierSchema.parse("growth"); // "growth" ``` -------------------------------- ### Parsing a security event with SecurityEventOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/security.md Shows how to parse a raw event and access its properties. The example checks for INJECTION_DETECTED and logs the createdAt date and details. ```typescript import { SecurityEventOutput } from "@anima-labs/schemas"; const event = SecurityEventOutput.parse(raw); if (event.type === "INJECTION_DETECTED") { console.log(event.createdAt.toISOString(), event.details); } ``` -------------------------------- ### Re-exports: MessageOutput, SendSmsInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/phone.md Re-exports the message-module schemas verbatim so phone consumers get one import path. Documented in full in message.md. ```APIDOC ## Re-exports: MessageOutput, SendSmsInput ### Description Re-exports the message-module schemas verbatim so phone consumers get one import path. Documented in full in [message.md](message.md#messageoutput) and [message.md](message.md#sendsmsinput). ### Type Zod object schemas ### Example ```typescript import { ListPhonesInput, ListPhonesOutput, SendSmsInput } from "@anima-labs/schemas"; const list = ListPhonesOutput.parse(await api.listPhones(ListPhonesInput.parse({ agentId: "clxagent1..." }))); const primary = list.items.find((p) => p.isPrimary); if (primary) await api.sendSms(SendSmsInput.parse({ agentId: "clxagent1...", to: primary.phoneNumber, body: "Hi" })); ``` ``` -------------------------------- ### CreateInboxInput usage example Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/inbox.md Shows how to parse a valid inbox input and handle a validation failure. The safeParse result's error message is logged when the username contains invalid characters. ```typescript import { CreateInboxInput } from "@anima-labs/schemas"; const inbox = CreateInboxInput.parse({ username: "support.team", domain: "example.com", displayName: "Support", agentId: "clxagent1...", }); const bad = CreateInboxInput.safeParse({ username: "bad user!" }); if (!bad.success) { console.log(bad.error.issues[0].message); // "Username can only contain letters, numbers, dots, hyphens, and underscores" } ``` -------------------------------- ### TypeScript: Compose API handler types with AgentListInput, AgentListOutput, AgentOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/types.md Use z.input and z.infer to derive request and page types from the schema objects. The example shows a listAgents function returning a Promise. ```typescript import { AgentListInput, AgentListOutput, AgentOutput } from "@anima-labs/schemas"; import type { z } from "zod"; type AgentListRequest = z.input; // { cursor?: string; limit?: number; status?: ... } type AgentPage = z.infer; // { items: Agent[]; pagination: { nextCursor: string | null; hasMore: boolean } } type Agent = z.infer; function listAgents(req: AgentListRequest): Promise { /* ... */ } ``` -------------------------------- ### Derive TypeScript types from Zod schemas with z.infer, z.input, z.output Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/types.md Use z.infer to get the parsed output type, z.input for the pre-parse input type (optional fields for .default()), and z.output for the post-defaults output type. Requires importing the schema and the z namespace from zod. ```typescript import { AgentOutput } from "@anima-labs/schemas"; import type { z } from "zod"; type Agent = z.infer; // parsed output type type AgentInput = z.input; // pre-parse input type type AgentOutputFull = z.output; // post-defaults output ``` -------------------------------- ### OpenClawSelfSignupOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Schema for the self-signup response output. Defines the structure of the provisioned organization, agent, and credentials, including the plaintext API key returned only once. ```APIDOC ## OpenClawSelfSignupOutput ### Description Schema for the self-signup response output. Defines the structure of the provisioned organization, agent, and credentials, including the plaintext API key returned only once. ### Fields #### organization | Field | Type | Required | Description | |---|---|---|---| | id | string (cuid) | required | Provisioned organization ID. | | name | string | required | Organization name. | | slug | string | required | Organization slug. | | tier | enum ["FREE", "DEVELOPER", "GROWTH", "SCALE", "ENTERPRISE"] | required | Server-assigned tier (not taken from input). | | createdAt | string (datetime) | required | Creation timestamp. | #### agent | Field | Type | Required | Description | |---|---|---|---| | id | string (cuid) | required | Provisioned agent ID. | | orgId | string (cuid) | required | Organization ID. | | name | string | required | Agent name. | | slug | string | required | Agent slug. | | email | string (email) | required | Agent email. | | phoneNumber | string | required | Agent phone number. | | apiKeyPrefix | string | required | API key prefix (echoes credentials prefix). | | createdAt | string (datetime) | required | Creation timestamp. | #### credentials | Field | Type | Required | Description | |---|---|---|---| | apiKey | string | required | Plaintext API key — returned once. | | apiKeyPrefix | string | required | Key prefix. | ### Example ```typescript import { OpenClawSelfSignupOutput } from "@anima-labs/schemas"; const result = OpenClawSelfSignupOutput.parse(await api.selfSignup(input)); // result.credentials.apiKey — store securely, it is not returned again ``` ``` -------------------------------- ### Re-export MessageOutput and SendSmsInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/phone.md Re-exports the message-module schemas verbatim so phone consumers get one import path. These schemas are documented in message.md. ```typescript export { MessageOutput, SendSmsInput }; ``` -------------------------------- ### Import and use Zod schemas Source: https://github.com/anima-labs-ai/schemas/blob/main/README.md Import AgentSchema, InboxSchema, and EmailSchema from the package. Use the parse method to validate data, such as agent data or API responses. ```typescript import { AgentSchema, InboxSchema, EmailSchema } from "@anima-labs/schemas"; // Validate agent data const agent = AgentSchema.parse(data); // Use in API contracts const inbox = InboxSchema.parse(response); ``` -------------------------------- ### CreateWebhookInput schema definition Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/webhook.md Defines the input schema for creating a webhook. Requires a URL and events array, with optional description and active flag (defaults to true). ```typescript export const CreateWebhookInput = z.object({ url: z.string().url(), events: z.array(WebhookEventSchema), description: z.string().optional(), active: z.boolean().default(true).optional(), }); ``` -------------------------------- ### CreateAgentInput - Schema Definition Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Defines the input schema for creating an agent. Requires orgId (CUID), name (2-100 chars), and slug (lowercase, digits, hyphens). Optional fields: email, provisionPhone (default false), and metadata (default {}). ```typescript export const CreateAgentInput = z.object({ orgId: z.string().cuid(), name: z.string().min(2).max(100), slug: z .string() .min(2) .max(64) .regex(/^[a-z0-9-]+$/), email: z.string().email().optional(), provisionPhone: z.boolean().default(false).optional(), metadata: z.record(z.string(), z.unknown()).default({}), }); ``` -------------------------------- ### PhoneProvisionOutput Zod Schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/phone.md Defines the output schema for phone provisioning. Includes fields for id, phoneNumber, provider (TELNYX or TWILIO), providerId (nullable), capabilities (sms, mms, voice booleans), tenDlcStatus (PENDING, REGISTERED, REJECTED, NOT_REQUIRED), isPrimary, and createdAt (datetime string). All fields are required. ```typescript export const PhoneProvisionOutput = z.object({ id: z.string(), phoneNumber: z.string(), provider: z.enum(["TELNYX", "TWILIO"]), providerId: z.string().nullable(), capabilities: z.object({ sms: z.boolean(), mms: z.boolean(), voice: z.boolean(), }), tenDlcStatus: z.enum(["PENDING", "REGISTERED", "REJECTED", "NOT_REQUIRED"]), isPrimary: z.boolean(), createdAt: z.string().datetime(), }); ``` -------------------------------- ### OpenClawAuthorizeOutput schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Defines the output of the authorize step. `enabled` indicates if the integration is enabled, `redirectUrl` is the OAuth authorize URL or null when disabled, and `state` is the server-generated state token or null. ```typescript export const OpenClawAuthorizeOutput = z.object({ enabled: z.boolean(), redirectUrl: z.string().url().nullable(), state: z.string().nullable(), }); ``` -------------------------------- ### Parsing DomainDnsRecordsOutput and adding DKIM records Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/email.md Example usage of the DomainDnsRecordsOutput schema: parses the API response and iterates over the DKIM records to add TXT entries via a DNS client. Requires an API client that returns the domain records and a DNS client with an addTxt method. ```typescript import { DomainDnsRecordsOutput } from "@anima-labs/schemas"; const records = DomainDnsRecordsOutput.parse( await api.getDomainRecords(domainId), ); for (const dkim of records.dkim) dnsClient.addTxt(dkim.name, dkim.value); ``` -------------------------------- ### CreateApiKeyInput: Zod object for API key creation Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Defines the input schema for creating an API key. Fields: name (optional, 1-100 chars), mode (default "LIVE"), agentId (optional cuid), scopes (default []), expiresAt (optional datetime). Output shape includes mode as "LIVE" and scopes as string[]. ```typescript export const CreateApiKeyInput = z.object({ name: z.string().min(1).max(100).optional(), mode: KeyModeSchema.default("LIVE"), agentId: z.string().cuid().optional(), scopes: z.array(z.string()).default([]), expiresAt: z.string().datetime().optional(), }); ``` -------------------------------- ### getTotp Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Fetches a TOTP output for a given credential. The input is a VaultCredentialIdInput object and the output is a TotpOutput. ```APIDOC ## getTotp ### Description Fetches a TOTP output for a given credential. The input is a VaultCredentialIdInput object and the output is a TotpOutput. ### Input - **agentId** (`AgentIdSchema`) - Required - Agent scope. - **id** (`z.string()`) - Required - Credential to fetch/act on. ### Output - **TotpOutput** - The TOTP output. ### Example ```typescript import { VaultCredentialIdInput, TotpOutput } from "@anima-labs/schemas"; const target = VaultCredentialIdInput.parse({ agentId: "clxagent1...", id: "cred_1" }); const totp = TotpOutput.parse(await api.getTotp(target)); ``` ``` -------------------------------- ### CreateOrgInput schema definition Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/organization.md Defines the input schema for creating an organization. Requires name and slug, with optional clerkOrgId, tier defaulting to "FREE", and settings defaulting to {}. ```typescript export const CreateOrgInput = z.object({ name: z.string().min(2).max(120), slug: z .string() .min(2) .max(64) .regex(/^[a-z0-9-]+$/), clerkOrgId: z.string().min(1).max(128).optional(), tier: TierSchema.default("FREE"), settings: z.record(z.string(), z.unknown()).default({}), }); ``` -------------------------------- ### Using ApiKeyWithSecretOutput to parse a response Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Imports ApiKeyWithSecretOutput from @anima-labs/schemas and parses a response to extract id, prefix, and key. The key is truncated for display. ```typescript import { ApiKeyWithSecretOutput } from "@anima-labs/schemas"; const { id, prefix, key } = ApiKeyWithSecretOutput.parse(response); console.log(id, prefix, key.slice(0, 12) + "…"); ``` -------------------------------- ### OpenClawSelfSignupInput Zod Schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Defines the input schema for OpenClaw self-signup. Requires openclawAgentId, organizationName, organizationSlug, agentName, agentSlug, email, and phoneNumber. phoneProvider defaults to "TELNYX" and is optional; metadata is optional free-form. ```typescript export const OpenClawSelfSignupInput = z.object({ openclawAgentId: z.string().min(1), organizationName: z.string().min(2).max(120), organizationSlug: z .string() .min(2) .max(64) .regex(/^[a-z0-9-]+$/), agentName: z.string().min(2).max(100), agentSlug: z .string() .min(2) .max(64) .regex(/^[a-z0-9-]+$/), email: z.string().email(), phoneNumber: z.string().min(7).max(20), phoneProvider: z.enum(["TELNYX", "TWILIO"]).default("TELNYX").optional(), metadata: z.record(z.string(), z.unknown()).optional(), }); ``` -------------------------------- ### CreateCredentialInput definition Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Defines the input schema for creating a credential. Requires agentId, type, and name (min length 1). favorite defaults to false. All other fields are optional. ```typescript export const CreateCredentialInput = z.object({ agentId: AgentIdSchema, type: CredentialTypeSchema, name: z.string().min(1), notes: z.string().optional(), login: LoginCredentialSchema.optional(), card: CardCredentialSchema.optional(), identity: IdentityCredentialSchema.optional(), fields: z.array(CustomFieldSchema).optional(), favorite: z.boolean().default(false).optional(), folderId: z.string().optional(), organizationId: z.string().optional(), collectionIds: z.array(z.string()).optional(), }); ``` -------------------------------- ### OpenClawSelfSignupOutput Zod Schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Defines the output schema for OpenClaw self-signup. Contains organization, agent, and credentials objects. The tier is server-assigned, not taken from input. The apiKey is returned in plaintext only once. ```typescript export const OpenClawSelfSignupOutput = z.object({ organization: z.object({ id: z.string().cuid(), name: z.string(), slug: z.string(), tier: z.enum(["FREE", "DEVELOPER", "GROWTH", "SCALE", "ENTERPRISE"]), createdAt: z.string().datetime(), }), agent: z.object({ id: z.string().cuid(), orgId: z.string().cuid(), name: z.string(), slug: z.string(), email: z.string().email(), phoneNumber: z.string(), apiKeyPrefix: z.string(), createdAt: z.string().datetime(), }), credentials: z.object({ apiKey: z.string(), apiKeyPrefix: z.string(), }), }); ``` -------------------------------- ### RotateApiKeyInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/api-keys.md Zod schema for rotating an API key. Requires the key ID. ```APIDOC ## RotateApiKeyInput ### Description Zod schema for rotating an API key. Requires the key ID. ### Fields - **id** (`z.string().cuid()`) - Required - Key ID to rotate (issuance of a new secret). ### Example ```typescript import { RotateApiKeyInput } from "@anima-labs/schemas"; const rotate = RotateApiKeyInput.parse({ id: "clxkey1..." }); ``` ``` -------------------------------- ### AgentListInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Input schema for listing agents. Extends PaginationInput with optional filters for organization, status, and free-text search. ```APIDOC ## AgentListInput ### Description Input schema for listing agents. Extends PaginationInput with optional filters for organization, status, and free-text search. ### Fields - **cursor** (string) - Optional - Pagination cursor. - **limit** (number) - Optional - Default: `20` - Maximum number of items to return. - **orgId** (string) - Optional - Filter by organization. - **status** (AgentStatusSchema) - Optional - Filter by status. - **query** (string) - Optional - Free-text search, 1–120 chars. ### Example ```typescript import { AgentListInput } from "@anima-labs/schemas"; const query = AgentListInput.parse({ status: "ACTIVE", limit: 10 }); ``` ``` -------------------------------- ### AgentListOutput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/agent.md Output schema for listing agents. Returns a page of agents along with cursor-based pagination information. ```APIDOC ## AgentListOutput ### Description Output schema for listing agents. Returns a page of agents along with cursor-based pagination information. ### Fields - **items** (array of AgentOutput) - Required - Page of agents. - **pagination** (CursorPagination) - Required - `nextCursor` + `hasMore` envelope. ### Example ```typescript import { AgentListOutput } from "@anima-labs/schemas"; const response: unknown = await api.listAgents(query); const { items, pagination } = AgentListOutput.parse(response); if (pagination.hasMore) { await api.listAgents(AgentListInput.parse({ cursor: pagination.nextCursor })); } ``` ``` -------------------------------- ### Parsing OpenClaw Callback Response Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Shows how to parse a callback response using OpenClawCallbackOutput and access the linked agent and tokens. Logs the agent email and token expiry if both are present. ```typescript import { OpenClawCallbackOutput } from "@anima-labs/schemas"; const result = OpenClawCallbackOutput.parse(response); if (result.agent && result.tokens) { console.log(`Linked ${result.agent.email} until ${result.tokens.expiresAt}`); } ``` -------------------------------- ### LoginCredentialSchema - Login Credentials Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/vault.md Exported object schema for login credentials with optional username, password, URIs, and TOTP fields. ```typescript export const LoginCredentialSchema = z.object({ username: z.string().optional(), password: z.string().optional(), uris: z.array(CredentialUriSchema).optional(), totp: z.string().optional(), }); ``` -------------------------------- ### OpenClawSelfSignupInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Schema for the self-signup request input. Validates and defines the fields required to provision an OpenClaw agent and organization. ```APIDOC ## OpenClawSelfSignupInput ### Description Schema for the self-signup request input. Validates and defines the fields required to provision an OpenClaw agent and organization. ### Fields | Field | Type | Required | Default | Description | |---|---|---|---|---| | openclawAgentId | string (min 1) | required | — | OpenClaw agent/account ID. | | organizationName | string (min 2, max 120) | required | — | Org display name. | | organizationSlug | string (min 2, max 64, regex /^[a-z0-9-]+$/) | required | — | Org slug. | | agentName | string (min 2, max 100) | required | — | Agent display name. | | agentSlug | string (min 2, max 64, regex /^[a-z0-9-]+$/) | required | — | Agent slug. | | email | string (email format) | required | — | Contact email. | | phoneNumber | string (min 7, max 20) | required | — | Phone for the provisioned agent. | | phoneProvider | enum ["TELNYX", "TWILIO"] | optional | "TELNYX" | Carrier provider. | | metadata | record | optional | — | Free-form metadata. | ### Example ```typescript import { OpenClawSelfSignupInput } from "@anima-labs/schemas"; const input = OpenClawSelfSignupInput.parse({ openclawAgentId: "oc_42", organizationName: "Acme", organizationSlug: "acme", agentName: "Acme Agent", agentSlug: "acme-agent", email: "ops@acme.example", phoneNumber: "+14155550132", }); ``` ``` -------------------------------- ### TypeScript: Narrow channel unions with MessageOutput and MessageChannelSchema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/types.md Shows how to check and switch on the channel field using MessageChannelSchema.options and MessageOutput.parse. The switch case narrows the parsed type to a specific channel. ```typescript // Narrowed channel unions import { MessageOutput, MessageChannelSchema } from "@anima-labs/schemas"; type Channel = z.infer; // "EMAIL" | "SMS" | "MMS" | "VOICE" if ((MessageChannelSchema.options as readonly string[]).includes(raw.channel)) {} switch (raw.channel) { case "SMS": { const sms = MessageOutput.parse(raw) as z.infer & { channel: "SMS" }; break; } } ``` -------------------------------- ### OrgListInput Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/organization.md Input schema for listing organizations. Extends PaginationInput and adds an optional free-text search query. ```APIDOC ## OrgListInput ### Description Input schema for listing organizations. Extends PaginationInput and adds an optional free-text search query. ### Fields - **query** (string) - Optional - Free-text search, min length 1, max length 120. ### Example ```typescript import { OrgListInput } from "@anima-labs/schemas"; const input = OrgListInput.parse({ query: "acme", limit: 50 }); ``` ``` -------------------------------- ### OpenClawListRegisteredOutput Schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/openclaw.md Defines the paginated output for listing registered agents, containing an array of agent outputs and cursor pagination metadata. ```typescript export const OpenClawListRegisteredOutput = z.object({ items: z.array(OpenClawRegisteredAgentOutput), pagination: CursorPagination, }); ``` -------------------------------- ### AttachmentDownloadOutput schema Source: https://github.com/anima-labs-ai/schemas/blob/main/_autodocs/api-reference/message.md Zod object schema for attachment download output, requiring a URL string and an ISO datetime string for expiry. ```typescript export const AttachmentDownloadOutput = z.object({ url: z.string().url(), expiresAt: z.string().datetime(), }); ```