### Install Anima SDK with yarn Source: https://github.com/anima-labs-ai/node/blob/main/README.md Install the SDK using the yarn package manager. ```bash yarn add @anima-labs/sdk ``` -------------------------------- ### Install Anima SDK with npm Source: https://github.com/anima-labs-ai/node/blob/main/README.md Install the SDK using the npm package manager. ```bash npm install @anima-labs/sdk ``` -------------------------------- ### Quick Start with Anima SDK Source: https://github.com/anima-labs-ai/node/blob/main/README.md Initialize the Anima client and send an email message from an agent. ```ts import { Anima } from "@anima-labs/sdk"; const anima = new Anima({ apiKey: "mk_your_api_key", }); // Send an email from an agent const message = await anima.messages.sendEmail({ agentId: "agent_abc123", to: ["user@example.com"], subject: "Welcome!", body: "Thanks for signing up.", }); console.log(message.id, message.status); ``` -------------------------------- ### Install Anima SDK with pnpm Source: https://github.com/anima-labs-ai/node/blob/main/README.md Install the SDK using the pnpm package manager. ```bash pnpm add @anima-labs/sdk ``` -------------------------------- ### Implement cursor-based pagination Source: https://github.com/anima-labs-ai/node/blob/main/README.md Demonstrates how to fetch the first page, retrieve subsequent pages using a cursor, and iterate through all available pages using a loop. ```ts // First page const page1 = await anima.agents.list({ orgId: "org_id", limit: 10 }); console.log(page1.items); console.log(page1.pagination.hasMore); // Next page if (page1.pagination.hasMore && page1.pagination.nextCursor) { const page2 = await anima.agents.list({ orgId: "org_id", limit: 10, cursor: page1.pagination.nextCursor, }); } // Iterate all pages let cursor: string | undefined; do { const page = await anima.agents.list({ orgId: "org_id", limit: 100, cursor }); for (const agent of page.items) { console.log(agent.name); } cursor = page.pagination.nextCursor ?? undefined; } while (cursor); ``` -------------------------------- ### Configure Anima Client Source: https://github.com/anima-labs-ai/node/blob/main/README.md Initialize the Anima client with optional configuration parameters including baseUrl, timeout, and maxRetries. ```ts const anima = new Anima({ apiKey: "mk_your_api_key", // Required — your organization master key or agent API key baseUrl: "https://api.useanima.sh", // Optional — defaults to https://api.useanima.sh timeout: 30_000, // Optional — request timeout in ms (default: 30s) maxRetries: 3, // Optional — retry count for 429/5xx errors (default: 3) }); ``` -------------------------------- ### Handle Provisioning Requests Source: https://github.com/anima-labs-ai/node/blob/main/README.md Agents use provisioning requests to ask owners for resources like vaults or phone numbers. Owners can approve or decline these requests using a master key. ```ts // As the agent: ask for a vault. `reason` is shown verbatim to the owner. const req = await anima.provisioningRequests.create({ resource: "VAULT", reason: "To store the Stripe key so I can issue refunds", }); // emailSent: false does NOT mean the request failed — it is live in the // console either way — but nobody was told, so nothing will happen until // someone looks. if (!req.emailSent) console.warn("owner was not notified"); // Poll for the decision. `decidedNote` carries the owner's reason for a // decline, so a second attempt can address it instead of repeating the first. const current = await anima.provisioningRequests.get(req.requestId); if (current.status === "APPROVED") { console.log("provisioned:", current.provisionedId); } // Withdraw an ask you no longer need. await anima.provisioningRequests.cancel(req.requestId); // As the owner (master key only): decide. await anima.provisioningRequests.approve(req.requestId); await anima.provisioningRequests.decline(req.requestId, { note: "Tell me which API first", }); // A phone number takes options; Starter+ plans only. await anima.provisioningRequests.create({ resource: "PHONE_NUMBER", reason: "To receive delivery notifications", options: { countryCode: "US", areaCode: "415" }, }); ``` -------------------------------- ### anima.provisioningRequests.create Source: https://github.com/anima-labs-ai/node/blob/main/README.md Creates a request for a resource like a VAULT or PHONE_NUMBER. ```APIDOC ## anima.provisioningRequests.create(params) ### Description Files a request for a resource that requires owner approval. ### Parameters - **resource** (string) - Required - 'VAULT' or 'PHONE_NUMBER' - **reason** (string) - Required - Reason for the request - **options** (object) - Optional - Additional configuration for resources like phone numbers ``` -------------------------------- ### Import SDK type definitions Source: https://github.com/anima-labs-ai/node/blob/main/README.md Shows how to import resource-specific types from the main package for use in TypeScript projects. ```ts import type { AgentOutput, MessageOutput, OrganizationOutput, SendEmailInput, WebhookEvent, AnimaClientOptions, } from "@anima-labs/sdk"; ``` -------------------------------- ### Handle typed errors with try-catch Source: https://github.com/anima-labs-ai/node/blob/main/README.md Demonstrates how to catch and differentiate between various SDK error types using instanceof checks. ```ts import { Anima, APIError, AuthError, ConflictError, InternalServerError, NotFoundError, RateLimitError, ValidationError, } from "@anima-labs/sdk"; try { await anima.agents.get("nonexistent"); } catch (error) { if (error instanceof AuthError) { // 401/403 — invalid or expired API key console.error("Auth failed:", error.message); } else if (error instanceof NotFoundError) { // 404 — resource doesn't exist console.error("Not found:", error.message); } else if (error instanceof ValidationError) { // 400/422 — invalid request parameters console.error("Validation:", error.message, error.details); } else if (error instanceof ConflictError) { // 409 — resource conflict (e.g. duplicate slug) console.error("Conflict:", error.message); } else if (error instanceof RateLimitError) { // 429 — rate limited, check retryAfter console.error("Rate limited, retry after:", error.retryAfter, "seconds"); } else if (error instanceof InternalServerError) { // 5xx — server error console.error("Server error:", error.status, error.message); } else if (error instanceof APIError) { // Other API errors console.error(error.status, error.code, error.message); } } ``` -------------------------------- ### anima.extension.connect Source: https://github.com/anima-labs-ai/node/blob/main/README.md Mints a connect URL for the Anima browser extension. ```APIDOC ## anima.extension.connect(params) ### Description Generates a URL to bind the browser extension to an agent session. ### Parameters - **agentId** (string) - Optional - **ttl** (string) - Optional - Time to live ('15m', '1h', 'session') ``` -------------------------------- ### Anima.webhooks.constructEvent Source: https://github.com/anima-labs-ai/node/blob/main/README.md Verifies the webhook signature and parses the event payload in a single step. ```APIDOC ## Anima.webhooks.constructEvent ### Description Verifies the signature of an incoming webhook request and returns the parsed event object. This method ensures the request originated from Anima by validating the HMAC-SHA256 signature. ### Parameters - **payload** (Buffer) - The raw request body bytes. - **headers** (Object) - An object containing `signature` and `timestamp` strings from the request headers. - **secret** (string) - The webhook secret key used for verification. ``` -------------------------------- ### Manage Webhooks with anima.webhooks Source: https://github.com/anima-labs-ai/node/blob/main/README.md Create, list, update, delete, and test webhooks. Includes configuration for authentication and rate limiting. ```ts // Create a webhook const webhook = await anima.webhooks.create({ url: "https://your-app.com/webhooks/anima", events: ["message.received", "message.sent", "agent.created"], description: "Production webhook", // Optional: auth Anima presents to your endpoint, in addition to the // always-on X-Anima-Signature HMAC. Also: bearer / basic / custom_header. authConfig: { type: "bearer", token: "your-endpoint-secret" }, rateLimitPerMinute: 60, // omit for unlimited maxAttempts: 5, // 1..10, default 3 }); // List, get, update, delete const webhooks = await anima.webhooks.list({ limit: 10 }); const wh = await anima.webhooks.get("webhook_id"); await anima.webhooks.update("webhook_id", { active: false }); await anima.webhooks.delete("webhook_id"); // Test a webhook const { deliveryId } = await anima.webhooks.test("webhook_id", "message.sent"); // List deliveries const deliveries = await anima.webhooks.listDeliveries("webhook_id", { limit: 20 }); ``` -------------------------------- ### Manage Domains with anima.domains Source: https://github.com/anima-labs-ai/node/blob/main/README.md Configure custom domains, verify DNS records, retrieve zone files, and check deliverability statistics. ```ts // Add a custom domain const domain = await anima.domains.add({ domain: "mail.example.com" }); // Verify domain DNS const verified = await anima.domains.verify("domain_id"); // Get DNS records to configure const records = await anima.domains.dnsRecords("domain_id"); // Get zone file const { zoneFile } = await anima.domains.zoneFile("domain_id"); // Check deliverability stats const stats = await anima.domains.deliverability("domain_id"); // List, get, update, delete const domains = await anima.domains.list(); const domain = await anima.domains.get("domain_id"); await anima.domains.update("domain_id", { feedbackEnabled: true }); await anima.domains.delete("domain_id"); ``` -------------------------------- ### Verify Webhooks with Middleware Source: https://github.com/anima-labs-ai/node/blob/main/README.md Mount the webhookMiddleware to automatically verify the signature and attach the event to the request object as req.webhookEvent. ```ts import { webhookMiddleware } from "@anima-labs/sdk"; app.post( "/webhooks/anima", express.raw({ type: "application/json" }), webhookMiddleware(process.env.ANIMA_WEBHOOK_SECRET!), (req, res) => { console.log(req.webhookEvent.event); res.sendStatus(200); }, ); ``` -------------------------------- ### anima.webhooks Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for managing webhooks, including creation, testing, and delivery tracking. ```APIDOC ## anima.webhooks.create(params) Creates a new webhook. ## anima.webhooks.list(params) Lists webhooks. ## anima.webhooks.get(webhookId) Retrieves a specific webhook. ## anima.webhooks.update(webhookId, params) Updates a webhook. ## anima.webhooks.delete(webhookId) Deletes a webhook. ## anima.webhooks.test(webhookId, event) Tests a webhook event. ## anima.webhooks.listDeliveries(webhookId, params) Lists delivery history for a webhook. ``` -------------------------------- ### Verify Webhooks Manually with Anima SDK Source: https://github.com/anima-labs-ai/node/blob/main/README.md Use express.raw to ensure the raw body is preserved for signature verification. The constructEvent method parses the event, while verify returns a boolean status. ```ts import express from "express"; import { Anima } from "@anima-labs/sdk"; // express.raw is required: the signature covers the exact bytes we sent, and // re-serialising a parsed body can reorder keys or drop whitespace. app.post( "/webhooks/anima", express.raw({ type: "application/json" }), (req, res) => { const headers = { signature: req.headers["x-anima-signature"] as string, timestamp: req.headers["x-anima-timestamp"] as string, }; const secret = process.env.ANIMA_WEBHOOK_SECRET!; // Verify and parse in one step try { const event = Anima.webhooks.constructEvent(req.body, headers, secret); // The payload is flat — no `data` envelope to unwrap. console.log(event.event, event.occurredAt, event.messageId); } catch { return res.status(400).send("Invalid signature"); } // …or verify only const isValid = Anima.webhooks.verify(req.body, headers, secret); if (!isValid) { return res.status(400).send("Invalid signature"); } res.status(200).send("OK"); }, ); ``` -------------------------------- ### Manage Agents Source: https://github.com/anima-labs-ai/node/blob/main/README.md Operations for creating, listing, retrieving, updating, deleting, and rotating API keys for agents. ```ts // Create an agent const agent = await anima.agents.create({ orgId: "org_id", name: "Support Bot", slug: "support-bot", email: "support@yourdomain.com", // optional — provision email identity provisionPhone: true, // optional — provision phone number }); // List agents with filtering const agents = await anima.agents.list({ orgId: "org_id", status: "ACTIVE", query: "support", limit: 10, }); // Get, update, delete const agent = await anima.agents.get("agent_id"); await anima.agents.update("agent_id", { name: "Updated Name" }); await anima.agents.delete("agent_id"); // Rotate agent API key const { apiKey, apiKeyPrefix } = await anima.agents.rotateKey("agent_id"); ``` -------------------------------- ### anima.domains Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for managing custom domains, DNS records, and deliverability statistics. ```APIDOC ## anima.domains.add(params) Adds a custom domain. ## anima.domains.verify(domainId) Verifies domain DNS settings. ## anima.domains.dnsRecords(domainId) Retrieves DNS records for configuration. ## anima.domains.zoneFile(domainId) Retrieves the zone file for a domain. ## anima.domains.deliverability(domainId) Checks deliverability statistics. ## anima.domains.list() Lists all domains. ## anima.domains.get(domainId) Retrieves a specific domain. ## anima.domains.update(domainId, params) Updates domain configuration. ## anima.domains.delete(domainId) Deletes a domain. ``` -------------------------------- ### Manage Organizations Source: https://github.com/anima-labs-ai/node/blob/main/README.md Operations for creating, listing, retrieving, updating, deleting, and rotating master keys for organizations. ```ts // Create an organization const org = await anima.organizations.create({ name: "Acme Corp", slug: "acme-corp", }); // List organizations const orgs = await anima.organizations.list({ limit: 20 }); // Get, update, delete const org = await anima.organizations.get("org_id"); await anima.organizations.update("org_id", { name: "New Name" }); await anima.organizations.delete("org_id"); // Rotate master key const { masterKey } = await anima.organizations.rotateKey("org_id"); ``` -------------------------------- ### anima.agents Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for managing AI agents, including creation, listing, updates, deletion, and API key rotation. ```APIDOC ## anima.agents.create(data) Creates a new agent with optional email and phone provisioning. ## anima.agents.list(params) Lists agents with filtering by orgId, status, and query. ## anima.agents.get(id) Retrieves an agent by ID. ## anima.agents.update(id, data) Updates agent details. ## anima.agents.delete(id) Deletes an agent. ## anima.agents.rotateKey(id) Rotates the API key for an agent. ``` -------------------------------- ### anima.organizations Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for managing organizations, including creation, retrieval, updates, deletion, and master key rotation. ```APIDOC ## anima.organizations.create(data) Creates a new organization. ## anima.organizations.list(params) Lists organizations with optional pagination. ## anima.organizations.get(id) Retrieves a specific organization by ID. ## anima.organizations.update(id, data) Updates an existing organization. ## anima.organizations.delete(id) Deletes an organization. ## anima.organizations.rotateKey(id) Rotates the master key for an organization. ``` -------------------------------- ### Anima.webhooks.verify Source: https://github.com/anima-labs-ai/node/blob/main/README.md Verifies the webhook signature without parsing the event payload. ```APIDOC ## Anima.webhooks.verify ### Description Validates the authenticity of a webhook request by checking the provided signature against the computed HMAC-SHA256 hash. ### Parameters - **payload** (Buffer) - The raw request body bytes. - **headers** (Object) - An object containing `signature` and `timestamp` strings from the request headers. - **secret** (string) - The webhook secret key used for verification. ``` -------------------------------- ### anima.phones Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for provisioning and managing phone numbers for agents. ```APIDOC ## anima.phones.provision(params) Provisions a new phone number. ## anima.phones.list(params) Lists phone numbers for an agent. ## anima.phones.get(phoneId) Retrieves a phone number by ID. ## anima.phones.updateConfig(phoneId, params) Updates phone configuration. ## anima.phones.release(phoneId) Releases a phone number. ``` -------------------------------- ### Manage Vault Credentials and Security Source: https://github.com/anima-labs-ai/node/blob/main/README.md Provision vaults, store or generate credentials, and perform lifecycle operations like listing, searching, updating, and deleting. Includes utilities for generating secure passwords and retrieving TOTP codes. ```ts // Provision a vault for an agent const vault = await anima.vault.provision({ agentId: "agent_id" }); // Store credentials const credential = await anima.vault.createCredential({ agentId: "agent_id", type: "login", name: "GitHub", login: { username: "bot@example.com", password: "secure-password", uris: [{ uri: "https://github.com/login" }], }, }); // Or have the vault generate the password server-side — it is stored // with the credential and never returned; the response carries only the // masked credential ref. (Defaults: 24 chars, all character classes.) const generated = await anima.vault.createCredential({ agentId: "agent_id", type: "login", name: "Acme Portal", login: { username: "bot@example.com" }, generatePassword: { length: 32 }, }); // List and search credentials const creds = await anima.vault.listCredentials({ agentId: "agent_id", type: "login" }); const results = await anima.vault.search({ agentId: "agent_id", search: "github" }); // Get, update, delete const cred = await anima.vault.getCredential("cred_id"); await anima.vault.updateCredential("cred_id", { name: "GitHub (prod)" }); await anima.vault.deleteCredential("cred_id"); // Generate a secure password const { password } = await anima.vault.generatePassword({ length: 32, uppercase: true, lowercase: true, number: true, special: true, }); // TOTP codes const { code, period } = await anima.vault.getTotp("cred_id"); // Vault status and sync const status = await anima.vault.status("agent_id"); await anima.vault.sync("agent_id"); // Deprovision await anima.vault.deprovision({ agentId: "agent_id" }); ``` -------------------------------- ### Connect Browser Extension Source: https://github.com/anima-labs-ai/node/blob/main/README.md Generate connection URLs for the Anima browser extension, useful for headless or Puppeteer workers. Supports both master key and agent-specific key authentication. ```ts // With a master key, pass the agent to connect. As the agent's own key, omit // agentId. `ttl` is optional and shorten-only ("15m" | "1h" | "session"). const { connectUrl, expiresAt, policy } = await anima.extension.connect({ agentId: "agent_id", ttl: "15m", }); // As the agent itself (agent key) — no arguments needed. const session = await anima.extension.connect(); ``` -------------------------------- ### anima.drafts Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for composing, managing, and sending email drafts. ```APIDOC ## anima.drafts.create(data) Creates a new email draft. ## anima.drafts.get(id) Retrieves a draft. ## anima.drafts.list(params) Lists drafts for an agent. ## anima.drafts.send(id) Sends a draft, converting it into a message. ## anima.drafts.delete(id) Deletes a draft. ``` -------------------------------- ### anima.vault.createCredential Source: https://github.com/anima-labs-ai/node/blob/main/README.md Stores a new credential in the vault, optionally generating a password server-side. ```APIDOC ## anima.vault.createCredential(params) ### Description Stores credentials such as logins. Can generate passwords if generatePassword is provided. ### Parameters - **agentId** (string) - Required - **type** (string) - Required - **name** (string) - Required - **login** (object) - Optional - **generatePassword** (object) - Optional ``` -------------------------------- ### webhookMiddleware Source: https://github.com/anima-labs-ai/node/blob/main/README.md Express middleware that automatically verifies the webhook signature and attaches the event to the request object. ```APIDOC ## webhookMiddleware ### Description An Express middleware function that handles signature verification automatically. If valid, it attaches the parsed event to `req.webhookEvent`. ### Parameters - **secret** (string) - The webhook secret key used for verification. ``` -------------------------------- ### Manage Inboxes with anima.inboxes Source: https://github.com/anima-labs-ai/node/blob/main/README.md Create, retrieve, list, update, and delete email inboxes. Creating an inbox without parameters provisions a generated address on the default domain. ```ts // Create an inbox — all fields optional; create() alone provisions a // generated address on the default domain const inbox = await anima.inboxes.create({ username: "support", // local part → support@ displayName: "Support", agentId: "agent_id", // optional — associate with an agent }); console.log(inbox.email); // Get, list, update, delete const fetched = await anima.inboxes.get("inbox_id"); const inboxes = await anima.inboxes.list({ query: "support", limit: 20 }); await anima.inboxes.update("inbox_id", { displayName: "Sales" }); await anima.inboxes.delete("inbox_id"); ``` -------------------------------- ### anima.inboxes Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for managing email inboxes, including creation, retrieval, listing, updating, and deletion. ```APIDOC ## anima.inboxes.create(params) Creates a new inbox. ## anima.inboxes.get(inboxId) Retrieves a specific inbox by ID. ## anima.inboxes.list(params) Lists inboxes with optional query and limit filters. ## anima.inboxes.update(inboxId, params) Updates an existing inbox. ## anima.inboxes.delete(inboxId) Deletes an inbox. ``` -------------------------------- ### anima.vault.listCredentials Source: https://github.com/anima-labs-ai/node/blob/main/README.md Retrieves a list of credentials associated with a specific agent. ```APIDOC ## anima.vault.listCredentials ### Description Lists credentials for a given agent. Returns a collection wrapped in an items envelope. ### Parameters - **agentId** (string) - Required - The ID of the agent whose credentials are being retrieved. ### Response - **items** (array) - A list of credentials associated with the agent. ``` -------------------------------- ### Browse Voices with anima.voices Source: https://github.com/anima-labs-ai/node/blob/main/README.md List available voices in the catalog, filter by language or gender, and access sample URLs for previews. ```ts // List every voice in the catalog const { voices } = await anima.voices.list(); // Only Spanish voices const spanish = await anima.voices.list({ language: "es" }); // Female English voices const enFemale = await anima.voices.list({ gender: "female", language: "en" }); for (const voice of voices) { console.log(voice.id, voice.name, voice.language, voice.descriptors); // Play a preview: `sampleUrl` is a vendor-neutral clip served from the API // host (undefined until a sample has been generated for that voice). if (voice.sampleUrl) console.log("preview:", voice.sampleUrl); } ``` -------------------------------- ### Manage Phone Numbers with anima.phones Source: https://github.com/anima-labs-ai/node/blob/main/README.md Provision phone numbers for agents, list existing numbers, update configurations, and release numbers. ```ts // Provision a phone number for an agent const phone = await anima.phones.provision({ agentId: "agent_id", countryCode: "US", capabilities: ["sms", "voice"], }); // List phone numbers const phones = await anima.phones.list({ agentId: "agent_id" }); // Get, update config, release const phone = await anima.phones.get("phone_id"); await anima.phones.updateConfig("phone_id", { isPrimary: true }); await anima.phones.release("phone_id"); ``` -------------------------------- ### Manage Email Drafts Source: https://github.com/anima-labs-ai/node/blob/main/README.md Operations for composing, fetching, listing, sending, and deleting email drafts. ```ts // Compose a draft — may be incomplete (no recipients / subject yet) const draft = await anima.drafts.create({ agentId: "agent_id", to: ["recipient@example.com"], subject: "Quarterly report", body: "Numbers attached.", }); // Get and list const fetched = await anima.drafts.get(draft.id); const drafts = await anima.drafts.list({ agentId: "agent_id", limit: 20 }); // Send — converts the draft into a real Message (threading, scanning and // limits all apply) and deletes the draft row. Resolves to the sent // Message; the draft id 404s afterwards. Incomplete drafts (missing // to/subject/body) are rejected with a ValidationError. const message = await anima.drafts.send(draft.id); console.log(message.status); // "SENT" // Delete without sending — resolves to the deleted draft const discarded = await anima.drafts.delete("draft_id"); ``` -------------------------------- ### anima.security Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for checking scanner status and listing security events. ```APIDOC ## anima.security.getScannerStatus(orgId) Retrieves the status of the AI scanner. ## anima.security.listEvents(params) Lists security events for an organization. ``` -------------------------------- ### Manage Emails Source: https://github.com/anima-labs-ai/node/blob/main/README.md Operations for listing email messages and managing email attachments. ```ts // List email messages const emails = await anima.emails.list({ agentId: "agent_id", limit: 20 }); // Attachment helpers const uploaded = await anima.emails.uploadAttachment("msg_id", { filename: "doc.pdf", mimeType: "application/pdf", sizeBytes: 2048, }); const download = await anima.emails.getAttachmentUrl("attachment_id"); ``` -------------------------------- ### Check Security Scanner Status with anima.security Source: https://github.com/anima-labs-ai/node/blob/main/README.md Query the status of the AI content scanner and list security events. Scanning runs automatically in send paths. ```ts // Content scanning is not a call you make. It runs inside the send paths, // so a blocked message surfaces as an error from emails.send / messages.send. // What you can query is whether the scanner is actually running: const { aiScanner } = await anima.security.getScannerStatus("org_id"); if (!aiScanner.active) { console.warn("AI scanning is off:", aiScanner.fallbackReason); } // List security events const events = await anima.security.listEvents({ orgId: "org_id", type: "PII_DETECTED", severity: "HIGH", limit: 20, }); ``` -------------------------------- ### anima.vault.provision Source: https://github.com/anima-labs-ai/node/blob/main/README.md Provisions a new vault for a specific agent. ```APIDOC ## anima.vault.provision(params) ### Description Provisions a vault for an agent. ### Parameters - **agentId** (string) - Required - The ID of the agent. ``` -------------------------------- ### Manage Messages Source: https://github.com/anima-labs-ai/node/blob/main/README.md Operations for sending emails and SMS, listing, searching, performing semantic searches, and managing attachments. ```ts // Send an email const email = await anima.messages.sendEmail({ agentId: "agent_id", to: ["recipient@example.com"], cc: ["cc@example.com"], subject: "Hello", body: "Plain text body", bodyHtml: "

Hello

", }); // Send with attachments — each entry provides EITHER base64 `content` // or a public `url` the server fetches (max 20 files, 25MB total) const withAttachment = await anima.messages.sendEmail({ agentId: "agent_id", to: ["recipient@example.com"], subject: "Report attached", body: "See the attached report.", attachments: [ { filename: "report.pdf", contentType: "application/pdf", content: "JVBERi0xLjQK..." }, { url: "https://files.example.com/big.pdf", filename: "big.pdf" }, ], }); // Reply in-thread by referencing Message-IDs const reply = await anima.messages.sendEmail({ agentId: "agent_id", to: ["recipient@example.com"], subject: "Re: Hello", body: "Replying in the same thread.", inReplyTo: "", references: [""], }); // Send an SMS const sms = await anima.messages.sendSms({ agentId: "agent_id", to: "+15551234567", body: "Your code is 123456", }); // List messages const messages = await anima.messages.list({ agentId: "agent_id", channel: "EMAIL", direction: "OUTBOUND", limit: 20, }); // Search messages const results = await anima.messages.search("verification", { filters: { status: "SENT", channel: "EMAIL" }, pagination: { limit: 10 }, }); // Semantic search — ranks messages by meaning, not text match: // finds "the invoice from last week" even when no message contains // those words. Results are ordered by similarity (best first). const semantic = await anima.messages.semanticSearch("the invoice from last week", { agentId: "agent_id", // optional — restrict to one agent limit: 10, // optional — max results (default 10) threshold: 0.7, // optional — min similarity 0-1 (default 0.7) }); for (const hit of semantic.results) { console.log(hit.similarity.toFixed(2), hit.content); } // Get a single message const msg = await anima.messages.get("msg_id"); // Attachments const attachment = await anima.messages.uploadAttachment("msg_id", { filename: "report.pdf", mimeType: "application/pdf", sizeBytes: 1024, }); const { url } = await anima.messages.getAttachmentUrl("attachment_id"); ``` -------------------------------- ### anima.messages Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for sending, searching, and managing email and SMS messages, including attachments and semantic search. ```APIDOC ## anima.messages.sendEmail(data) Sends an email, supports attachments, threading, and HTML bodies. ## anima.messages.sendSms(data) Sends an SMS message. ## anima.messages.list(params) Lists messages by agent, channel, or direction. ## anima.messages.search(query, options) Performs a text search on messages. ## anima.messages.semanticSearch(query, options) Performs a semantic search ranked by meaning. ## anima.messages.get(id) Retrieves a single message. ## anima.messages.uploadAttachment(msgId, data) Uploads an attachment to a message. ## anima.messages.getAttachmentUrl(attachmentId) Retrieves a download URL for an attachment. ``` -------------------------------- ### anima.voices Source: https://github.com/anima-labs-ai/node/blob/main/README.md Methods for browsing the multilingual voice catalog. ```APIDOC ## anima.voices.list(params) Lists voices in the catalog, with optional filters for language and gender. ``` -------------------------------- ### anima.vault.generatePassword Source: https://github.com/anima-labs-ai/node/blob/main/README.md Generates a password of a specified length. ```APIDOC ## anima.vault.generatePassword ### Description Generates a new password. Returns the value inside a password envelope. ### Parameters - **length** (number) - Required - The desired length of the generated password. ### Response - **password** (string) - The generated password string. ``` -------------------------------- ### Handle Response Envelopes Source: https://github.com/anima-labs-ai/node/blob/main/README.md Access data from response envelopes returned by vault methods, which are not automatically unwrapped. ```ts const { items } = await anima.vault.listCredentials({ agentId }); const { password } = await anima.vault.generatePassword({ length: 24 }); ``` -------------------------------- ### anima.messages.sendEmail Source: https://github.com/anima-labs-ai/node/blob/main/README.md Sends an email from a specified agent to one or more recipients. ```APIDOC ## anima.messages.sendEmail ### Description Sends an email message from a specific agent. ### Parameters - **agentId** (string) - Required - The ID of the agent sending the email. - **to** (string[]) - Required - An array of recipient email addresses. - **subject** (string) - Required - The subject line of the email. - **body** (string) - Required - The content of the email body. ### Response - **id** (string) - The unique identifier of the sent message. - **status** (string) - The delivery status of the message. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.