From 4c41fc6c3ead4518a93d273f241def7cd59869ed Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Fri, 21 Aug 2026 12:24:06 -0700 Subject: [PATCH 01/63] fix(setup): bump sim-setup to 1.0.1 (#6944) --- bun.lock | 2 +- packages/sim-setup/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 3388974a04c..83936801773 100644 --- a/bun.lock +++ b/bun.lock @@ -627,7 +627,7 @@ }, "packages/sim-setup": { "name": "sim-setup", - "version": "1.0.0", + "version": "1.0.1", "bin": { "sim-setup": "dist/index.js", }, diff --git a/packages/sim-setup/package.json b/packages/sim-setup/package.json index 7942f84939c..c6e5523474f 100644 --- a/packages/sim-setup/package.json +++ b/packages/sim-setup/package.json @@ -1,6 +1,6 @@ { "name": "sim-setup", - "version": "1.0.0", + "version": "1.0.1", "description": "Set up and manage a self-hosted Sim installation", "type": "module", "bin": { From 6a45b0d4a6c01163a195b57e74f7365ff56474c6 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 21 Aug 2026 12:45:59 -0700 Subject: [PATCH 02/63] feat(library): Best AI Agent Platforms for Connecting Your Existing Tools (#6946) Co-authored-by: Sim Pi Agent --- .../index.mdx | 288 ++++++++++++++++++ .../cover.jpg | Bin 0 -> 26210 bytes 2 files changed, 288 insertions(+) create mode 100644 apps/sim/content/library/best-ai-agent-platforms-for-connecting-your-existing-tools/index.mdx create mode 100644 apps/sim/public/library/best-ai-agent-platforms-for-connecting-your-existing-tools/cover.jpg diff --git a/apps/sim/content/library/best-ai-agent-platforms-for-connecting-your-existing-tools/index.mdx b/apps/sim/content/library/best-ai-agent-platforms-for-connecting-your-existing-tools/index.mdx new file mode 100644 index 00000000000..0799fda876f --- /dev/null +++ b/apps/sim/content/library/best-ai-agent-platforms-for-connecting-your-existing-tools/index.mdx @@ -0,0 +1,288 @@ +--- +slug: best-ai-agent-platforms-for-connecting-your-existing-tools +title: 'Best AI Agent Platforms for Connecting Your Existing Tools' +description: 'Compare the best AI agent platforms for connecting Slack, Notion, Airtable, and other existing tools, including Sim, Zapier, Make, n8n, Gumloop, and Workato.' +date: 2026-08-01 +updated: 2026-08-01 +authors: + - andrew +readingTime: 12 +tags: [AI Agents, Integrations, Automation, Comparison, Sim] +ogImage: /library/best-ai-agent-platforms-for-connecting-your-existing-tools/cover.jpg +canonical: https://www.sim.ai/library/best-ai-agent-platforms-for-connecting-your-existing-tools +draft: false +faq: + - q: "Does a smaller integration catalog matter when custom API access exists?" + a: "A smaller catalog matters less when a platform provides reliable API and MCP fallbacks, but native connectors still reduce setup and maintenance. Confirm authentication, triggers, rate limits, and required actions before choosing a platform." + - q: "What separates real-time triggers from polling triggers?" + a: "Real-time triggers launch workflows when an app sends an event, while polling triggers check periodically for changes. Real-time triggers suit urgent routing, while polling can handle less time-sensitive work." + - q: "Can these platforms write back to connected tools?" + a: "Yes, but write-back depth varies by platform and connector. Buyers should verify the exact create, update, and delete actions required for each production workflow." + - q: "Which platforms can be self-hosted?" + a: "Sim and n8n can be self-hosted. Sim uses the permissive Apache 2.0 license, while n8n's self-hosted edition uses its source-available Sustainable Use License. Self-hosting adds infrastructure responsibility as well as deployment control." + - q: "What is the best open-source Zapier alternative?" + a: "Sim is a strong open-source Zapier alternative for teams that need agent reasoning, write-back actions, real-time triggers, and a permissive Apache 2.0 license. Zapier remains better suited to teams that prioritize maximum connector breadth and managed setup." + - q: "What is the difference between Sim and Zapier?" + a: "Sim combines agent reasoning, deterministic workflow logic, write-back actions, and Apache 2.0 self-hosting, while Zapier prioritizes a large managed app catalog. Choose according to whether infrastructure control or catalog breadth matters more." +--- + +## TL;DR + +The best AI agent platforms for connecting existing tools are Sim, Zapier, Make, n8n, Gumloop, and Workato, but each is strongest for a different integration requirement. + +- **Sim** combines AI reasoning, write-back actions, real-time triggers, and Apache 2.0 self-hosting across a growing integration catalog. +- **[Zapier](https://zapier.com/apps)** offers a broad app catalog, instant triggers for many apps, and an API request fallback, but runs as a managed cloud service. +- **[Make](https://www.make.com/en/integrations)** provides a deep visual builder with instant and polling triggers, though integration depth varies by app. +- **[n8n](https://docs.n8n.io/)** supports self-hosting, code extensions, and a universal HTTP Request node, but uses a fair-code license. +- **[Gumloop](https://docs.gumloop.com)** favors managed, no-code workflows and AI-generated polling triggers, though its public integration documentation lacks detailed action lists. +- **[Workato](https://www.workato.com/integrations)** provides enterprise-managed connectors and governance, with heavier setup for integrations such as Slack. + +Teams seeking an open, self-hostable option can [start building with Sim](https://sim.ai). + +## Quick answer + +- **Best for AI reasoning with write-back:** Sim +- **Best for app catalog breadth:** [Zapier](https://zapier.com/apps) +- **Best visual scenario builder:** [Make](https://www.make.com/en) +- **Best for self-hosted deterministic automation:** [n8n](https://docs.n8n.io/hosting/) +- **Best managed no-code AI integration platform:** [Gumloop](https://docs.gumloop.com) +- **Best for enterprise governance:** [Workato](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html) + +For a broader view of the category, see our guides to the [best AI automation tools](https://www.sim.ai/library/best-ai-automation-tools-2026) and [open-source AI agent platforms](https://www.sim.ai/library/open-source-ai-agent-platforms). + +## Why integration depth is the real test for an AI agent platform + +An AI agent integration platform must read business data and take permitted actions in the tools you already use. Model quality cannot compensate for a connector that retrieves an Airtable record but cannot update it, or a Slack integration that can detect messages but cannot post a response. + +Action depth often matters more than catalog size. Read access gives an agent context, while write access lets it update records, send messages, or create pages. A catalog entry may represent one limited action or dozens of triggers, searches, and write operations. + +Trigger design determines how quickly a workflow responds. Webhook triggers run when an app sends an event, while polling triggers check for changes on a schedule. For example, [Zapier explains that polling intervals vary by plan](https://help.zapier.com/hc/en-us/articles/8496244568589-How-often-does-Zapier-check-for-new-data), while Sim provides webhook-based Airtable triggers. + +Custom API access also limits the impact of missing native actions. [Zapier supports API Request actions](https://help.zapier.com/hc/en-us/articles/12899607716493-Send-API-requests-in-Zaps), [Make offers a general HTTP app](https://www.make.com/en/integrations/http), and [n8n provides an HTTP Request node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/). Sim uses general API blocks and MCP connections for the same class of extension. + +We reviewed each vendor's documented Slack, Notion, and Airtable behavior, including read actions, write actions, triggers, and API fallbacks. The comparison reflects published connector behavior rather than catalog claims alone. + +## What to look for in an AI agent integration platform + +These five criteria show whether an agent can act through your existing tools rather than merely retrieve information. + +**Catalog size and depth.** Count supported apps, then inspect the available actions. A large catalog can still provide shallow coverage for important tools. + +**Read and write access.** Confirm that agents can retrieve records and create, update, or delete them. Write access enables workflows such as updating a CRM after qualifying a lead. + +**Trigger support.** Real-time webhooks start workflows when an event occurs. Polling checks periodically, which can delay responses and consume additional usage. + +**Custom API or HTTP fallback.** A raw API request, webhook block, or MCP connection can cover missing native actions. Check how the platform handles authentication and response data. If MCP is part of your architecture, learn [how to turn a workflow into a reusable MCP tool](https://www.sim.ai/library/how-to-turn-a-workflow-into-a-reusable-mcp-tool). + +**Self-hosting and deployment control.** Self-hosting gives you control over infrastructure and data handling. Hosted-only platforms reduce operational work but limit where the agent runtime can run. + +## Sim + +### Best for + +**Best for:** Teams that want an AI agent to reason over business data, choose an action, and write the result into an existing tool while retaining the option to self-host. + +[Sim](https://sim.ai) combines AI reasoning and deterministic logic in one workflow graph. An Agent block can interpret a Slack request or classify an Airtable record, while conditions, code, approvals, and integration actions control what happens next. The agent can update a record or send a response instead of stopping after analysis. + +Sim provides read and write coverage across the three integrations examined here. Its [Slack integration](https://www.sim.ai/integrations/slack) supports message, channel, file, user, canvas, and reaction operations alongside real-time message, mention, and reaction triggers. Airtable tools cover record creation, reading, updating, upserting, and deletion, plus a real-time webhook trigger. Notion tools cover pages, blocks, databases, comments, and users, with real-time triggers for supported events. + +The [Apache 2.0 licensed core](https://github.com/simstudioai/sim) gives buyers more infrastructure control than the managed platforms covered here. It can be self-hosted with Docker, and Sim can operate as both an MCP client and server so workflows can call external MCP tools or become tools that other AI systems use. + +### Pros + +- Deep write-back support for Slack, Notion, and Airtable, including real-time triggers. +- Agent reasoning works alongside explicit routing, code, and human approval. +- MCP client and server support provides an extension path beyond native integrations. +- BYOK supports connecting eligible model-provider keys directly. +- The Apache 2.0 core supports permissive self-hosting. + +### Cons + +- Sim's catalog remains smaller than the broader catalogs of established automation vendors. +- Buyers seeking simple, prebuilt app-to-app recipes may prefer a conventional no-code automation product. +- [Workato documents an established enterprise integration and governance stack](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html). + +### Pricing + +As of August 2026, [Sim's pricing page](https://www.sim.ai/pricing) lists Free, Pro, Max, and custom Enterprise options. Usage follows a credit model, so compare expected model and tool execution rather than subscription price alone. + +## Zapier + +### Best for + +**Best for:** Teams that prioritize app catalog breadth and familiar managed automation over infrastructure ownership or deeply integrated agent reasoning. + +Zapier maintains a large [app integration directory](https://zapier.com/apps). Its [Slack connector](https://zapier.com/apps/slack/integrations) and [Notion connector](https://zapier.com/apps/notion/integrations) provide documented read and write actions, with instant triggers available for supported events. + +The [Airtable connector](https://zapier.com/apps/airtable/integrations) supports record creation, updates, deletion, search, schema access, and API requests, while its listed Airtable triggers are polling based. Zapier Agents operates as a product layer alongside core Zaps, so buyers should understand how agent activity and automation tasks are metered. Teams comparing the broader ecosystem can also review the [best Zapier alternatives](https://www.sim.ai/library/best-zapier-alternatives). + +### Pros + +- [Zapier's app directory](https://zapier.com/apps) covers many SaaS tools. +- Its [Slack](https://zapier.com/apps/slack/integrations) and [Notion](https://zapier.com/apps/notion/integrations) connectors provide documented read, write, and instant-trigger options. +- [API Request actions](https://help.zapier.com/hc/en-us/articles/12899607716493-Send-API-requests-in-Zaps) can fill native-action gaps while retaining Zapier authentication. +- The [managed service](https://zapier.com/terms-of-service) removes infrastructure and upgrade work. + +### Cons + +- [Polling intervals](https://help.zapier.com/hc/en-us/articles/8496244568589-How-often-does-Zapier-check-for-new-data) can delay time-sensitive workflows. +- Zapier's separately presented [automation](https://zapier.com/pricing) and [Agents](https://zapier.com/agents) products can make AI workflow costs harder to estimate. +- [Zapier describes its service as a hosted platform](https://zapier.com/terms-of-service), not a self-hostable runtime. + +### Pricing + +[Zapier's pricing page](https://zapier.com/pricing) meters automation plans according to factors including task usage, features, and user access. Check the current Agents allowance separately when a workflow combines Zaps and agents. + +## Make + +### Best for + +**Best for:** Teams that prefer a mature visual scenario builder and need branching logic across business tools without writing much code. + +Make's canvas represents each trigger, action, or search as a module, so builders can inspect routes and configure how data moves between steps. Its [integration directory](https://www.make.com/en/integrations) covers a broad range of business apps. + +Make provides extensive [Slack modules](https://www.make.com/en/integrations/slack), including triggers, actions, and searches. Slack scenarios can use instant webhook triggers or scheduled polling. Make also documents [native Notion modules](https://www.make.com/en/integrations/notion), including page and database-item operations. + +The [Airtable integration](https://www.make.com/en/integrations/airtable) covers record searches and write operations. Its Make an API Call module lets builders reach Airtable endpoints that lack dedicated modules. + +### Pros + +- [Make's visual canvas](https://www.make.com/en) makes branches, filters, and multi-step routes easier to inspect. +- [Instant Slack triggers](https://www.make.com/en/integrations/slack) can start scenarios when supported events occur. +- The [Airtable API action](https://www.make.com/en/integrations/airtable) provides a fallback for missing native operations. +- Its [integration directory](https://www.make.com/en/integrations) supports many SaaS workflows. + +### Cons + +- The [modules listed for each connector](https://www.make.com/en/integrations) show that integration depth varies. +- [Make's plans use credits](https://www.make.com/en/pricing), so one workflow run can consume several credits. +- The platform's [scenario model](https://www.make.com/en/help/scenarios/scenario) can become harder to inspect as routes and modules accumulate. +- [Make provides its platform as a cloud service](https://www.make.com/en/terms-and-conditions-of-use), rather than documenting a self-hostable workflow runtime. + +### Pricing + +As of August 2026, [Make offers credit-based plans](https://www.make.com/en/pricing) from Free through Enterprise. Because module activity drives usage, estimate costs using the modules and AI features each scenario invokes rather than workflow runs alone. + +## n8n + +### Best for + +**Best for:** Technical teams that want self-hosted deterministic automation, code extensibility, and a reliable HTTP fallback when native integrations fall short. + +n8n combines a visual workflow engine with code, custom nodes, and a [universal HTTP Request node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/). Its live [integrations directory](https://n8n.io/integrations/) lists native and community-supported options, while HTTP requests can call external APIs with custom methods, authentication, headers, and bodies. + +Native integration depth varies by app. The [Notion node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.notion/) supports operations across databases, database pages, pages, blocks, and users. n8n also lists Slack and Airtable integrations, although buyers should inspect the current node documentation for every required trigger and action. For a closer comparison, see our guide to [n8n alternatives](https://www.sim.ai/library/n8n-alternatives). + +### Pros + +- [n8n documents self-hosting](https://docs.n8n.io/hosting/) for teams that want workflow data on infrastructure they control. +- [Cloud pricing is based on workflow executions](https://n8n.io/pricing/) rather than charging separately for every standard node step. +- Code nodes, custom nodes, and the HTTP Request node extend workflows beyond the native catalog. +- The [integration directory](https://n8n.io/integrations/) includes native and community options for many common tools. + +### Cons + +- [n8n uses its Sustainable Use License](https://docs.n8n.io/sustainable-use-license/), a fair-code license rather than a permissive OSI-approved open-source license. +- The operations and trigger coverage shown in [n8n's node documentation](https://docs.n8n.io/integrations/) vary by node. +- Technical flexibility comes with more deployment, security, upgrade, and maintenance work than a managed no-code platform. + +### Pricing + +[n8n's pricing page](https://n8n.io/pricing/) lists metered cloud plans. Its [self-hosted Community Edition](https://docs.n8n.io/hosting/community-edition-features/) is available under n8n's licensing terms, but users remain responsible for infrastructure, deployment, updates, security, and operating costs. + +## Gumloop + +### Best for + +**Best for:** Non-technical operations and go-to-market teams that want a polished managed canvas and AI-assisted connector setup without operating infrastructure. + +Gumloop emphasizes managed no-code workflows and generated connectors over manual API work. Its documentation describes [AI-created triggers](https://docs.gumloop.com/core-concepts/triggers) that monitor external apps, while its [Slack integration](https://docs.gumloop.com/integrations/slack) can connect workflows with Slack. + +Gumloop's [public documentation](https://docs.gumloop.com) does not itemize its Notion and Airtable actions with the same detail as several competitors. Buyers may need to test which records can be read, which fields can be updated, and whether a required event uses webhooks or polling. [MCP integrations](https://docs.gumloop.com/integrations/mcp) can cover some native-catalog gaps, but teams should test every required action before adoption. + +### Pros + +- [Gumloop's no-code canvas](https://docs.gumloop.com) makes workflow setup accessible without programming. +- [AI-assisted trigger creation](https://docs.gumloop.com/core-concepts/triggers) can connect external apps. +- [Documented MCP support](https://docs.gumloop.com/integrations/mcp) expands access to external tools and data. +- [Workflow templates](https://www.gumloop.com/templates) cover common business use cases. + +### Cons + +- [Public documentation](https://docs.gumloop.com) does not provide a single fixed, itemized integration catalog. +- The same [documentation](https://docs.gumloop.com) makes Notion and Airtable read, write, and trigger depth difficult to verify before testing. +- [Polling-based triggers](https://docs.gumloop.com/core-concepts/triggers) can introduce delays compared with real-time webhooks. +- [Gumloop's published product and pricing materials](https://gumloop.com/pricing) position it as a managed service rather than documenting an open-source, self-hostable runtime. + +### Pricing + +As of August 2026, [Gumloop's pricing page](https://gumloop.com/pricing) uses credits and lists self-service and Enterprise options. Credit consumption varies by operation, so confirm current allowances and overage terms against the workflows you intend to run. + +## Workato + +### Best for + +**Best for:** Enterprise IT departments that need administrators to govern credentials, permissions, and multi-system automations across a broad connector catalog. + +Workato's [integrations catalog](https://www.workato.com/integrations) covers a broad range of enterprise and business systems. The platform emphasizes managed enterprise integration, centralized administration, and governed automation. + +Slack setup can require more administration than one-click OAuth flows. Workato's [Slack trigger documentation](https://docs.workato.com/connectors/slack/triggers.html) describes creating and configuring a custom Slack app for event triggers. [Workbot for Slack](https://docs.workato.com/workbot-for-slack.html) can then place workflow interactions inside Slack. + +### Pros + +- Workato's [connector catalog](https://www.workato.com/integrations) and [workspace administration](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html) suit complex enterprise environments. +- [Workbot](https://docs.workato.com/workbot-for-slack.html) lets employees interact with cross-application workflows from Slack. +- [Workspace roles and privileges](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html) support controlled administration. + +### Cons + +- [Custom Slack app registration and event configuration](https://docs.workato.com/connectors/slack/triggers.html) increase setup work for administrators. +- Because Workato's [public connector catalog](https://www.workato.com/integrations) does not expose a dedicated Notion connector page, buyers should verify current capabilities directly. +- [Quote-based pricing](https://www.workato.com/pricing) and enterprise implementation make Workato heavier than self-service platforms for smaller teams. + +### Pricing + +Workato directs buyers to [request pricing](https://www.workato.com/pricing) rather than publishing standard plan prices. Ask Workato to confirm current usage limits, connector availability, and implementation requirements. + +## Slack, Notion, and Airtable integration depth compared + +Vendor documentation checked in August 2026 supports the comparison below. **R** means read access, **W** means write access, and **T** means trigger support. βœ… means strong documented support, 🟑 means partial, narrower, or insufficiently itemized support, and ❌ means no meaningful documented option. + +| Platform | Slack R/W/T | Notion R/W/T | Airtable R/W/T | Custom API fallback | +| --- | --- | --- | --- | --- | +| [Sim](https://www.sim.ai/integrations/slack) | βœ… R/W, real-time T | βœ… R/W, real-time T | βœ… R/W, real-time T | 🟑 General API, webhook, and MCP blocks | +| [Zapier](https://zapier.com/apps/slack/integrations) | βœ… R/W, instant T for supported events | βœ… R/W, instant T for supported events | βœ… R/W, 🟑 polling T | βœ… API Request | +| [Make](https://www.make.com/en/integrations/slack) | βœ… R/W, instant and polling T | 🟑 Connector depth varies | βœ… R/W, 🟑 verify trigger timing | βœ… Make an API Call | +| [n8n](https://n8n.io/integrations/) | 🟑 Verify node operations | βœ… R/W, 🟑 verify triggers | 🟑 Verify node operations | βœ… HTTP Request node | +| [Gumloop](https://docs.gumloop.com) | 🟑 Public action list limited | 🟑 Public action list limited | 🟑 Public action list limited | 🟑 MCP available | +| [Workato](https://docs.workato.com/connectors/slack/triggers.html) | 🟑 Event T with custom app setup | 🟑 Verify directly | 🟑 Verify directly | 🟑 Verify directly | + +β€œInsufficiently itemized” does not mean absent. [Gumloop](https://docs.gumloop.com) and [Workato](https://www.workato.com/integrations) may support additional actions that their public pages do not list in one place. + +## Which platform fits your integration needs + +No platform fits every integration requirement, so choose according to the tools, actions, trigger latency, and deployment controls your workflows need. + +- **Maximum catalog breadth:** Choose [Zapier](https://zapier.com/apps) when broad app coverage matters most. Choose [Make](https://www.make.com/en/integrations) when you also want a visual canvas with detailed branching. +- **Self-hosted deterministic automation:** Choose [n8n](https://docs.n8n.io/hosting/) when technical users want to manage infrastructure, add code, and use HTTP requests when native nodes fall short. +- **Managed visual automation:** Choose [Gumloop](https://docs.gumloop.com) when non-technical operators value guided setup and AI-assisted workflow building more than publicly itemized connector depth. +- **Enterprise governance:** Choose [Workato](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html) when IT needs centralized administration, access controls, and governed automation across complex business systems. +- **AI reasoning with write-back:** Choose [Sim](https://sim.ai) when an agent must reason over business data, decide what action to take, and write results into connected tools. + +Before committing, verify that the platform supports the exact read actions, write actions, and trigger types your workflow requires. A large catalog does not guarantee deep access to every app. + +## Why Sim is worth evaluating alongside the bigger catalogs + +Sim is a strong choice for teams that need AI reasoning, write-back actions, real-time triggers, and infrastructure ownership in one platform. An agent can evaluate context, follow conditions, request human approval, and write the result back into a connected business tool. That structure suits workflows where AI must decide what action to take rather than simply transfer data. + +Sim also gives buyers more deployment control than the managed platforms in this guide. Its Apache 2.0 core supports self-hosting, while custom API calls and MCP connections provide fallback options when a native integration lacks the required action. + +[Zapier](https://zapier.com/apps) and [Make](https://www.make.com/en/integrations) offer broad connector catalogs, so either may require less setup for long-tail SaaS tools. [Workato](https://docs.workato.com/user-accounts-and-teams/workspace-roles.html) also documents enterprise governance controls. Sim remains a practical option when priorities include agent reasoning, write-back, model choice, and control over hosting. + +[Build your first agent with Sim](https://sim.ai). + +## How we evaluated these platforms + +**Author and methodology:** Andrew Caslow at Sim evaluated these platforms using their live integration directories and technical documentation rather than marketing summaries. For Slack, Notion, and Airtable, the review checked whether connectors could read and write data. It also recorded trigger type, custom API fallback options, catalog depth, licensing, and self-hosting support. When public documentation lacked enough detail, the capability was marked as unverified rather than assumed absent. + +These details were verified in August 2026. Vendors frequently change connector catalogs, supported actions, trigger behavior, and pricing, so buyers should confirm each platform's current documentation before making a decision. diff --git a/apps/sim/public/library/best-ai-agent-platforms-for-connecting-your-existing-tools/cover.jpg b/apps/sim/public/library/best-ai-agent-platforms-for-connecting-your-existing-tools/cover.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6202d2549782ac88ec71d13ec819c322223be86d GIT binary patch literal 26210 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 Date: Fri, 21 Aug 2026 12:52:49 -0700 Subject: [PATCH 03/63] fix(billing): separate Enterprise reporting periods from Stripe terms (#6942) * fix(billing): separate Enterprise reporting periods from Stripe terms * fix(billing): reconcile accepted legacy intents * fix(billing): keep accepted legacy intents fail-closed * fix(billing): reconcile accepted retired intents * fix(billing): retire invalid legacy intents --- .../preview/route.ts | 21 +- .../route.ts | 23 +- .../lib/admin/dashboard-organizations.test.ts | 76 ++++-- apps/sim/lib/admin/dashboard.ts | 77 +++--- .../lib/api/contracts/v1/admin/dashboard.ts | 25 +- .../lib/billing/core/reporting-period.test.ts | 64 +++++ apps/sim/lib/billing/core/reporting-period.ts | 5 +- .../sim/lib/billing/enterprise-outbox.test.ts | 132 ++++++++++ apps/sim/lib/billing/enterprise-outbox.ts | 32 ++- .../billing/enterprise-provisioning.test.ts | 238 +++++++++++++----- .../lib/billing/enterprise-provisioning.ts | 173 +++---------- apps/sim/lib/billing/types/index.test.ts | 2 + apps/sim/lib/billing/types/index.ts | 1 + 13 files changed, 564 insertions(+), 305 deletions(-) rename apps/sim/app/api/v1/admin/dashboard/organizations/[id]/{billing-terms => reporting-period}/preview/route.ts (51%) rename apps/sim/app/api/v1/admin/dashboard/organizations/[id]/{billing-terms => reporting-period}/route.ts (57%) diff --git a/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/preview/route.ts b/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/preview/route.ts similarity index 51% rename from apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/preview/route.ts rename to apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/preview/route.ts index fd5c3d494c4..8ca902fade3 100644 --- a/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/preview/route.ts +++ b/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/preview/route.ts @@ -1,6 +1,6 @@ import { getErrorMessage } from '@sim/utils/errors' -import { previewDashboardEnterpriseBillingTerms } from '@/lib/admin/dashboard' -import { adminDashboardPreviewBillingTermsContract } from '@/lib/api/contracts/v1/admin/dashboard' +import { previewDashboardEnterpriseReportingPeriod } from '@/lib/admin/dashboard' +import { adminDashboardPreviewReportingPeriodContract } from '@/lib/api/contracts/v1/admin/dashboard' import { parseRequest } from '@/lib/api/server' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { withAdminAuthParams } from '@/app/api/v1/admin/middleware' @@ -13,18 +13,23 @@ import { export const POST = withRouteHandler( withAdminAuthParams<{ id: string }>(async (request, context) => { - const parsed = await parseRequest(adminDashboardPreviewBillingTermsContract, request, context, { - validationErrorResponse: adminValidationErrorResponse, - invalidJsonResponse: adminInvalidJsonResponse, - }) + const parsed = await parseRequest( + adminDashboardPreviewReportingPeriodContract, + request, + context, + { + validationErrorResponse: adminValidationErrorResponse, + invalidJsonResponse: adminInvalidJsonResponse, + } + ) if (!parsed.success) return parsed.response try { return singleResponse( - await previewDashboardEnterpriseBillingTerms(parsed.data.params.id, parsed.data.body) + await previewDashboardEnterpriseReportingPeriod(parsed.data.params.id, parsed.data.body) ) } catch (error) { return badRequestResponse( - getErrorMessage(error, 'Failed to preview Enterprise billing terms') + getErrorMessage(error, 'Failed to preview Enterprise reporting period') ) } }) diff --git a/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/route.ts b/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/route.ts similarity index 57% rename from apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/route.ts rename to apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/route.ts index e9afd5d98ea..78c2057b99a 100644 --- a/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/billing-terms/route.ts +++ b/apps/sim/app/api/v1/admin/dashboard/organizations/[id]/reporting-period/route.ts @@ -1,6 +1,6 @@ import { getErrorMessage } from '@sim/utils/errors' -import { updateDashboardEnterpriseBillingTerms } from '@/lib/admin/dashboard' -import { adminDashboardUpdateBillingTermsContract } from '@/lib/api/contracts/v1/admin/dashboard' +import { updateDashboardEnterpriseReportingPeriod } from '@/lib/admin/dashboard' +import { adminDashboardUpdateReportingPeriodContract } from '@/lib/api/contracts/v1/admin/dashboard' import { parseRequest } from '@/lib/api/server' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { getAdminAuditActor } from '@/app/api/v1/admin/dashboard/actor' @@ -14,20 +14,27 @@ import { export const PATCH = withRouteHandler( withAdminAuthParams<{ id: string }>(async (request, context) => { - const parsed = await parseRequest(adminDashboardUpdateBillingTermsContract, request, context, { - validationErrorResponse: adminValidationErrorResponse, - invalidJsonResponse: adminInvalidJsonResponse, - }) + const parsed = await parseRequest( + adminDashboardUpdateReportingPeriodContract, + request, + context, + { + validationErrorResponse: adminValidationErrorResponse, + invalidJsonResponse: adminInvalidJsonResponse, + } + ) if (!parsed.success) return parsed.response try { - await updateDashboardEnterpriseBillingTerms( + await updateDashboardEnterpriseReportingPeriod( parsed.data.params.id, parsed.data.body, await getAdminAuditActor(request) ) return singleResponse({ success: true as const }) } catch (error) { - return badRequestResponse(getErrorMessage(error, 'Failed to update Enterprise billing terms')) + return badRequestResponse( + getErrorMessage(error, 'Failed to update Enterprise reporting period') + ) } }) ) diff --git a/apps/sim/lib/admin/dashboard-organizations.test.ts b/apps/sim/lib/admin/dashboard-organizations.test.ts index 2c8e25cb7dc..49de9707c93 100644 --- a/apps/sim/lib/admin/dashboard-organizations.test.ts +++ b/apps/sim/lib/admin/dashboard-organizations.test.ts @@ -79,7 +79,7 @@ import { getDashboardOrganization, listDashboardOrganizations, toDashboardConfigurationUpdate, - updateDashboardEnterpriseBillingTerms, + updateDashboardEnterpriseReportingPeriod, updateDashboardEnterpriseSeats, updateDashboardOrganizationLimits, } from '@/lib/admin/dashboard' @@ -189,6 +189,7 @@ describe('toDashboardConfigurationUpdate', () => { concurrencyLimit: 50, }, requestedTerms: null, + providerAccepted: false, error: null, }, }) @@ -196,15 +197,43 @@ describe('toDashboardConfigurationUpdate', () => { id: 'config-2', status: 'pending', requestedUsageLimitDollars: 50_000, - requestedInvoiceAmountUsd: null, - requestedBillingInterval: null, + requestedReportingPeriodInterval: null, requestedReportingPeriodAnchorDate: null, requestedSeats: 20, requestedConcurrencyLimit: 50, requestedWorkflowExecutionTimeoutSeconds: null, + providerAccepted: false, + retryable: true, error: null, }) }) + + it('surfaces a legacy coupled cadence as reporting-only and disables retry', () => { + expect( + toDashboardConfigurationUpdate({ + latestRevision: 3, + desiredMetadata: {}, + desiredTerms: null, + hasUnappliedIntent: true, + effectiveSeatCapacity: 20, + configurationUpdate: { + id: 'legacy-config', + status: 'failed', + requestedMetadata: { + reportingPeriodAnchorDate: '2026-05-01', + seats: 20, + }, + requestedTerms: { invoiceAmountCents: 50_000, billingInterval: 'year' }, + providerAccepted: false, + error: 'Commercial-term updates are unsupported', + }, + }) + ).toMatchObject({ + requestedReportingPeriodAnchorDate: '2026-05-01', + requestedReportingPeriodInterval: 'year', + retryable: false, + }) + }) }) describe('listDashboardOrganizations', () => { @@ -458,7 +487,7 @@ describe('updateDashboardOrganizationLimits', () => { }) }) -describe('updateDashboardEnterpriseBillingTerms', () => { +describe('updateDashboardEnterpriseReportingPeriod', () => { beforeEach(() => { vi.clearAllMocks() resetDbChainMock() @@ -477,7 +506,7 @@ describe('updateDashboardEnterpriseBillingTerms', () => { }) }) - it('queues a cadence and immutable Price change through the existing Stripe intent', async () => { + it('queues only independent reporting metadata and preserves commercial metadata', async () => { queueTableRows(subscription, [ { id: 'sub-1', @@ -485,15 +514,19 @@ describe('updateDashboardEnterpriseBillingTerms', () => { plan: 'enterprise', status: 'active', billingInterval: 'month', - metadata: { plan: 'enterprise', referenceId: 'org-1', monthlyPrice: 125, seats: 10 }, + metadata: { + plan: 'enterprise', + referenceId: 'org-1', + monthlyPrice: 125, + seats: 10, + }, }, ]) - await updateDashboardEnterpriseBillingTerms( + await updateDashboardEnterpriseReportingPeriod( 'org-1', { - invoiceAmountUsd: 1200, - billingInterval: 'year', + reportingPeriodInterval: 'year', reportingPeriodAnchorDate: '2026-01-31', }, { id: 'admin-1', name: 'Admin', email: 'admin@sim.ai' } @@ -504,19 +537,17 @@ describe('updateDashboardEnterpriseBillingTerms', () => { 'stripe.sync-enterprise-metadata', expect.objectContaining({ revision: 4, - terms: { invoiceAmountCents: 120_000, billingInterval: 'year' }, metadata: expect.objectContaining({ - invoiceAmountCents: 120_000, + monthlyPrice: 125, reportingPeriodAnchorDate: '2026-01-31', + reportingPeriodInterval: 'year', }), }) ) - expect( - (mocks.enqueueOutboxEvent.mock.calls[0][2] as { metadata: Record }).metadata - ).toMatchObject({ monthlyPrice: null }) + expect(mocks.enqueueOutboxEvent.mock.calls[0][2]).not.toHaveProperty('terms') }) - it('updates only metadata when the applied Price already matches', async () => { + it('does not compare the requested reporting cadence with the Stripe cadence', async () => { queueTableRows(subscription, [ { id: 'sub-1', @@ -528,16 +559,25 @@ describe('updateDashboardEnterpriseBillingTerms', () => { }, ]) - await updateDashboardEnterpriseBillingTerms( + await updateDashboardEnterpriseReportingPeriod( 'org-1', { - invoiceAmountUsd: 1200, - billingInterval: 'year', + reportingPeriodInterval: 'month', reportingPeriodAnchorDate: '2025-01-31', }, { id: 'admin-1', name: 'Admin', email: 'admin@sim.ai' } ) expect(mocks.enqueueOutboxEvent.mock.calls[0][2]).not.toHaveProperty('terms') + expect(mocks.enqueueOutboxEvent.mock.calls[0][2]).toMatchObject({ + metadata: { + plan: 'enterprise', + referenceId: 'org-1', + seats: 10, + monthlyPrice: 125, + reportingPeriodAnchorDate: '2025-01-31', + reportingPeriodInterval: 'month', + }, + }) }) }) diff --git a/apps/sim/lib/admin/dashboard.ts b/apps/sim/lib/admin/dashboard.ts index cabb7f04687..144fe0def4d 100644 --- a/apps/sim/lib/admin/dashboard.ts +++ b/apps/sim/lib/admin/dashboard.ts @@ -110,7 +110,6 @@ async function enqueueEnterpriseMetadataIntent( subscriptionId: string appliedMetadata: unknown buildDesiredMetadata: (current: Record) => Record - terms?: { invoiceAmountCents: number; billingInterval: 'month' | 'year' } | null } ): Promise<{ version: number; desiredMetadata: Record }> { const intent = await resolveEnterpriseMetadataIntent( @@ -135,7 +134,6 @@ async function enqueueEnterpriseMetadataIntent( ...intent.desiredMetadata, } const desiredMetadata = params.buildDesiredMetadata(current) - const desiredTerms = params.terms === undefined ? intent.desiredTerms : params.terms const version = intent.latestRevision + 1 await enqueueOutboxEvent(tx, ENTERPRISE_METADATA_SYNC_EVENT_TYPE, { @@ -143,7 +141,6 @@ async function enqueueEnterpriseMetadataIntent( revision: version, deliveryRevision: 0, metadata: desiredMetadata, - ...(desiredTerms ? { terms: desiredTerms } : {}), }) return { version, desiredMetadata } } @@ -524,8 +521,12 @@ export function toDashboardConfigurationUpdate( usageLimitCredits === null ? null : creditsToDollars(usageLimitCredits) + prepaidBalanceDollars, - requestedInvoiceAmountUsd: terms ? terms.invoiceAmountCents / 100 : null, - requestedBillingInterval: terms?.billingInterval ?? null, + requestedReportingPeriodInterval: + metadata.reportingPeriodInterval === 'month' || metadata.reportingPeriodInterval === 'year' + ? metadata.reportingPeriodInterval + : typeof metadata.reportingPeriodAnchorDate === 'string' + ? (terms?.billingInterval ?? null) + : null, requestedReportingPeriodAnchorDate: typeof metadata.reportingPeriodAnchorDate === 'string' ? metadata.reportingPeriodAnchorDate @@ -535,6 +536,7 @@ export function toDashboardConfigurationUpdate( requestedWorkflowExecutionTimeoutSeconds: workflowExecutionTimeoutSeconds === null ? null : Math.round(workflowExecutionTimeoutSeconds), providerAccepted: update.providerAccepted, + retryable: terms === null, error: update.error, } } @@ -1147,36 +1149,27 @@ export async function updateDashboardEnterpriseSeats( }) } -interface DashboardEnterpriseBillingTerms { - invoiceAmountUsd: number - billingInterval: 'month' | 'year' +interface DashboardEnterpriseReportingPeriod { + reportingPeriodInterval: 'month' | 'year' reportingPeriodAnchorDate: string } -function validateDashboardEnterpriseBillingTerms(values: DashboardEnterpriseBillingTerms) { - const invoiceAmountCents = Math.round(values.invoiceAmountUsd * 100) - if ( - invoiceAmountCents <= 0 || - !Number.isSafeInteger(invoiceAmountCents) || - Math.abs(values.invoiceAmountUsd * 100 - invoiceAmountCents) > 1e-8 - ) { - throw new Error('Invoice amount must be at least $0.01 and use whole cents') - } +function validateDashboardEnterpriseReportingPeriod(values: DashboardEnterpriseReportingPeriod) { const reportingPeriod = resolveEnterpriseReportingPeriod( values.reportingPeriodAnchorDate, - values.billingInterval + values.reportingPeriodInterval ) if (!reportingPeriod) { - throw new Error('Contract start must be a valid UTC date that is not in the future') + throw new Error('Reporting-period anchor must be a valid UTC date that is not in the future') } - return { invoiceAmountCents, reportingPeriod } + return reportingPeriod } -export async function previewDashboardEnterpriseBillingTerms( +export async function previewDashboardEnterpriseReportingPeriod( organizationId: string, - values: DashboardEnterpriseBillingTerms + values: DashboardEnterpriseReportingPeriod ) { - const { reportingPeriod } = validateDashboardEnterpriseBillingTerms(values) + const reportingPeriod = validateDashboardEnterpriseReportingPeriod(values) const [[org], [subscriptionRow]] = await Promise.all([ db .select({ orgUsageLimit: organization.orgUsageLimit }) @@ -1221,12 +1214,12 @@ export async function previewDashboardEnterpriseBillingTerms( } } -export async function updateDashboardEnterpriseBillingTerms( +export async function updateDashboardEnterpriseReportingPeriod( organizationId: string, - values: DashboardEnterpriseBillingTerms, + values: DashboardEnterpriseReportingPeriod, actor: AdminMutationActor ) { - const { invoiceAmountCents } = validateDashboardEnterpriseBillingTerms(values) + validateDashboardEnterpriseReportingPeriod(values) await db.transaction(async (tx) => { await acquireOrganizationMutationLock(tx, organizationId) const [subscriptionRow] = await tx @@ -1244,29 +1237,14 @@ export async function updateDashboardEnterpriseBillingTerms( if (!subscriptionRow?.stripeSubscriptionId) { throw new Error('Active Stripe-backed Enterprise subscription not found') } - const appliedMetadata = metadataRecord(subscriptionRow.metadata) - const appliedInvoiceAmountCents = - metadataNumber(appliedMetadata, 'invoiceAmountCents') ?? - Math.round((metadataNumber(appliedMetadata, 'monthlyPrice') ?? 0) * 100) - const appliedBillingInterval = subscriptionRow.billingInterval === 'year' ? 'year' : 'month' - const termsChanged = - appliedInvoiceAmountCents !== invoiceAmountCents || - appliedBillingInterval !== values.billingInterval await enqueueEnterpriseMetadataIntent(tx, { subscriptionId: subscriptionRow.id, appliedMetadata: subscriptionRow.metadata, - terms: termsChanged ? { invoiceAmountCents, billingInterval: values.billingInterval } : null, - buildDesiredMetadata: (current) => { - const { monthlyPrice: _legacyMonthlyPrice, ...rest } = current - return { - ...rest, - // Stripe metadata updates merge by default. An empty value removes - // the legacy key after the neutral amount has been written. - monthlyPrice: null, - invoiceAmountCents, - reportingPeriodAnchorDate: values.reportingPeriodAnchorDate, - } - }, + buildDesiredMetadata: (current) => ({ + ...current, + reportingPeriodAnchorDate: values.reportingPeriodAnchorDate, + reportingPeriodInterval: values.reportingPeriodInterval, + }), }) }) recordAudit({ @@ -1276,7 +1254,7 @@ export async function updateDashboardEnterpriseBillingTerms( action: AuditAction.ORGANIZATION_UPDATED, resourceType: AuditResourceType.ORGANIZATION, resourceId: organizationId, - description: 'Admin requested Enterprise billing-term update', + description: 'Admin requested Enterprise reporting-period update', metadata: { ...values }, }) } @@ -1319,6 +1297,11 @@ export async function retryDashboardEnterpriseConfigurationUpdate( if (event.status !== 'dead_letter') { throw new Error('Only a failed Enterprise configuration update can be retried') } + if (payload.data.terms) { + throw new Error( + 'Legacy Enterprise commercial-term updates cannot be retried. Submit a new reporting-period change instead.' + ) + } await tx .update(outboxEvent) .set({ diff --git a/apps/sim/lib/api/contracts/v1/admin/dashboard.ts b/apps/sim/lib/api/contracts/v1/admin/dashboard.ts index 60d5cc63eec..9b6c2943ef4 100644 --- a/apps/sim/lib/api/contracts/v1/admin/dashboard.ts +++ b/apps/sim/lib/api/contracts/v1/admin/dashboard.ts @@ -161,8 +161,7 @@ export const adminDashboardOrganizationDetailSchema = id: z.string(), status: z.enum(['pending', 'processing', 'failed']), requestedUsageLimitDollars: dollarAmountSchema.nullable(), - requestedInvoiceAmountUsd: z.number().positive().nullable(), - requestedBillingInterval: adminDashboardBillingIntervalSchema.nullable(), + requestedReportingPeriodInterval: adminDashboardBillingIntervalSchema.nullable(), requestedReportingPeriodAnchorDate: adminDashboardDateOnlySchema.nullable(), requestedSeats: z.number().int().positive().nullable(), requestedConcurrencyLimit: z @@ -178,6 +177,7 @@ export const adminDashboardOrganizationDetailSchema = .max(MAX_WORKFLOW_EXECUTION_TIMEOUT_SECONDS) .nullable(), providerAccepted: z.boolean(), + retryable: z.boolean(), error: z.string().nullable(), }) .nullable(), @@ -551,13 +551,12 @@ export const adminDashboardEnterpriseReviewSchema = z.object({ }), }) -export const adminDashboardBillingTermsBodySchema = z.object({ - invoiceAmountUsd: z.number().min(0.01).max(10_000_000).multipleOf(0.01), - billingInterval: adminDashboardBillingIntervalSchema, +export const adminDashboardReportingPeriodBodySchema = z.object({ + reportingPeriodInterval: adminDashboardBillingIntervalSchema, reportingPeriodAnchorDate: adminDashboardDateOnlySchema, }) -export const adminDashboardBillingTermsPreviewSchema = z.object({ +export const adminDashboardReportingPeriodPreviewSchema = z.object({ reportingPeriod: adminDashboardReportingPeriodSchema, usage: adminDashboardUsageSchema, exceedsLimit: z.boolean(), @@ -876,22 +875,22 @@ export const adminDashboardUpdateLimitsContract = defineRouteContract({ }, }) -export const adminDashboardPreviewBillingTermsContract = defineRouteContract({ +export const adminDashboardPreviewReportingPeriodContract = defineRouteContract({ method: 'POST', - path: '/api/v1/admin/dashboard/organizations/[id]/billing-terms/preview', + path: '/api/v1/admin/dashboard/organizations/[id]/reporting-period/preview', params: adminV1IdParamsSchema, - body: adminDashboardBillingTermsBodySchema, + body: adminDashboardReportingPeriodBodySchema, response: { mode: 'json', - schema: adminV1SingleResponseSchema(adminDashboardBillingTermsPreviewSchema), + schema: adminV1SingleResponseSchema(adminDashboardReportingPeriodPreviewSchema), }, }) -export const adminDashboardUpdateBillingTermsContract = defineRouteContract({ +export const adminDashboardUpdateReportingPeriodContract = defineRouteContract({ method: 'PATCH', - path: '/api/v1/admin/dashboard/organizations/[id]/billing-terms', + path: '/api/v1/admin/dashboard/organizations/[id]/reporting-period', params: adminV1IdParamsSchema, - body: adminDashboardBillingTermsBodySchema, + body: adminDashboardReportingPeriodBodySchema, response: { mode: 'json', schema: adminV1SingleResponseSchema(adminDashboardMutationResultSchema), diff --git a/apps/sim/lib/billing/core/reporting-period.test.ts b/apps/sim/lib/billing/core/reporting-period.test.ts index 5d82406bbae..8b3a8572845 100644 --- a/apps/sim/lib/billing/core/reporting-period.test.ts +++ b/apps/sim/lib/billing/core/reporting-period.test.ts @@ -61,6 +61,70 @@ describe('Enterprise reporting periods', () => { ).toMatchObject({ source: 'stripe' }) }) + it('uses the reporting metadata interval independently from the Stripe cadence', () => { + expect( + resolveSubscriptionUsagePeriod( + { + plan: 'enterprise', + billingInterval: 'month', + metadata: { + reportingPeriodAnchorDate: '2026-05-01', + reportingPeriodInterval: 'year', + }, + periodStart: new Date('2026-07-21T19:37:47.000Z'), + periodEnd: new Date('2026-08-21T19:37:47.000Z'), + }, + new Date('2026-08-21T18:00:00.000Z') + ) + ).toMatchObject({ + source: 'reporting', + anchorDate: '2026-05-01', + interval: 'year', + start: new Date('2026-05-01T00:00:00.000Z'), + end: new Date('2027-05-01T00:00:00.000Z'), + }) + }) + + it('ignores custom reporting metadata for standard plans', () => { + expect( + resolveSubscriptionUsagePeriod( + { + plan: 'team_25000', + billingInterval: 'month', + metadata: { + reportingPeriodAnchorDate: '2026-05-01', + reportingPeriodInterval: 'year', + }, + periodStart: new Date('2026-08-01T00:00:00.000Z'), + periodEnd: new Date('2026-09-01T00:00:00.000Z'), + }, + new Date('2026-08-21T18:00:00.000Z') + ) + ).toMatchObject({ + source: 'stripe', + interval: 'month', + start: new Date('2026-08-01T00:00:00.000Z'), + end: new Date('2026-09-01T00:00:00.000Z'), + }) + }) + + it('preserves custom reporting periods written before the interval metadata split', () => { + expect( + resolveSubscriptionUsagePeriod( + { + plan: 'enterprise', + billingInterval: 'year', + metadata: { reportingPeriodAnchorDate: '2026-05-01' }, + }, + new Date('2026-08-21T18:00:00.000Z') + ) + ).toMatchObject({ + source: 'reporting', + anchorDate: '2026-05-01', + interval: 'year', + }) + }) + it('uses the same open fallback window when a subscription has no usable dates', () => { expect( resolveSubscriptionUsagePeriodOrDefault({ plan: 'enterprise', metadata: {} }) diff --git a/apps/sim/lib/billing/core/reporting-period.ts b/apps/sim/lib/billing/core/reporting-period.ts index d7967324231..a9d37cb1866 100644 --- a/apps/sim/lib/billing/core/reporting-period.ts +++ b/apps/sim/lib/billing/core/reporting-period.ts @@ -3,6 +3,7 @@ import { defaultBillingPeriod } from '@/lib/billing/core/billing-period' import { isEnterprise } from '@/lib/billing/plan-helpers' export const ENTERPRISE_REPORTING_PERIOD_ANCHOR_METADATA_KEY = 'reportingPeriodAnchorDate' +export const ENTERPRISE_REPORTING_PERIOD_INTERVAL_METADATA_KEY = 'reportingPeriodInterval' export type BillingInterval = 'month' | 'year' export type UsagePeriodSource = 'reporting' | 'stripe' | 'default' @@ -92,7 +93,9 @@ export function resolveSubscriptionUsagePeriod( if (subscription && isEnterprise(subscription.plan)) { const metadata = isRecordLike(subscription.metadata) ? subscription.metadata : {} const anchor = metadata[ENTERPRISE_REPORTING_PERIOD_ANCHOR_METADATA_KEY] - const interval = parseBillingInterval(subscription.billingInterval) + const interval = + parseBillingInterval(metadata[ENTERPRISE_REPORTING_PERIOD_INTERVAL_METADATA_KEY]) ?? + parseBillingInterval(subscription.billingInterval) if (typeof anchor === 'string' && interval) { const reportingPeriod = resolveEnterpriseReportingPeriod(anchor, interval, now) if (reportingPeriod) return reportingPeriod diff --git a/apps/sim/lib/billing/enterprise-outbox.test.ts b/apps/sim/lib/billing/enterprise-outbox.test.ts index 2bc57064cfd..d118f30fb5e 100644 --- a/apps/sim/lib/billing/enterprise-outbox.test.ts +++ b/apps/sim/lib/billing/enterprise-outbox.test.ts @@ -302,6 +302,138 @@ describe('Enterprise metadata intent admission state', () => { }) }) + it('keeps a legacy commercial-term intent pending until Stripe state is checked', async () => { + const state = await resolveEnterpriseMetadataIntent( + executorReturning([ + { + id: 'config-2', + status: 'pending', + payload: { + subscriptionId: 'sub-local', + revision: 2, + metadata: { seats: 7 }, + terms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + }, + }, + ]), + 'sub-local', + { seats: '10', simConfigRevision: '1', simConfigOperationId: 'config-1' } + ) + + expect(state.hasUnappliedIntent).toBe(true) + expect(state.effectiveSeatCapacity).toBe(7) + expect(state.configurationUpdate).toMatchObject({ + id: 'config-2', + status: 'pending', + providerAccepted: false, + error: null, + }) + }) + + it('releases a legacy commercial-term intent after Stripe confirms it was not applied', async () => { + const state = await resolveEnterpriseMetadataIntent( + executorReturning([ + { + id: 'config-2', + status: 'pending', + payload: { + subscriptionId: 'sub-local', + revision: 2, + metadata: { + seats: 7, + reportingPeriodAnchorDate: '2026-05-01', + }, + terms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + commercialTermsRetiredAt: '2026-08-01T00:00:00.000Z', + }, + }, + ]), + 'sub-local', + { seats: '10', simConfigRevision: '1', simConfigOperationId: 'config-1' } + ) + + expect(state.hasUnappliedIntent).toBe(false) + expect(state.effectiveSeatCapacity).toBe(10) + expect(state.configurationUpdate).toEqual({ + id: 'config-2', + status: 'failed', + requestedMetadata: { + seats: 7, + reportingPeriodAnchorDate: '2026-05-01', + }, + requestedTerms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + providerAccepted: false, + error: + 'Enterprise commercial-term updates are no longer supported. Submit a reporting-period change instead.', + }) + }) + + it('keeps a Stripe-accepted legacy commercial-term intent fail-closed', async () => { + const state = await resolveEnterpriseMetadataIntent( + executorReturning([ + { + id: 'config-2', + status: 'dead_letter', + payload: { + subscriptionId: 'sub-local', + revision: 2, + metadata: { seats: 7 }, + terms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + acknowledgement: { + startedAt: '2026-08-01T00:00:00.000Z', + deadlineAt: '2026-08-01T00:30:00.000Z', + }, + }, + }, + ]), + 'sub-local', + { seats: '10', simConfigRevision: '1', simConfigOperationId: 'config-1' } + ) + + expect(state.hasUnappliedIntent).toBe(true) + expect(state.effectiveSeatCapacity).toBe(7) + expect(state.configurationUpdate).toMatchObject({ + id: 'config-2', + status: 'failed', + requestedTerms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + providerAccepted: true, + }) + }) + + it('does not release an accepted legacy intent even if a retirement marker is present', async () => { + const state = await resolveEnterpriseMetadataIntent( + executorReturning([ + { + id: 'config-2', + status: 'dead_letter', + payload: { + subscriptionId: 'sub-local', + revision: 2, + metadata: { seats: 7 }, + terms: { invoiceAmountCents: 500_00, billingInterval: 'year' }, + commercialTermsRetiredAt: '2026-08-01T00:00:00.000Z', + deliveryState: { + priorPause: null, + billingIntervalChanged: true, + providerAcceptedAt: '2026-08-01T00:00:00.000Z', + }, + }, + }, + ]), + 'sub-local', + { seats: '10', simConfigRevision: '1', simConfigOperationId: 'config-1' } + ) + + expect(state.hasUnappliedIntent).toBe(true) + expect(state.effectiveSeatCapacity).toBe(7) + expect(state.configurationUpdate).toMatchObject({ + id: 'config-2', + status: 'failed', + providerAccepted: true, + error: null, + }) + }) + it('keeps a Stripe-accepted dead letter fail-closed until reconciliation', async () => { const state = await resolveEnterpriseMetadataIntent( executorReturning([ diff --git a/apps/sim/lib/billing/enterprise-outbox.ts b/apps/sim/lib/billing/enterprise-outbox.ts index b348c8c729f..3eda75002d3 100644 --- a/apps/sim/lib/billing/enterprise-outbox.ts +++ b/apps/sim/lib/billing/enterprise-outbox.ts @@ -94,6 +94,7 @@ export const enterpriseMetadataSyncPayloadSchema = z.object({ billingInterval: z.enum(['month', 'year']), }) .optional(), + commercialTermsRetiredAt: z.string().datetime().optional(), stripeProgress: z.object({ priceId: z.string().min(1).optional() }).default({}), deliveryState: z .object({ @@ -118,6 +119,14 @@ export function enterpriseMetadataDeliveryIsVerified( return payload.deliveryState?.verifiedAt !== undefined } +export function enterpriseMetadataIntentProviderAccepted( + payload: EnterpriseMetadataSyncPayload +): boolean { + return ( + payload.deliveryState?.providerAcceptedAt !== undefined || payload.acknowledgement !== undefined + ) +} + function stripeMetadataValueMatches( metadata: Stripe.Metadata, key: string, @@ -274,7 +283,8 @@ export function enterpriseOperationMatchesStripeSubscription( stripeMetadataInteger(metadata, 'invoiceAmountCents') === request.invoiceAmountCents && stripeMetadataInteger(metadata, 'usageLimitCredits') === request.usageLimitCredits && (request.reportingPeriodAnchorDate === undefined || - metadata.reportingPeriodAnchorDate === request.reportingPeriodAnchorDate) && + (metadata.reportingPeriodAnchorDate === request.reportingPeriodAnchorDate && + metadata.reportingPeriodInterval === request.billingInterval)) && stripeMetadataInteger(metadata, 'seats') === request.seats && (request.concurrencyLimit === undefined || stripeMetadataInteger(metadata, 'concurrencyLimit') === request.concurrencyLimit) && @@ -422,11 +432,15 @@ export async function resolveEnterpriseMetadataIntent( const appliedOperationId = appliedMetadata.simConfigOperationId const operationApplied = appliedOperationId === latest.id - const providerAccepted = - parsed.data.deliveryState?.providerAcceptedAt !== undefined || - parsed.data.acknowledgement !== undefined + const providerAccepted = enterpriseMetadataIntentProviderAccepted(parsed.data) + const retiredCommercialTerms = + parsed.data.terms !== undefined && + parsed.data.commercialTermsRetiredAt !== undefined && + !providerAccepted const hasUnappliedIntent = - !operationApplied && (latest.status !== 'dead_letter' || providerAccepted) + !operationApplied && + !retiredCommercialTerms && + (latest.status !== 'dead_letter' || providerAccepted) const desiredMetadata = hasUnappliedIntent ? parsed.data.metadata : appliedMetadata const desiredSeats = positiveInteger(parsed.data.metadata.seats) const effectiveSeatCapacity = hasUnappliedIntent @@ -448,7 +462,7 @@ export async function resolveEnterpriseMetadataIntent( : { id: latest.id, status: - latest.status === 'dead_letter' + retiredCommercialTerms || latest.status === 'dead_letter' ? 'failed' : latest.status === 'processing' ? 'processing' @@ -456,7 +470,11 @@ export async function resolveEnterpriseMetadataIntent( requestedMetadata: parsed.data.metadata, requestedTerms: parsed.data.terms ?? null, providerAccepted, - error: latest.status === 'dead_letter' ? (latest.lastError ?? null) : null, + error: retiredCommercialTerms + ? 'Enterprise commercial-term updates are no longer supported. Submit a reporting-period change instead.' + : latest.status === 'dead_letter' + ? (latest.lastError ?? null) + : null, }, } } diff --git a/apps/sim/lib/billing/enterprise-provisioning.test.ts b/apps/sim/lib/billing/enterprise-provisioning.test.ts index 82c9f5b9305..a71b36f8bb5 100644 --- a/apps/sim/lib/billing/enterprise-provisioning.test.ts +++ b/apps/sim/lib/billing/enterprise-provisioning.test.ts @@ -1078,6 +1078,7 @@ describe('Enterprise issuance outbox handler', () => { metadata: expect.objectContaining({ invoiceAmountCents: '120000', reportingPeriodAnchorDate: '2026-08-01', + reportingPeriodInterval: 'year', }), }), expect.any(Object) @@ -1251,6 +1252,8 @@ describe('Enterprise metadata outbox handler', () => { seats: 15, usageLimitCredits: 35000, concurrencyLimit: 1250, + reportingPeriodAnchorDate: '2026-05-01', + reportingPeriodInterval: 'year', }, } queueTableRows(schemaMock.subscription, [ @@ -1259,7 +1262,15 @@ describe('Enterprise metadata outbox handler', () => { queueTableRows(schemaMock.subscription, [{ metadata: {} }]) queueTableRows(schemaMock.outboxEvent, [{ id: 'metadata-event-1', payload }]) queueTableRows(schemaMock.member, [{ value: 10 }]) - mocks.subscriptionsUpdate.mockResolvedValue({ id: 'sub_1' }) + mocks.subscriptionsRetrieve.mockResolvedValue({ + id: 'sub_1', + metadata: {}, + pause_collection: { behavior: 'keep_as_draft', resumes_at: null }, + }) + mocks.subscriptionsUpdate.mockResolvedValue({ + id: 'sub_1', + pause_collection: { behavior: 'keep_as_draft', resumes_at: null }, + }) const checkpointPayload = vi.fn() await expect( @@ -1289,17 +1300,21 @@ describe('Enterprise metadata outbox handler', () => { metadata: expect.objectContaining({ seats: '15', concurrencyLimit: '1250', + reportingPeriodAnchorDate: '2026-05-01', + reportingPeriodInterval: 'year', simConfigRevision: '4', simConfigOperationId: 'metadata-event-1', simConfigDeliveryRevision: '0', simConfigDeliveryAttempt: '0', }), - expand: ['latest_invoice'], }, { idempotencyKey: 'enterprise-config:local-sub-1:metadata-event-1:delivery:0:attempt:0', } ) + expect(mocks.pricesCreate).not.toHaveBeenCalled() + expect(mocks.invoicesUpdate).not.toHaveBeenCalled() + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') }) it('does not send a seat decrease below current pending reservations to Stripe', async () => { @@ -1351,7 +1366,12 @@ describe('Enterprise metadata outbox handler', () => { queueTableRows(schemaMock.subscription, [{ metadata: {} }]) queueTableRows(schemaMock.outboxEvent, [{ id: 'metadata-event-2', payload }]) queueTableRows(schemaMock.member, [{ value: 10 }]) - mocks.subscriptionsUpdate.mockResolvedValue({ id: 'sub_1' }) + mocks.subscriptionsRetrieve.mockResolvedValue({ + id: 'sub_1', + metadata: {}, + pause_collection: null, + }) + mocks.subscriptionsUpdate.mockResolvedValue({ id: 'sub_1', pause_collection: null }) await expect( syncEnterpriseMetadataInStripe(payload, { @@ -1430,33 +1450,79 @@ describe('Enterprise metadata outbox handler', () => { expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() }) - it('repairs a paused cadence-change invoice before waiting for the webhook', async () => { + it('retires an unapplied legacy commercial intent even when its seats are now too low', async () => { const payload = { subscriptionId: 'local-sub-1', revision: 7, - deliveryRevision: 1, - acknowledgement: { - startedAt: '2026-08-13T00:00:00.000Z', - deadlineAt: '2099-08-13T00:30:00.000Z', + deliveryRevision: 0, + metadata: { + plan: 'enterprise', + referenceId: 'org-1', + seats: 5, + invoiceAmountCents: 120000, + reportingPeriodAnchorDate: '2026-05-01', }, + terms: { invoiceAmountCents: 120000, billingInterval: 'year' as const }, + stripeProgress: {}, + } + queueTableRows(schemaMock.subscription, [ + { stripeSubscriptionId: 'sub_1', referenceId: 'org-1', metadata: {} }, + ]) + queueTableRows(schemaMock.subscription, [{ metadata: {} }]) + queueTableRows(schemaMock.outboxEvent, [{ id: 'legacy-terms-event', payload }]) + queueTableRows(schemaMock.member, [{ value: 10 }]) + mocks.subscriptionsRetrieve.mockResolvedValue({ + id: 'sub_1', + metadata: {}, + items: { data: [] }, + pause_collection: { behavior: 'keep_as_draft', resumes_at: null }, + }) + const checkpointPayload = vi.fn() + + await expect( + syncEnterpriseMetadataInStripe(payload, { + eventId: 'legacy-terms-event', + eventType: 'stripe.sync-enterprise-metadata', + attempts: 7, + checkpointPayload, + }) + ).resolves.toBeUndefined() + + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') + expect(checkpointPayload).toHaveBeenCalledWith({ + commercialTermsRetiredAt: expect.any(String), + }) + expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() + expect(mocks.pricesCreate).not.toHaveBeenCalled() + expect(mocks.invoicesUpdate).not.toHaveBeenCalled() + }) + + it('finishes verification when Stripe already contains an accepted legacy commercial intent', async () => { + const payload = { + subscriptionId: 'local-sub-1', + revision: 7, + deliveryRevision: 2, metadata: { plan: 'enterprise', referenceId: 'org-1', seats: 15, invoiceAmountCents: 120000, + reportingPeriodAnchorDate: '2026-05-01', }, terms: { invoiceAmountCents: 120000, billingInterval: 'year' as const }, - stripeProgress: { priceId: 'price_year' }, + commercialTermsRetiredAt: '2026-08-21T18:01:00.000Z', deliveryState: { priorPause: { behavior: 'keep_as_draft' as const, resumesAt: null }, billingIntervalChanged: true, + providerAcceptedAt: '2026-08-21T18:00:00.000Z', }, + stripeProgress: { priceId: 'price_year' }, } queueTableRows(schemaMock.subscription, [ { stripeSubscriptionId: 'sub_1', referenceId: 'org-1', metadata: {} }, ]) queueTableRows(schemaMock.subscription, [{ metadata: {} }]) - queueTableRows(schemaMock.outboxEvent, [{ id: 'metadata-event-recovery', payload }]) + queueTableRows(schemaMock.outboxEvent, [{ id: 'accepted-legacy-terms-event', payload }]) queueTableRows(schemaMock.member, [{ value: 10 }]) mocks.subscriptionsRetrieve.mockResolvedValue({ id: 'sub_1', @@ -1465,15 +1531,15 @@ describe('Enterprise metadata outbox handler', () => { referenceId: 'org-1', seats: '15', invoiceAmountCents: '120000', - simConfigOperationId: 'metadata-event-recovery', + reportingPeriodAnchorDate: '2026-05-01', + simConfigOperationId: 'accepted-legacy-terms-event', simConfigRevision: '7', - simConfigDeliveryRevision: '1', + simConfigDeliveryRevision: '2', }, - schedule: null, collection_method: 'send_invoice', days_until_due: 30, + schedule: null, pause_collection: { behavior: 'keep_as_draft', resumes_at: null }, - latest_invoice: { id: 'in_change', status: 'draft', auto_advance: true }, items: { data: [ { @@ -1491,25 +1557,86 @@ describe('Enterprise metadata outbox handler', () => { await expect( syncEnterpriseMetadataInStripe(payload, { - eventId: 'metadata-event-recovery', + eventId: 'accepted-legacy-terms-event', eventType: 'stripe.sync-enterprise-metadata', - attempts: 2, + attempts: 7, checkpointPayload, }) - ).resolves.toMatchObject({ outcome: 'deferred', consumeAttempt: false }) + ).resolves.toMatchObject({ + outcome: 'deferred', + consumeAttempt: false, + reason: 'Waiting for the verified Stripe webhook acknowledgement', + }) + expect(checkpointPayload).toHaveBeenNthCalledWith(1, { + deliveryState: expect.objectContaining({ + providerAcceptedAt: '2026-08-21T18:00:00.000Z', + verifiedAt: expect.any(String), + }), + }) + expect(checkpointPayload).toHaveBeenNthCalledWith(2, { + acknowledgement: expect.objectContaining({ + startedAt: expect.any(String), + deadlineAt: expect.any(String), + }), + }) expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() - expect(mocks.invoicesUpdate).toHaveBeenCalledWith( - 'in_change', - { auto_advance: false }, - { idempotencyKey: 'enterprise:metadata-event-recovery:initial-invoice-draft' } - ) - expect(checkpointPayload).toHaveBeenCalledWith({ - deliveryState: expect.objectContaining({ providerAcceptedAt: expect.any(String) }), + expect(mocks.pricesCreate).not.toHaveBeenCalled() + expect(mocks.invoicesUpdate).not.toHaveBeenCalled() + }) + + it('keeps an accepted legacy commercial intent fail-closed when Stripe no longer matches', async () => { + const payload = { + subscriptionId: 'local-sub-1', + revision: 7, + deliveryRevision: 2, + metadata: { + plan: 'enterprise', + referenceId: 'org-1', + seats: 15, + invoiceAmountCents: 120000, + reportingPeriodAnchorDate: '2026-05-01', + }, + terms: { invoiceAmountCents: 120000, billingInterval: 'year' as const }, + commercialTermsRetiredAt: '2026-08-21T18:01:00.000Z', + deliveryState: { + priorPause: { behavior: 'keep_as_draft' as const, resumesAt: null }, + billingIntervalChanged: true, + providerAcceptedAt: '2026-08-21T18:00:00.000Z', + }, + stripeProgress: { priceId: 'price_year' }, + } + queueTableRows(schemaMock.subscription, [ + { stripeSubscriptionId: 'sub_1', referenceId: 'org-1', metadata: {} }, + ]) + queueTableRows(schemaMock.subscription, [{ metadata: {} }]) + queueTableRows(schemaMock.outboxEvent, [{ id: 'accepted-legacy-terms-event', payload }]) + queueTableRows(schemaMock.member, [{ value: 10 }]) + mocks.subscriptionsRetrieve.mockResolvedValue({ + id: 'sub_1', + metadata: {}, + items: { data: [] }, + pause_collection: { behavior: 'keep_as_draft', resumes_at: null }, }) - expect(checkpointPayload).toHaveBeenCalledWith({ - deliveryState: expect.objectContaining({ verifiedAt: expect.any(String) }), + const checkpointPayload = vi.fn() + + await expect( + syncEnterpriseMetadataInStripe(payload, { + eventId: 'accepted-legacy-terms-event', + eventType: 'stripe.sync-enterprise-metadata', + attempts: 7, + checkpointPayload, + }) + ).rejects.toThrow( + 'Legacy Enterprise commercial terms were accepted by Stripe but no longer match; manual reconciliation is required' + ) + + expect(checkpointPayload).not.toHaveBeenCalledWith({ + commercialTermsRetiredAt: expect.any(String), }) + expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() + expect(mocks.pricesCreate).not.toHaveBeenCalled() + expect(mocks.invoicesUpdate).not.toHaveBeenCalled() }) it('consumes the finite missing-ack budget only after the durable grace deadline', async () => { @@ -1551,7 +1678,7 @@ describe('Enterprise metadata outbox handler', () => { }) }) - it('replaces the single Enterprise Price in place without proration', async () => { + it('does not replace a Stripe Price for a legacy interval-change intent', async () => { const payload = { subscriptionId: 'local-sub-1', revision: 6, @@ -1606,27 +1733,17 @@ describe('Enterprise metadata outbox handler', () => { attempts: 0, checkpointPayload, }) - ).resolves.toMatchObject({ outcome: 'deferred' }) + ).resolves.toBeUndefined() - expect(mocks.subscriptionsUpdate).toHaveBeenCalledWith( - 'sub_1', - expect.objectContaining({ - items: [{ id: 'si_1', price: 'price_year', quantity: 1 }], - proration_behavior: 'none', - billing_cycle_anchor: 'now', - metadata: expect.objectContaining({ - invoiceAmountCents: '120000', - reportingPeriodAnchorDate: '2026-01-31', - }), - }), - expect.any(Object) - ) + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') + expect(mocks.pricesCreate).not.toHaveBeenCalled() + expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() expect(checkpointPayload).toHaveBeenCalledWith({ - stripeProgress: { priceId: 'price_year' }, + commercialTermsRetiredAt: expect.any(String), }) }) - it('preserves paused collection and freezes the cadence-change invoice as a draft', async () => { + it('does not touch a paused subscription for a legacy commercial intent', async () => { const payload = { subscriptionId: 'local-sub-1', revision: 7, @@ -1677,22 +1794,21 @@ describe('Enterprise metadata outbox handler', () => { latest_invoice: { id: 'in_change', status: 'draft', auto_advance: true }, }) - await syncEnterpriseMetadataInStripe(payload, { - eventId: 'metadata-event-paused', - eventType: 'stripe.sync-enterprise-metadata', - attempts: 0, - checkpointPayload: vi.fn(), - }) + await expect( + syncEnterpriseMetadataInStripe(payload, { + eventId: 'metadata-event-paused', + eventType: 'stripe.sync-enterprise-metadata', + attempts: 0, + checkpointPayload: vi.fn(), + }) + ).resolves.toBeUndefined() - expect(mocks.invoicesUpdate).toHaveBeenCalledWith( - 'in_change', - { auto_advance: false }, - { idempotencyKey: 'enterprise:metadata-event-paused:initial-invoice-draft' } - ) - expect(mocks.subscriptionsUpdate.mock.calls[0][1]).not.toHaveProperty('pause_collection') + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') + expect(mocks.invoicesUpdate).not.toHaveBeenCalled() + expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() }) - it('does not treat an old paid invoice as a failed paused amount-only update', async () => { + it('does not inspect invoices for a legacy amount-change intent', async () => { const payload = { subscriptionId: 'local-sub-1', revision: 8, @@ -1751,13 +1867,14 @@ describe('Enterprise metadata outbox handler', () => { attempts: 0, checkpointPayload: vi.fn(), }) - ).resolves.toMatchObject({ outcome: 'deferred' }) + ).resolves.toBeUndefined() + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') expect(mocks.invoicesUpdate).not.toHaveBeenCalled() - expect(mocks.subscriptionsUpdate.mock.calls[0][1]).not.toHaveProperty('billing_cycle_anchor') + expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() }) - it('rejects billing-term changes controlled by a Stripe Schedule', async () => { + it('retires a legacy billing-term intent without touching its Stripe Schedule', async () => { const payload = { subscriptionId: 'local-sub-1', revision: 6, @@ -1788,7 +1905,8 @@ describe('Enterprise metadata outbox handler', () => { attempts: 0, checkpointPayload: vi.fn(), }) - ).rejects.toThrow('Stripe Schedule') + ).resolves.toBeUndefined() + expect(mocks.subscriptionsRetrieve).toHaveBeenCalledWith('sub_1') expect(mocks.subscriptionsUpdate).not.toHaveBeenCalled() }) diff --git a/apps/sim/lib/billing/enterprise-provisioning.ts b/apps/sim/lib/billing/enterprise-provisioning.ts index c096c92f92d..b0eb8d078f6 100644 --- a/apps/sim/lib/billing/enterprise-provisioning.ts +++ b/apps/sim/lib/billing/enterprise-provisioning.ts @@ -57,6 +57,7 @@ import { enterpriseInvitePeoplePayloadSchema, enterpriseMemberReconciliationPayloadSchema, enterpriseMetadataIntentMatchesStripeSubscription, + enterpriseMetadataIntentProviderAccepted, enterpriseMetadataSyncPayloadSchema, enterpriseProvisionPayloadSchema, enterpriseWorkspaceMovePayloadSchema, @@ -302,33 +303,6 @@ async function findOperationPrice( return match } -async function findConfigurationPrice( - stripe: Stripe, - productId: string, - operationId: string -): Promise { - let match: Stripe.Price | null = null - let startingAfter: string | undefined - for (;;) { - const page = await stripe.prices.list({ - product: productId, - limit: 100, - ...(startingAfter ? { starting_after: startingAfter } : {}), - }) - for (const candidate of page.data) { - if (candidate.metadata?.enterpriseConfigOperationId !== operationId) continue - if (match && match.id !== candidate.id) { - throw new Error('Multiple Stripe prices exist for this Enterprise configuration update') - } - match = candidate - } - if (!page.has_more) break - startingAfter = page.data.at(-1)?.id - if (!startingAfter) break - } - return match -} - function isStripeMissingResource(error: unknown): boolean { return Boolean( error && @@ -374,25 +348,6 @@ function assertEnterprisePrice( } } -function assertEnterpriseConfigurationPrice( - price: Stripe.Price, - terms: { invoiceAmountCents: number; billingInterval: 'month' | 'year' }, - operationId: string, - expectedProductId: string -): void { - const productId = typeof price.product === 'string' ? price.product : price.product?.id - if ( - price.currency !== 'usd' || - price.unit_amount !== terms.invoiceAmountCents || - price.recurring?.interval !== terms.billingInterval || - (price.recurring.interval_count ?? 1) !== 1 || - price.metadata?.enterpriseConfigOperationId !== operationId || - productId !== expectedProductId - ) { - throw new Error('Recovered Stripe price does not match the Enterprise billing-term update') - } -} - export interface IssueEnterpriseProvisioningInput { ownerUserId: string organizationName?: string @@ -2319,9 +2274,7 @@ function stripePauseMatchesDeliveryState( } async function verifyEnterpriseMetadataDelivery(params: { - stripe: Stripe subscription: Stripe.Subscription - operationId: string deliveryState: EnterpriseMetadataDeliveryState context: OutboxEventContext }): Promise { @@ -2337,17 +2290,6 @@ async function verifyEnterpriseMetadataDelivery(params: { throw new Error('Stripe did not preserve Enterprise payment-collection pause settings') } - if ( - acceptedState.billingIntervalChanged && - acceptedState.priorPause?.behavior === 'keep_as_draft' - ) { - await keepInitialEnterpriseInvoiceAsDraft({ - stripe: params.stripe, - subscription: params.subscription, - operationId: params.operationId, - }) - } - if (!acceptedState.verifiedAt) { await params.context.checkpointPayload({ deliveryState: { ...acceptedState, verifiedAt: new Date().toISOString() }, @@ -2424,7 +2366,10 @@ export const provisionEnterpriseInStripe: OutboxHandler = async (rawPay enterpriseOperationId: context.eventId, invoiceAmountCents: request.invoiceAmountCents.toString(), ...(request.reportingPeriodAnchorDate - ? { reportingPeriodAnchorDate: request.reportingPeriodAnchorDate } + ? { + reportingPeriodAnchorDate: request.reportingPeriodAnchorDate, + reportingPeriodInterval: request.billingInterval, + } : {}), usageLimitCredits: request.usageLimitCredits.toString(), seats: request.seats.toString(), @@ -2659,20 +2604,13 @@ export const syncEnterpriseMetadataInStripe: OutboxHandler = async ( const latestPayload = enterpriseMetadataSyncPayloadSchema.safeParse(latest.payload) if (!latestPayload.success) throw new Error('Latest Enterprise metadata intent is invalid') - const desiredSeats = Number(latestPayload.data.metadata.seats) - const currentSeatRequirement = await getEnterpriseIssuanceSeatRequirement({ - executor: db, - organizationId: subscriptionRow.referenceId, - workspaceIds: [], - invitationEmails: [], - }) if ( - !Number.isSafeInteger(desiredSeats) || - desiredSeats < currentSeatRequirement.requiredSeats + latestPayload.data.terms && + latestPayload.data.commercialTermsRetiredAt && + !enterpriseMetadataIntentProviderAccepted(latestPayload.data) ) { - throw new Error('Enterprise seat intent is below current occupied or reserved seats') + return } - const metadata: Record = {} for (const [key, value] of Object.entries(latestPayload.data.metadata)) { if (value === null) metadata[key] = '' @@ -2684,10 +2622,7 @@ export const syncEnterpriseMetadataInStripe: OutboxHandler = async ( metadata.simConfigDeliveryAttempt = String(context.attempts) const stripe = requireStripeClient() - const terms = latestPayload.data.terms - const stripeSubscription = await stripe.subscriptions.retrieve(stripeSubscriptionId, { - expand: ['latest_invoice'], - }) + const stripeSubscription = await stripe.subscriptions.retrieve(stripeSubscriptionId) const deliveryAlreadyWritten = enterpriseMetadataIntentMatchesStripeSubscription( latestPayload.data, context.eventId, @@ -2699,77 +2634,39 @@ export const syncEnterpriseMetadataInStripe: OutboxHandler = async ( throw new Error('Enterprise configuration delivery state was not checkpointed') } await verifyEnterpriseMetadataDelivery({ - stripe, subscription: stripeSubscription, - operationId: context.eventId, deliveryState, context, }) return waitForEnterpriseWebhookAcknowledgement(latestPayload.data.acknowledgement, context) } - let priceId = latestPayload.data.stripeProgress.priceId ?? null - let updateItems: Stripe.SubscriptionUpdateParams.Item[] | undefined - let billingIntervalChanged = false - - if (terms) { - if (stripeSubscription.schedule) { - throw new Error( - 'Enterprise billing terms cannot be changed while a Stripe Schedule controls the subscription' - ) - } - if ( - stripeSubscription.collection_method !== 'send_invoice' || - stripeSubscription.days_until_due !== 30 - ) { - throw new Error( - 'Enterprise billing-term updates require send-invoice collection with 30-day terms' - ) - } - const items = stripeSubscription.items.data - if (items.length !== 1) { + if (latestPayload.data.terms) { + if (enterpriseMetadataIntentProviderAccepted(latestPayload.data)) { throw new Error( - 'Enterprise billing-term updates require exactly one Stripe subscription item' + 'Legacy Enterprise commercial terms were accepted by Stripe but no longer match; manual reconciliation is required' ) } - const currentItem = items[0] - billingIntervalChanged = currentItem.price.recurring?.interval !== terms.billingInterval - const productId = - typeof currentItem.price.product === 'string' - ? currentItem.price.product - : currentItem.price.product?.id - if (!productId) throw new Error('Enterprise subscription price has no reusable product') - - let price: Stripe.Price | null = null - if (priceId) { - price = await stripe.prices.retrieve(priceId) - } else { - price = await findConfigurationPrice(stripe, productId, context.eventId) - } - if (!price) { - price = await stripe.prices.create( - { - currency: 'usd', - unit_amount: terms.invoiceAmountCents, - recurring: { interval: terms.billingInterval }, - product: productId, - metadata: { enterpriseConfigOperationId: context.eventId }, - }, - { - idempotencyKey: `enterprise-config:${payload.subscriptionId}:${context.eventId}:price`, - } - ) - } - assertEnterpriseConfigurationPrice(price, terms, context.eventId, productId) - priceId = price.id - if (latestPayload.data.stripeProgress.priceId !== priceId) { - await context.checkpointPayload({ stripeProgress: { priceId } }) - } - updateItems = [{ id: currentItem.id, price: priceId, quantity: 1 }] + await context.checkpointPayload({ commercialTermsRetiredAt: new Date().toISOString() }) + return + } + + const desiredSeats = Number(latestPayload.data.metadata.seats) + const currentSeatRequirement = await getEnterpriseIssuanceSeatRequirement({ + executor: db, + organizationId: subscriptionRow.referenceId, + workspaceIds: [], + invitationEmails: [], + }) + if ( + !Number.isSafeInteger(desiredSeats) || + desiredSeats < currentSeatRequirement.requiredSeats + ) { + throw new Error('Enterprise seat intent is below current occupied or reserved seats') } const deliveryState: EnterpriseMetadataDeliveryState = { priorPause: stripePauseState(stripeSubscription.pause_collection), - billingIntervalChanged, + billingIntervalChanged: false, } await context.checkpointPayload({ deliveryState }) @@ -2777,23 +2674,13 @@ export const syncEnterpriseMetadataInStripe: OutboxHandler = async ( stripeSubscriptionId, { metadata, - ...(updateItems - ? { - items: updateItems, - proration_behavior: 'none' as const, - ...(billingIntervalChanged ? { billing_cycle_anchor: 'now' as const } : {}), - } - : {}), - expand: ['latest_invoice'], }, { idempotencyKey: `enterprise-config:${payload.subscriptionId}:${context.eventId}:delivery:${latestPayload.data.deliveryRevision}:attempt:${context.attempts}`, } ) await verifyEnterpriseMetadataDelivery({ - stripe, subscription: updatedSubscription, - operationId: context.eventId, deliveryState, context, }) diff --git a/apps/sim/lib/billing/types/index.test.ts b/apps/sim/lib/billing/types/index.test.ts index 3a79403c247..e43d98aaaed 100644 --- a/apps/sim/lib/billing/types/index.test.ts +++ b/apps/sim/lib/billing/types/index.test.ts @@ -81,11 +81,13 @@ describe('Enterprise subscription metadata', () => { invoiceAmountCents: '120000', seats: '25', reportingPeriodAnchorDate: '2026-01-31', + reportingPeriodInterval: 'year', }) ).toMatchObject({ invoiceAmountCents: 120000, invoiceAmountUsd: 1200, reportingPeriodAnchorDate: '2026-01-31', + reportingPeriodInterval: 'year', }) }) }) diff --git a/apps/sim/lib/billing/types/index.ts b/apps/sim/lib/billing/types/index.ts index b521eeb8003..3d59032ddd6 100644 --- a/apps/sim/lib/billing/types/index.ts +++ b/apps/sim/lib/billing/types/index.ts @@ -32,6 +32,7 @@ export const enterpriseSubscriptionMetadataSchema = z ) }, 'Reporting-period anchor must be a valid UTC date that is not in the future') .optional(), + reportingPeriodInterval: z.enum(['month', 'year']).optional(), concurrencyLimit: z.coerce .number() .int() From 58aa6379e037f946071915b825fc10acff7d67b7 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Date: Fri, 21 Aug 2026 12:59:08 -0700 Subject: [PATCH 04/63] feat(cli): add chat command (#6937) * feat(cli): add chat command * fix(cli): harden chat command execution --- apps/docs/content/docs/en/cli/commands.mdx | 26 ++ apps/docs/content/docs/en/cli/reference.mdx | 28 ++ apps/sim/app/api/v2/chat/route.test.ts | 307 ++++++++++++++ apps/sim/app/api/v2/chat/route.ts | 386 ++++++++++++++++++ apps/sim/lib/api/contracts/v2/chat.ts | 62 +++ .../sim/lib/copilot/application/operations.ts | 16 + bun.lock | 1 - .../src/commands/protocol/chat.test.ts | 165 ++++++++ .../sim-cli/src/commands/protocol/chat.ts | 179 ++++++++ .../sim-cli/src/commands/protocol/index.ts | 3 + packages/sim-cli/src/contract/commands.ts | 3 + packages/sim-cli/src/generated/v2-api.ts | 42 ++ scripts/check-api-validation-contracts.ts | 4 +- scripts/check-openapi-specs.ts | 2 + scripts/generate-cli-docs.ts | 1 + 15 files changed, 1222 insertions(+), 3 deletions(-) create mode 100644 apps/sim/app/api/v2/chat/route.test.ts create mode 100644 apps/sim/app/api/v2/chat/route.ts create mode 100644 apps/sim/lib/api/contracts/v2/chat.ts create mode 100644 apps/sim/lib/copilot/application/operations.ts create mode 100644 packages/sim-cli/src/commands/protocol/chat.test.ts create mode 100644 packages/sim-cli/src/commands/protocol/chat.ts diff --git a/apps/docs/content/docs/en/cli/commands.mdx b/apps/docs/content/docs/en/cli/commands.mdx index 67c44e3f197..8a1e209c3a1 100644 --- a/apps/docs/content/docs/en/cli/commands.mdx +++ b/apps/docs/content/docs/en/cli/commands.mdx @@ -113,3 +113,29 @@ sim configure [options] | `--unset ` | No | Remove settings (endpoint, workspace, output). | + +## Ask Sim and print the reply + +```bash +sim chat [options] +``` + +**Arguments** + + + +| Argument | Required | Description | +| --- | --- | --- | +| `message` | Yes | What to ask Sim | + + + +**Options** + + + +| Option | Required | Description | +| --- | --- | --- | +| `-c, --conversation ` | No | Continue the conversation with this ID. | + + diff --git a/apps/docs/content/docs/en/cli/reference.mdx b/apps/docs/content/docs/en/cli/reference.mdx index 4346ef28715..4447a60c831 100644 --- a/apps/docs/content/docs/en/cli/reference.mdx +++ b/apps/docs/content/docs/en/cli/reference.mdx @@ -101,6 +101,34 @@ sim configure [options] +## sim chat + +Ask Sim and print the reply + +```bash +sim chat [options] +``` + +**Arguments** + + + +| Argument | Required | Description | +| --- | --- | --- | +| `message` | Yes | What to ask Sim | + + + +**Options** + + + +| Option | Required | Description | +| --- | --- | --- | +| `-c, --conversation ` | No | Continue the conversation with this ID. | + + + ## sim profiles Also spelled `sim profile`. diff --git a/apps/sim/app/api/v2/chat/route.test.ts b/apps/sim/app/api/v2/chat/route.test.ts new file mode 100644 index 00000000000..5c7072319ac --- /dev/null +++ b/apps/sim/app/api/v2/chat/route.test.ts @@ -0,0 +1,307 @@ +/** + * @vitest-environment node + */ + +import { createMockRequest } from '@sim/testing' +import { beforeEach, describe, expect, it, vi } from 'vitest' + +const { + MockV2ApiKeyUnauthenticatedError, + MockWorkspaceAccessDeniedError, + billingAttributionSnapshot, + mockAssertActiveWorkspaceAccess, + mockAuthenticateV2ApiKey, + mockCheckOperationRate, + mockCheckPreAuthRate, + mockGenerateId, + mockRequestExplicitStreamAbort, + mockResolveBillingAttribution, + mockRunHeadlessCopilotLifecycle, +} = vi.hoisted(() => ({ + MockV2ApiKeyUnauthenticatedError: class MockV2ApiKeyUnauthenticatedError extends Error {}, + MockWorkspaceAccessDeniedError: class MockWorkspaceAccessDeniedError extends Error {}, + mockAssertActiveWorkspaceAccess: vi.fn(), + mockAuthenticateV2ApiKey: vi.fn(), + billingAttributionSnapshot: { + actorUserId: 'user-1', + workspaceId: 'workspace-1', + organizationId: null, + billedAccountUserId: 'user-1', + billingEntity: { type: 'user', id: 'user-1' }, + billingPeriod: { start: '2026-08-01T00:00:00.000Z', end: '2026-09-01T00:00:00.000Z' }, + payerSubscription: null, + }, + mockCheckOperationRate: vi.fn(), + mockCheckPreAuthRate: vi.fn(), + mockGenerateId: vi.fn(), + mockResolveBillingAttribution: vi.fn(), + mockRequestExplicitStreamAbort: vi.fn().mockResolvedValue(undefined), + mockRunHeadlessCopilotLifecycle: vi.fn(), +})) + +vi.mock('@/lib/api/server/routes/v2-api-key-auth', () => ({ + authenticateV2ApiKey: mockAuthenticateV2ApiKey, + V2ApiKeyUnauthenticatedError: MockV2ApiKeyUnauthenticatedError, +})) + +vi.mock('@/lib/core/rate-limiter', () => ({ + getRateLimit: () => ({ maxTokens: 100, refillRate: 50, refillIntervalMs: 60_000 }), + RateLimiter: class RateLimiter { + checkRateLimitDirect = mockCheckPreAuthRate + checkRateLimitDirectOrThrow = mockCheckOperationRate + }, +})) + +vi.mock('@/app/api/v2/lib/gate', () => ({ + v2ApiGateError: vi.fn().mockResolvedValue(null), +})) + +vi.mock('@sim/utils/id', () => ({ + generateId: mockGenerateId, + generateShortId: vi.fn(() => 'mock-short-id'), +})) + +vi.mock('@/lib/workspaces/permissions/utils', () => ({ + assertActiveWorkspaceAccess: mockAssertActiveWorkspaceAccess, + isWorkspaceAccessDeniedError: (error: unknown) => error instanceof MockWorkspaceAccessDeniedError, +})) + +vi.mock('@/lib/billing/core/billing-attribution', () => ({ + resolveBillingAttribution: mockResolveBillingAttribution, +})) + +vi.mock('@/lib/environment/utils', () => ({ + getPersonalAndWorkspaceEnv: vi.fn().mockResolvedValue({ personal: {}, workspace: {} }), +})) + +vi.mock('@/lib/copilot/environment-context', () => ({ + createCopilotEnvironmentContext: vi.fn().mockResolvedValue({ id: 'env-context' }), +})) + +vi.mock('@/lib/copilot/chat/workspace-context', () => ({ + generateWorkspaceContext: vi.fn().mockResolvedValue('workspace context'), +})) + +vi.mock('@/lib/copilot/chat/payload', () => ({ + buildIntegrationToolSchemas: vi.fn().mockResolvedValue([{ name: 'run_workflow' }]), +})) + +vi.mock('@/lib/copilot/entitlements', () => ({ + computeWorkspaceEntitlements: vi.fn().mockResolvedValue([]), +})) + +vi.mock('@/lib/copilot/request/lifecycle/headless', () => ({ + runHeadlessCopilotLifecycle: mockRunHeadlessCopilotLifecycle, +})) + +vi.mock('@/lib/copilot/request/session/explicit-abort', () => ({ + requestExplicitStreamAbort: mockRequestExplicitStreamAbort, +})) + +vi.mock('@/lib/copilot/secret-mount-policy', () => ({ + normalizeSecretMountPolicy: vi.fn(() => ({ secretScope: 'all', mountedSecrets: [] })), +})) + +vi.mock('@/lib/core/config/env-flags', () => ({ + isDocSandboxEnabled: false, +})) + +import { POST } from '@/app/api/v2/chat/route' + +const personalAuth = { + principal: { kind: 'personal_api_key', userId: 'user-1', keyId: 'key-1' }, + rolloutUserId: 'user-1', + rateLimitSubjectIds: ['api-key:key-1', 'user:user-1'], + rateLimitSubscription: null, + keyType: 'personal', +} + +const successResult = { + success: true, + content: 'Hello there', + toolCalls: [{ name: 'run_workflow' }, { name: 'internal_only' }], + usage: { prompt: 10, completion: 5 }, + cost: { total: 0.01 }, +} + +function callChat(body: Record, headers: Record = {}) { + const req = createMockRequest('POST', body, { 'X-API-Key': 'test-key', ...headers }) + return POST(req, { params: Promise.resolve({}) }) +} + +async function readNdjsonEvents(response: Response): Promise>> { + const raw = await response.text() + return raw + .split('\n') + .filter((line) => line.trim().length > 0) + .map((line) => JSON.parse(line)) +} + +describe('POST /api/v2/chat', () => { + beforeEach(() => { + vi.clearAllMocks() + let generated = 0 + mockGenerateId.mockImplementation(() => `generated-${++generated}`) + mockAuthenticateV2ApiKey.mockResolvedValue(personalAuth) + mockCheckPreAuthRate.mockResolvedValue({ allowed: true, remaining: 10, resetAt: new Date() }) + mockCheckOperationRate.mockResolvedValue({ allowed: true, remaining: 10, resetAt: new Date() }) + mockAssertActiveWorkspaceAccess.mockResolvedValue({ permission: 'admin' }) + mockResolveBillingAttribution.mockResolvedValue(billingAttributionSnapshot) + mockRequestExplicitStreamAbort.mockResolvedValue(undefined) + mockRunHeadlessCopilotLifecycle.mockResolvedValue(successResult) + }) + + it('rejects a missing or invalid API key', async () => { + mockAuthenticateV2ApiKey.mockRejectedValue( + new MockV2ApiKeyUnauthenticatedError('API key required') + ) + + const response = await callChat({ workspaceId: 'workspace-1', message: 'hi' }) + + expect(response.status).toBe(401) + }) + + it('rejects a workspace API key: chat has no acting user to attribute', async () => { + mockAuthenticateV2ApiKey.mockResolvedValue({ + ...personalAuth, + principal: { kind: 'workspace_api_key', workspaceId: 'workspace-1', keyId: 'key-2' }, + keyType: 'workspace', + }) + + const response = await callChat({ workspaceId: 'workspace-1', message: 'hi' }) + + expect(response.status).toBe(403) + const body = await response.json() + expect(body.error.details.code).toBe('PRINCIPAL_KIND_NOT_PERMITTED') + expect(mockRunHeadlessCopilotLifecycle).not.toHaveBeenCalled() + }) + + it('rejects an empty message before running anything', async () => { + const response = await callChat({ workspaceId: 'workspace-1', message: '' }) + + expect(response.status).toBe(400) + expect(mockRunHeadlessCopilotLifecycle).not.toHaveBeenCalled() + }) + + it('answers 403 when the caller cannot access the workspace', async () => { + mockAssertActiveWorkspaceAccess.mockRejectedValue(new MockWorkspaceAccessDeniedError('denied')) + + const response = await callChat({ workspaceId: 'workspace-1', message: 'hi' }) + + expect(response.status).toBe(403) + expect(mockRunHeadlessCopilotLifecycle).not.toHaveBeenCalled() + }) + + it('runs one turn and answers the reply with a generated conversation id', async () => { + const response = await callChat({ workspaceId: 'workspace-1', message: 'hi' }) + + expect(response.status).toBe(200) + const body = await response.json() + expect(body.data).toEqual({ + content: 'Hello there', + model: 'mothership', + conversationId: 'generated-1', + tokens: { prompt: 10, completion: 5, total: 15 }, + cost: { total: 0.01 }, + toolCalls: [{ name: 'run_workflow' }], + }) + + const [payload, options] = mockRunHeadlessCopilotLifecycle.mock.calls[0] + expect(payload).toMatchObject({ + messages: [{ role: 'user', content: 'hi' }], + userId: 'user-1', + workspaceId: 'workspace-1', + chatId: 'generated-1', + mode: 'agent', + isHosted: true, + workspaceContext: 'workspace context', + integrationTools: [{ name: 'run_workflow' }], + userPermission: 'admin', + }) + expect(options).toMatchObject({ + userId: 'user-1', + workspaceId: 'workspace-1', + chatId: 'generated-1', + goRoute: '/api/mothership/execute', + autoExecuteTools: true, + interactive: false, + // Hosted execution refuses to run without attribution, so the resolved + // snapshot must always ride along. + billingAttribution: billingAttributionSnapshot, + }) + expect(mockResolveBillingAttribution).toHaveBeenCalledWith({ + actorUserId: 'user-1', + workspaceId: 'workspace-1', + }) + }) + + it('continues the conversation the caller names', async () => { + const response = await callChat({ + workspaceId: 'workspace-1', + message: 'and then?', + conversationId: 'conv-9', + }) + + expect(response.status).toBe(200) + const body = await response.json() + expect(body.data.conversationId).toBe('conv-9') + expect(mockRunHeadlessCopilotLifecycle.mock.calls[0][0]).toMatchObject({ chatId: 'conv-9' }) + }) + + it('answers a failed run as a 500 with the run error', async () => { + mockRunHeadlessCopilotLifecycle.mockResolvedValue({ success: false, error: 'model exploded' }) + + const response = await callChat({ workspaceId: 'workspace-1', message: 'hi' }) + + expect(response.status).toBe(500) + const body = await response.json() + expect(body.error.message).toBe('model exploded') + }) + + it('streams heartbeats, chunks, and a final event for NDJSON callers', async () => { + mockRunHeadlessCopilotLifecycle.mockImplementation( + async (_payload: unknown, options: { onEvent?: (event: unknown) => Promise }) => { + await options.onEvent?.({ + type: 'text', + payload: { channel: 'assistant', text: 'Hello' }, + }) + await options.onEvent?.({ + type: 'text', + payload: { channel: 'assistant', text: 'Hello there' }, + }) + return successResult + } + ) + + const response = await callChat( + { workspaceId: 'workspace-1', message: 'hi' }, + { accept: 'application/x-ndjson' } + ) + + expect(response.status).toBe(200) + expect(response.headers.get('content-type')).toContain('application/x-ndjson') + const events = await readNdjsonEvents(response) + + expect(events[0].type).toBe('heartbeat') + const chunks = events.filter((event) => event.type === 'chunk') + expect(chunks.map((chunk) => chunk.content)).toEqual(['Hello', ' there']) + const final = events.at(-1) as { type: string; data: Record } + expect(final.type).toBe('final') + expect(final.data).toMatchObject({ content: 'Hello there', conversationId: 'generated-1' }) + }) + + it('ends the NDJSON stream with an error event when the run fails', async () => { + mockRunHeadlessCopilotLifecycle.mockResolvedValue({ success: false, error: 'model exploded' }) + + const response = await callChat( + { workspaceId: 'workspace-1', message: 'hi' }, + { accept: 'application/x-ndjson' } + ) + + expect(response.status).toBe(200) + const events = await readNdjsonEvents(response) + const last = events.at(-1) as { type: string; error?: string } + expect(last.type).toBe('error') + expect(last.error).toBe('model exploded') + }) +}) diff --git a/apps/sim/app/api/v2/chat/route.ts b/apps/sim/app/api/v2/chat/route.ts new file mode 100644 index 00000000000..a7df7680448 --- /dev/null +++ b/apps/sim/app/api/v2/chat/route.ts @@ -0,0 +1,386 @@ +import { createLogger } from '@sim/logger' +import { getErrorMessage, toError } from '@sim/utils/errors' +import { generateId } from '@sim/utils/id' +import type { NextRequest } from 'next/server' +import { v2ChatContract } from '@/lib/api/contracts/v2/chat' +import { parseRequest } from '@/lib/api/server' +import { + admitV2Request, + V2_PARSE_DEFAULTS, + V2RouteInfrastructureError, + v2ApiKeyAuth, + v2RateLimits, +} from '@/lib/api/server/routes' +import { resolveBillingAttribution } from '@/lib/billing/core/billing-attribution' +import { chatOperations } from '@/lib/copilot/application/operations' +import { buildIntegrationToolSchemas } from '@/lib/copilot/chat/payload' +import { generateWorkspaceContext } from '@/lib/copilot/chat/workspace-context' +import { computeWorkspaceEntitlements } from '@/lib/copilot/entitlements' +import { + type CopilotEnvironmentContext, + createCopilotEnvironmentContext, +} from '@/lib/copilot/environment-context' +import { + MothershipStreamV1EventType, + MothershipStreamV1TextChannel, +} from '@/lib/copilot/generated/mothership-stream-v1' +import { runHeadlessCopilotLifecycle } from '@/lib/copilot/request/lifecycle/headless' +import { requestExplicitStreamAbort } from '@/lib/copilot/request/session/explicit-abort' +import type { StreamEvent } from '@/lib/copilot/request/types' +import { normalizeSecretMountPolicy } from '@/lib/copilot/secret-mount-policy' +import { isDocSandboxEnabled } from '@/lib/core/config/env-flags' +import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { getPersonalAndWorkspaceEnv } from '@/lib/environment/utils' +import { + assertActiveWorkspaceAccess, + isWorkspaceAccessDeniedError, +} from '@/lib/workspaces/permissions/utils' +import { v2Data, v2Error } from '@/app/api/v2/lib/response' + +export const dynamic = 'force-dynamic' +export const maxDuration = 3600 + +const logger = createLogger('V2ChatAPI') + +const CHAT_STREAM_CONTENT_TYPE = 'application/x-ndjson' +const CHAT_STREAM_HEADER = 'x-mothership-execute-stream' +const CHAT_STREAM_VALUE = 'ndjson' +const CHAT_HEARTBEAT_INTERVAL_MS = 15_000 +const ndjsonEncoder = new TextEncoder() + +function isAbortError(error: unknown): boolean { + return error instanceof Error && error.name === 'AbortError' +} + +function wantsStreamedChatResponse(req: NextRequest): boolean { + return ( + req.headers.get(CHAT_STREAM_HEADER) === CHAT_STREAM_VALUE || + req.headers.get('accept')?.includes(CHAT_STREAM_CONTENT_TYPE) === true + ) +} + +function encodeNdjson(value: unknown): Uint8Array { + return ndjsonEncoder.encode(`${JSON.stringify(value)}\n`) +} + +/** + * Same projection as the Sim Chat block's execute endpoint: the full assistant + * reply, the conversation id that continues this conversation, and the client + * tool calls the run surfaced. + */ +function buildChatResultPayload( + result: Awaited>, + conversationId: string, + integrationTools: Array<{ name: string }> +) { + const clientToolNames = new Set(integrationTools.map((t) => t.name)) + const clientToolCalls = (result.toolCalls || []).filter( + (tc: { name: string }) => clientToolNames.has(tc.name) || tc.name.startsWith('mcp-') + ) + + return { + content: result.content ?? '', + model: 'mothership', + conversationId, + tokens: result.usage + ? { + prompt: result.usage.prompt, + completion: result.usage.completion, + total: (result.usage.prompt || 0) + (result.usage.completion || 0), + } + : {}, + cost: result.cost || undefined, + toolCalls: clientToolCalls, + } +} + +/** + * POST /api/v2/chat + * + * One conversational turn against the same headless execution path as the Sim + * Chat block (`/api/mothership/execute`), authenticated with a personal API key + * instead of the executor's internal JWT. JSON callers get one final response; + * NDJSON callers (`Accept: application/x-ndjson`) get heartbeats and incremental + * `chunk` events followed by a `final` event, so long-running turns do not look + * idle to intermediaries. + * + * A raw special route rather than a builder route: the response is a + * long-running protocol stream, and the work is copilot orchestration rather + * than a domain use case. + */ +export const POST = withRouteHandler( + async (req: NextRequest) => { + const admission = await admitV2Request( + req, + chatOperations.send, + v2ApiKeyAuth, + v2RateLimits.publicApi + ) + if (!admission.success) return admission.response + const { principal } = admission.auth + + if (principal.kind !== 'personal_api_key') { + return v2Error('FORBIDDEN', 'Chat requires a personal API key', { + details: { code: 'PRINCIPAL_KIND_NOT_PERMITTED' }, + }) + } + const userId = principal.userId + + const parsed = await parseRequest(v2ChatContract, req, {}, { ...V2_PARSE_DEFAULTS }) + if (!parsed.success) return parsed.response + const { workspaceId, message, conversationId } = parsed.data.body + + const chatId = conversationId || generateId() + const messageId = generateId() + const requestId = generateId() + const reqLogger = logger.withMetadata({ chatId, messageId, requestId }) + + try { + const workspaceAccess = await assertActiveWorkspaceAccess(workspaceId, userId) + const userPermission = workspaceAccess.permission + const secretMountPolicy = normalizeSecretMountPolicy(undefined) + + let environmentContext: CopilotEnvironmentContext | undefined + try { + const environment = await getPersonalAndWorkspaceEnv(userId, workspaceId, { + workspaceAccess, + }) + environmentContext = await createCopilotEnvironmentContext(userId, workspaceId, environment) + } catch (error) { + reqLogger.warn('Failed to build chat environment context', { + error: getErrorMessage(error), + userId, + workspaceId, + }) + } + + const [workspaceContext, integrationTools, entitlements, billingAttribution] = + await Promise.all([ + generateWorkspaceContext(workspaceId, userId, { workspaceAccess, secretMountPolicy }), + buildIntegrationToolSchemas(userId, messageId, undefined, workspaceId), + computeWorkspaceEntitlements(workspaceId, userId), + // Hosted execution refuses to run without an attribution snapshot; + // the executor path receives it as a header, this path resolves it + // from the authenticated actor and asserted workspace. + resolveBillingAttribution({ actorUserId: userId, workspaceId }), + ]) + + const requestPayload: Record = { + messages: [{ role: 'user', content: message }], + userId, + workspaceId, + chatId, + mode: 'agent', + messageId, + isHosted: true, + workspaceContext, + ...(isDocSandboxEnabled ? { docCompiler: 'python' } : {}), + ...(integrationTools.length > 0 ? { integrationTools } : {}), + ...(userPermission ? { userPermission } : {}), + ...(entitlements.length > 0 ? { entitlements } : {}), + } + + let allowExplicitAbort = true + let explicitAbortRequest: Promise | undefined + const lifecycleAbortController = new AbortController() + const requestExplicitAbortOnce = () => { + if (!allowExplicitAbort || explicitAbortRequest) { + return + } + + explicitAbortRequest = requestExplicitStreamAbort({ + streamId: messageId, + userId, + chatId, + workspaceId, + }).catch((error) => { + reqLogger.warn('Failed to send explicit abort for chat request', { + error: toError(error).message, + }) + }) + } + const abortLifecycle = (reason?: unknown) => { + if (!lifecycleAbortController.signal.aborted) { + lifecycleAbortController.abort(reason ?? 'chat_request_aborted') + } + requestExplicitAbortOnce() + } + const onAbort = () => { + abortLifecycle(req.signal.reason ?? 'request_aborted') + } + + if (req.signal.aborted) { + onAbort() + } else { + req.signal.addEventListener('abort', onAbort, { once: true }) + } + + const runLifecycle = (onEvent?: (event: StreamEvent) => Promise) => + runHeadlessCopilotLifecycle(requestPayload, { + userId, + workspaceId, + chatId, + simRequestId: requestId, + // The Go copilot route this turn is POSTed to β€” the same headless + // execute surface the Sim Chat block uses (it also selects the + // mothership sandbox profile for code tools). + goRoute: '/api/mothership/execute', + autoExecuteTools: true, + interactive: false, + abortSignal: lifecycleAbortController.signal, + billingAttribution, + ...(userPermission ? { userPermission } : {}), + secretActorUserId: userId, + secretMountPolicy, + environmentContext, + onEvent, + }) + + if (wantsStreamedChatResponse(req)) { + let cancelled = false + let heartbeatId: ReturnType | undefined + + const stream = new ReadableStream({ + start(controller) { + let forwardedAssistantContent = '' + const send = (event: unknown) => { + if (!cancelled) { + controller.enqueue(encodeNdjson(event)) + } + } + + // Flush response headers promptly and keep long turns from looking + // idle to proxy HTTP stacks. + send({ type: 'heartbeat', timestamp: new Date().toISOString() }) + heartbeatId = setInterval(() => { + send({ type: 'heartbeat', timestamp: new Date().toISOString() }) + }, CHAT_HEARTBEAT_INTERVAL_MS) + + void (async () => { + try { + const result = await runLifecycle(async (event) => { + if ( + event.type === MothershipStreamV1EventType.text && + event.payload.channel === MothershipStreamV1TextChannel.assistant && + event.payload.text + ) { + const text = event.payload.text + const content = text.startsWith(forwardedAssistantContent) + ? text.slice(forwardedAssistantContent.length) + : text + if (content) { + forwardedAssistantContent += content + send({ type: 'chunk', content }) + } + } + }) + allowExplicitAbort = false + + if (lifecycleAbortController.signal.aborted) { + send({ type: 'error', error: 'Chat request aborted' }) + return + } + + if (!result.success) { + reqLogger.error('Chat request failed', { + error: result.error, + errors: result.errors, + }) + send({ + type: 'error', + error: result.error || 'Chat request failed', + content: result.content || '', + }) + return + } + + send({ + type: 'final', + data: buildChatResultPayload(result, chatId, integrationTools), + }) + } catch (error) { + if ( + lifecycleAbortController.signal.aborted || + req.signal.aborted || + isAbortError(error) + ) { + reqLogger.info('Chat request aborted') + send({ type: 'error', error: 'Chat request aborted' }) + return + } + + reqLogger.error('Chat request error', { + error: getErrorMessage(error, 'Unknown error'), + }) + send({ type: 'error', error: getErrorMessage(error, 'Internal server error') }) + } finally { + allowExplicitAbort = false + if (heartbeatId) { + clearInterval(heartbeatId) + } + req.signal.removeEventListener('abort', onAbort) + await explicitAbortRequest + if (!cancelled) { + controller.close() + } + } + })() + }, + cancel(reason) { + cancelled = true + if (heartbeatId) { + clearInterval(heartbeatId) + } + abortLifecycle(reason ?? 'chat_stream_cancelled') + }, + }) + + return new Response(stream, { + headers: { + 'Content-Type': `${CHAT_STREAM_CONTENT_TYPE}; charset=utf-8`, + 'Cache-Control': 'no-cache, no-transform', + }, + }) + } + + try { + const result = await runLifecycle() + allowExplicitAbort = false + + if (lifecycleAbortController.signal.aborted || req.signal.aborted) { + reqLogger.info('Chat request aborted after lifecycle completion') + return v2Error('CLIENT_CLOSED_REQUEST', 'Chat request aborted') + } + + if (!result.success) { + reqLogger.error('Chat request failed', { error: result.error, errors: result.errors }) + return v2Error('INTERNAL_ERROR', result.error || 'Chat request failed') + } + + return v2Data(buildChatResultPayload(result, chatId, integrationTools)) + } finally { + allowExplicitAbort = false + req.signal.removeEventListener('abort', onAbort) + await explicitAbortRequest + } + } catch (error) { + if (req.signal.aborted || isAbortError(error)) { + reqLogger.info('Chat request aborted') + return v2Error('CLIENT_CLOSED_REQUEST', 'Chat request aborted') + } + + if (isWorkspaceAccessDeniedError(error)) { + return v2Error('FORBIDDEN', 'Workspace access denied') + } + + reqLogger.error('Chat request error', { error: getErrorMessage(error, 'Unknown error') }) + return v2Error('INTERNAL_ERROR', 'Internal server error') + } + }, + { + unhandledErrorResponse: ({ error }) => + error instanceof V2RouteInfrastructureError + ? v2Error('SERVICE_UNAVAILABLE', 'Service temporarily unavailable') + : v2Error('INTERNAL_ERROR', 'Internal server error'), + } +) diff --git a/apps/sim/lib/api/contracts/v2/chat.ts b/apps/sim/lib/api/contracts/v2/chat.ts new file mode 100644 index 00000000000..1f8170befbe --- /dev/null +++ b/apps/sim/lib/api/contracts/v2/chat.ts @@ -0,0 +1,62 @@ +import { z } from 'zod' +import { noInputSchema } from '@/lib/api/contracts/primitives' +import { defineRouteContract } from '@/lib/api/contracts/types' +import { v2DataResponse } from '@/lib/api/contracts/v2/shared' + +/** + * v2 chat contract β€” the `sim chat` surface. + * + * One turn against the same headless execution path the Sim Chat block uses: + * the caller sends a message (optionally continuing an existing conversation) + * and receives the reply plus the conversation id that reinvokes the same + * conversation on the next turn. + */ + +export const v2ChatBodySchema = z.object({ + workspaceId: z + .string() + .min(1, 'workspaceId is required') + .describe('Workspace the conversation runs in.'), + message: z + .string() + .min(1, 'message cannot be empty') + .max(200_000, 'message cannot exceed 200000 characters') + .describe('The message to send to Sim.'), + conversationId: z + .string() + .min(1, 'conversationId cannot be empty') + .max(128, 'conversationId cannot exceed 128 characters') + .optional() + .describe('Conversation to continue; a new one starts when omitted.'), +}) + +const v2ChatTokensSchema = z.object({ + prompt: z.number().optional(), + completion: z.number().optional(), + total: z.number().optional(), +}) + +export const v2ChatResultSchema = z.object({ + content: z.string(), + conversationId: z.string(), + model: z.string(), + tokens: v2ChatTokensSchema.optional(), + // untyped-response: cost is a billing passthrough whose shape is owned by the copilot backend, not this contract + cost: z.unknown().optional(), + // untyped-response: each tool call's arguments and result shapes are owned by the tool that produced them + toolCalls: z.array(z.record(z.string(), z.unknown())).optional(), +}) + +export const v2ChatContract = defineRouteContract({ + method: 'POST', + path: '/api/v2/chat', + query: noInputSchema, + body: v2ChatBodySchema, + response: { + mode: 'json', + schema: v2DataResponse(v2ChatResultSchema), + }, +}) + +export type V2ChatBody = z.input +export type V2ChatResult = z.output diff --git a/apps/sim/lib/copilot/application/operations.ts b/apps/sim/lib/copilot/application/operations.ts new file mode 100644 index 00000000000..2fc9830226b --- /dev/null +++ b/apps/sim/lib/copilot/application/operations.ts @@ -0,0 +1,16 @@ +import { defineWorkspaceOperation } from '@/lib/core/application' + +/** + * Chat is a user-actor surface: the run is attributed to a person, reads their + * personal environment, and writes their memories. A workspace key names no + * acting user, so it cannot express the caller and is denied rather than + * silently substituting the key's owner. + */ +export const chatOperations = { + send: defineWorkspaceOperation({ + id: 'chat.send', + minimumRole: 'read', + workspaceApiKey: 'deny', + principalKinds: ['personal_api_key'], + }), +} as const diff --git a/bun.lock b/bun.lock index 83936801773..d5b11db7e06 100644 --- a/bun.lock +++ b/bun.lock @@ -1,6 +1,5 @@ { "lockfileVersion": 1, - "configVersion": 0, "workspaces": { "": { "name": "simstudio", diff --git a/packages/sim-cli/src/commands/protocol/chat.test.ts b/packages/sim-cli/src/commands/protocol/chat.test.ts new file mode 100644 index 00000000000..6d51e3baa35 --- /dev/null +++ b/packages/sim-cli/src/commands/protocol/chat.test.ts @@ -0,0 +1,165 @@ +import { Command } from 'commander' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { buildGeneratedCommands } from '../../runtime/build' +import { attachProtocolCommands } from './index' + +const { output, requestRaw } = vi.hoisted(() => ({ + output: { format: 'table' }, + requestRaw: vi.fn(), +})) + +vi.mock('../../context', () => ({ + clientFrom: () => ({ + client: { requestRaw, requireWorkspace: () => 'ws_local' }, + profile: { + workspaceId: 'ws_local', + output: output.format, + name: 'default', + apiKey: 'k', + endpoint: 'https://sim.example', + }, + }), +})) + +interface WriteSpy { + mock: { calls: unknown[][] } +} + +let stdout: WriteSpy +let stderr: WriteSpy + +beforeEach(() => { + output.format = 'table' + requestRaw.mockReset() + stdout = vi.spyOn(process.stdout, 'write').mockImplementation(() => true) + stderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => true) +}) + +afterEach(() => { + vi.restoreAllMocks() +}) + +function ndjson(events: Array>): Response { + const body = new ReadableStream({ + start(controller) { + for (const event of events) { + controller.enqueue(new TextEncoder().encode(`${JSON.stringify(event)}\n`)) + } + controller.close() + }, + }) + return new Response(body, { + status: 200, + headers: { 'content-type': 'application/x-ndjson; charset=utf-8' }, + }) +} + +function program(): Command { + const root = new Command('sim').exitOverride() + for (const group of buildGeneratedCommands()) root.addCommand(group) + attachProtocolCommands(root) + return root +} + +function run(...args: string[]): Promise { + return program().parseAsync(['chat', ...args], { from: 'user' }) +} + +function written(spy: WriteSpy): string { + return spy.mock.calls.map((call) => String(call[0])).join('') +} + +const FINAL = { + type: 'final', + data: { content: 'Hello there', conversationId: 'conv-1', model: 'mothership' }, +} + +describe('sim chat', () => { + it('sends the message and streams the reply, then names the conversation on stderr', async () => { + requestRaw.mockResolvedValue( + ndjson([ + { type: 'heartbeat', timestamp: '2026-08-21T00:00:00.000Z' }, + { type: 'chunk', content: 'Hello ' }, + { type: 'chunk', content: 'there' }, + FINAL, + ]) + ) + + await run('What workflows do I have?') + + expect(requestRaw).toHaveBeenCalledWith('/api/v2/chat', { + method: 'POST', + body: { workspaceId: 'ws_local', message: 'What workflows do I have?' }, + headers: { accept: 'application/x-ndjson' }, + }) + expect(written(stdout)).toBe('Hello there\n') + expect(written(stderr)).toContain('conversation: conv-1') + }) + + it('passes -c through as the conversation to continue', async () => { + requestRaw.mockResolvedValue(ndjson([FINAL])) + + await run('-c', 'conv-1', 'And which run on a schedule?') + + expect(requestRaw).toHaveBeenCalledWith('/api/v2/chat', { + method: 'POST', + body: { + workspaceId: 'ws_local', + message: 'And which run on a schedule?', + conversationId: 'conv-1', + }, + headers: { accept: 'application/x-ndjson' }, + }) + }) + + it('prints the full content when the stream carried no chunks', async () => { + requestRaw.mockResolvedValue(ndjson([FINAL])) + + await run('hello') + + expect(written(stdout)).toBe('Hello there\n') + }) + + it('prints the final suffix the chunks never carried, without repeating the prefix', async () => { + requestRaw.mockResolvedValue(ndjson([{ type: 'chunk', content: 'Hello ' }, FINAL])) + + await run('hello') + + expect(written(stdout)).toBe('Hello there\n') + }) + + it('strips terminal control sequences from the streamed reply', async () => { + requestRaw.mockResolvedValue(ndjson([{ type: 'chunk', content: 'safe\u001b[31m text' }, FINAL])) + + await run('hello') + + expect(written(stdout)).toContain('safe text') + expect(written(stdout)).not.toContain('\u001b') + }) + + it('prints one finished document for --output json, without streaming', async () => { + output.format = 'json' + const log = vi.spyOn(console, 'log').mockImplementation(() => {}) + requestRaw.mockResolvedValue(ndjson([{ type: 'chunk', content: 'Hello ' }, FINAL])) + + await run('hello') + + expect(written(stdout)).toBe('') + const printed = JSON.parse(log.mock.calls.map((call) => String(call[0])).join('\n')) + expect(printed).toMatchObject({ content: 'Hello there', conversationId: 'conv-1' }) + }) + + it('surfaces a server error event as a clean failure', async () => { + requestRaw.mockResolvedValue( + ndjson([{ type: 'heartbeat' }, { type: 'error', error: 'Chat request failed' }]) + ) + + await expect(run('hello')).rejects.toThrow('Chat request failed') + }) + + it('reports a stream that ends without a final result', async () => { + requestRaw.mockResolvedValue(ndjson([{ type: 'chunk', content: 'partial' }])) + + await expect(run('hello')).rejects.toThrow('Chat stream ended without a final result') + }) +}) diff --git a/packages/sim-cli/src/commands/protocol/chat.ts b/packages/sim-cli/src/commands/protocol/chat.ts new file mode 100644 index 00000000000..320f5451dc3 --- /dev/null +++ b/packages/sim-cli/src/commands/protocol/chat.ts @@ -0,0 +1,179 @@ +import chalk from 'chalk' +import type { Command } from 'commander' +import { clientFrom } from '../../context' +import { type ChatResponse, V2_OPERATIONS } from '../../generated/v2-api' +import { SimApiError } from '../../http/client' +import { sanitize } from '../../output/render' +import { printProtocolResult } from './result' + +/** The final payload, as `POST /api/v2/chat` answers it. */ +type ChatResult = ChatResponse['data'] + +/** + * One line of the chat NDJSON stream β€” the same protocol the Sim Chat block + * consumes from the execute endpoint: heartbeats keep the connection visibly + * alive, `chunk` events carry assistant text as it generates, and exactly one + * `final` or `error` event ends the turn. + */ +type ChatStreamEvent = + | { type: 'heartbeat'; timestamp?: string } + | { type: 'chunk'; content?: string } + | { type: 'final'; data: ChatResult } + | { type: 'error'; error?: string } + +interface ChatOptions { + conversation?: string +} + +function parseChatStreamLine(line: string): ChatStreamEvent | undefined { + const trimmed = line.trim() + if (!trimmed) return undefined + + try { + return JSON.parse(trimmed) as ChatStreamEvent + } catch { + throw new SimApiError('Chat stream returned malformed data', 0) + } +} + +/** + * Consumes the chat NDJSON stream to its final payload. + * + * `onChunk` receives assistant text as it arrives, already sanitized for the + * terminal. The stream ends with exactly one `final` or `error` event; a stream + * that ends with neither is reported rather than treated as an empty reply. + */ +async function readChatStream( + response: Response, + onChunk: (content: string) => void +): Promise { + if (!response.body) { + throw new SimApiError('Chat stream ended without a response body', 0) + } + + const reader = response.body.getReader() + const decoder = new TextDecoder() + let buffer = '' + let finalResult: ChatResult | undefined + + const processLine = (line: string): void => { + const event = parseChatStreamLine(line) + if (!event || event.type === 'heartbeat') return + + if (event.type === 'chunk') { + if (event.content) onChunk(sanitize(event.content)) + return + } + + if (event.type === 'error') { + throw new SimApiError(event.error || 'Chat request failed', 0) + } + + if (event.type === 'final') { + finalResult = event.data + return + } + + throw new SimApiError('Chat stream returned an unknown event', 0) + } + + try { + while (true) { + const { done, value } = await reader.read() + if (done) break + + buffer += decoder.decode(value, { stream: true }) + const lines = buffer.split('\n') + buffer = lines.pop() ?? '' + for (const line of lines) { + processLine(line) + } + } + + buffer += decoder.decode() + processLine(buffer) + + if (!finalResult) { + throw new SimApiError('Chat stream ended without a final result', 0) + } + + return finalResult + } finally { + reader.releaseLock() + } +} + +/** + * Adds `sim chat`. + * + * A protocol command rather than a generated one: the generated pass can only + * make one JSON request, while a chat turn can run for minutes and is consumed + * as an NDJSON stream so the reply prints as it generates and heartbeats keep + * proxies from idling the connection out. The generated `chat` operation is + * hidden in the CLI contract in favour of this command. + */ +export function attachChat(program: Command): void { + program + .command('chat') + .description('Ask Sim and print the reply') + .argument('', 'What to ask Sim') + .option('-c, --conversation ', 'Continue the conversation with this ID') + .addHelpText( + 'after', + ` +Each turn prints the reply on stdout and the conversation ID on stderr; pass +that ID back with -c to continue the same conversation. With --output json or +yaml the reply is not streamed β€” the finished result is printed as one +document, conversation ID included. + +Examples: + $ sim chat "What workflows do I have?" + $ sim chat -c 3f2a… "Which of those run on a schedule?" + $ sim --output json chat "Summarize yesterday's failed runs" | jq -r '.content' +` + ) + .action(async (message: string, options: ChatOptions, command: Command) => { + const { client, profile } = clientFrom(command) + const workspaceId = client.requireWorkspace() + + const response = await client.requestRaw(V2_OPERATIONS.chat.path, { + method: 'POST', + body: { + workspaceId, + message, + ...(options.conversation ? { conversationId: options.conversation } : {}), + }, + headers: { accept: 'application/x-ndjson' }, + }) + + // Structured output waits for the finished result: a half-streamed reply + // interleaved with a JSON document is parseable by neither human nor jq. + const streaming = profile.output === 'table' || profile.output === 'text' + let streamed = '' + const result = await readChatStream(response, (content) => { + if (!streaming) return + streamed += content + process.stdout.write(content) + }) + + if (!streaming) { + printProtocolResult(profile.output, result) + return + } + + // A run that produced its reply without incremental chunks β€” or whose + // final content outran the streamed deltas β€” still has to print in full. + // Only the missing suffix is written, so nothing already on the terminal + // repeats; a final that diverges from the stream entirely stays unprinted + // rather than duplicating the reply. + const content = sanitize(result.content ?? '') + if (content.startsWith(streamed) && content.length > streamed.length) { + process.stdout.write(content.slice(streamed.length)) + streamed = content + } + if (streamed.length > 0 && !streamed.endsWith('\n')) { + process.stdout.write('\n') + } + process.stderr.write(`${chalk.dim(`conversation: ${result.conversationId}`)}\n`) + }) +} diff --git a/packages/sim-cli/src/commands/protocol/index.ts b/packages/sim-cli/src/commands/protocol/index.ts index 9af2f47c747..ea85ee7d69f 100644 --- a/packages/sim-cli/src/commands/protocol/index.ts +++ b/packages/sim-cli/src/commands/protocol/index.ts @@ -1,4 +1,5 @@ import { Command } from 'commander' +import { attachChat } from './chat' import { attachFileGet } from './files-get' import { attachFileUpload } from './files-upload' import { attachKnowledgeDocumentUpload } from './knowledge-document-upload' @@ -60,4 +61,6 @@ export function attachProtocolCommands(program: Command): void { attachWorkflowRunWait(group(workflows, 'runs')) attachLogsFollow(group(program, 'logs')) + + attachChat(program) } diff --git a/packages/sim-cli/src/contract/commands.ts b/packages/sim-cli/src/contract/commands.ts index 7c9f5d97b6a..78d1b767657 100644 --- a/packages/sim-cli/src/contract/commands.ts +++ b/packages/sim-cli/src/contract/commands.ts @@ -67,6 +67,9 @@ function moveResource(command: string, resource: string): CommandVariantSpec { * upsertTableRow β†’ sim tables upsert */ export const CLI_CONTRACT: CliContract = { + // Hidden in favour of the protocol `sim chat` command, which consumes the + // endpoint as an NDJSON stream so the reply prints as it generates. + chat: { hidden: true }, createCredentialConnection: { hidden: true }, createServiceAccountCredential: { hidden: true }, getBillingStatus: { diff --git a/packages/sim-cli/src/generated/v2-api.ts b/packages/sim-cli/src/generated/v2-api.ts index 6271ef1ed30..b6eac6251cd 100644 --- a/packages/sim-cli/src/generated/v2-api.ts +++ b/packages/sim-cli/src/generated/v2-api.ts @@ -481,6 +481,30 @@ export type CancelWorkflowRunResponse = { data: CancelWorkflowRunResponseRef0 } +/** `POST /api/v2/chat` */ +export type ChatQuery = Record + +export type ChatBody = { + workspaceId: string + message: string + conversationId?: string +} + +export type ChatResponse = { + data: { + content: string + conversationId: string + model: string + tokens?: { + prompt?: number + completion?: number + total?: number + } + cost?: unknown + toolCalls?: Array> + } +} + /** `POST /api/v2/files/uploads/[uploadId]/complete` */ export type CompleteFileUploadParams = { uploadId: string @@ -6315,6 +6339,24 @@ export const V2_OPERATIONS = { responseMode: 'json', summary: 'Cancel Workflow Run', }, + chat: { + method: 'POST', + path: '/api/v2/chat', + pathParams: [] as const, + responseMode: 'json', + body: { + workspaceId: { + kind: 'string', + required: true, + describe: 'Workspace the conversation runs in.', + }, + message: { kind: 'string', required: true, describe: 'The message to send to Sim.' }, + conversationId: { + kind: 'string', + describe: 'Conversation to continue; a new one starts when omitted.', + }, + }, + }, completeFileUpload: { method: 'POST', path: '/api/v2/files/uploads/[uploadId]/complete', diff --git a/scripts/check-api-validation-contracts.ts b/scripts/check-api-validation-contracts.ts index 449e00c4d75..2b92482ad92 100644 --- a/scripts/check-api-validation-contracts.ts +++ b/scripts/check-api-validation-contracts.ts @@ -9,8 +9,8 @@ const QUERY_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/queries') const SELECTOR_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/selectors') const BASELINE = { - totalRoutes: 1160, - zodRoutes: 1160, + totalRoutes: 1161, + zodRoutes: 1161, nonZodRoutes: 0, } as const diff --git a/scripts/check-openapi-specs.ts b/scripts/check-openapi-specs.ts index 4dbae563db4..e059c83e6b2 100644 --- a/scripts/check-openapi-specs.ts +++ b/scripts/check-openapi-specs.ts @@ -66,6 +66,8 @@ const SPEC_FILES = OPENAPI_SPEC_FILES * transfer is published on `transfer.url` in `contracts/v2/uploads.ts`. */ const UNDOCUMENTED_V2_ROUTES: Readonly> = { + 'POST /api/v2/chat': + 'Conversational surface behind `sim chat`. The contract describes the JSON answer, but the CLI consumes the same endpoint as an NDJSON progress stream negotiated by Accept header β€” a protocol `checkV2Conventions` cannot describe as a published operation. Deliberately unpublished while the surface is CLI-only; document it when the JSON shape is committed to as public API.', 'PUT /api/v2/uploads/{uploadId}': 'Local-storage data plane for a signed whole-object upload. Authenticated by the short-lived upload-token minted by the documented session-create operation, not by an API key, so it carries neither the v2 API-key security scheme nor the rate-limit and feature-gate responses `checkV2Conventions` requires of a published operation. On a cloud deployment the same field points at object storage instead, so the endpoint is described by `transfer.url` β€” which publishes its method, headers, success status, and error codes β€” rather than by an operation of its own.', 'PUT /api/v2/uploads/{uploadId}/parts/{partNumber}': diff --git a/scripts/generate-cli-docs.ts b/scripts/generate-cli-docs.ts index 2b2f5be0190..ff4023cc476 100644 --- a/scripts/generate-cli-docs.ts +++ b/scripts/generate-cli-docs.ts @@ -277,6 +277,7 @@ const ACRONYMS = new Set([ 'JSON', 'MCP', 'OAuth', + 'Sim', 'SSE', 'SSO', 'URL', From 85a322667825e3ddd739ea18c5ba92e9cfb02b43 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 21 Aug 2026 13:33:52 -0700 Subject: [PATCH 05/63] fix(security): stop redirects replaying request bodies and leaking credentials (#6941) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(security): stop redirects replaying request bodies and leaking credentials `secureFetchWithPinnedIP` passed its options straight into the redirect recursion, so a 301/302/303 replayed the original method and body β€” delivering a non-idempotent write twice β€” and forwarded `Authorization` and every other caller header to whatever origin the upstream named. `followRedirectsGuarded`, a hundred lines above it in the same file, already had the correct RFC 9110 rules. The two had drifted, and the drift is the bug. Both now route through one `resolveRedirectHop`: - 303, and 301/302 on POST, degrade to a bodyless GET and drop the entity headers that described the removed body. - A cross-origin hop drops every caller header, not just `Authorization`. - A cross-origin hop that would forward a body is refused. `stripAuthOnRedirect` still narrows same-origin hops for endpoints that redirect to a target carrying its own signed URL. Verified by stashing the fix and re-running: 4 of the 6 new tests fail against the old code. The 2 that pass either way cover same-origin behaviour that was already correct. * fix(api): preserve HTTP redirect compatibility --- .../sub-block/components/switch/switch.tsx | 2 +- .../editor/components/sub-block/sub-block.tsx | 1 + apps/sim/blocks/blocks/api.test.ts | 17 + apps/sim/blocks/blocks/api.ts | 24 ++ .../workflow/edit-workflow/builders.test.ts | 32 ++ .../server/workflow/edit-workflow/builders.ts | 5 +- .../lib/core/security/http-redirect-policy.ts | 12 + .../core/security/input-validation.server.ts | 130 +++++-- .../pinned-redirect-replay.server.test.ts | 341 ++++++++++++++++++ .../core/security/ssrf-guarded-lookup.test.ts | 9 + apps/sim/tools/generated/tool-metadata.ts | 2 +- apps/sim/tools/http/request.test.ts | 79 ++++ apps/sim/tools/http/request.ts | 20 +- apps/sim/tools/http/types.ts | 4 +- apps/sim/tools/http/utils.ts | 43 ++- apps/sim/tools/index.ts | 1 + apps/sim/tools/request-transport.ts | 47 ++- apps/sim/tools/types.ts | 3 + apps/sim/tools/utils.test.ts | 29 ++ 19 files changed, 766 insertions(+), 35 deletions(-) create mode 100644 apps/sim/blocks/blocks/api.test.ts create mode 100644 apps/sim/lib/core/security/http-redirect-policy.ts create mode 100644 apps/sim/lib/core/security/pinned-redirect-replay.server.test.ts diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/switch/switch.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/switch/switch.tsx index 9ac68b39dac..f4756f67029 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/switch/switch.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/switch/switch.tsx @@ -22,7 +22,7 @@ export function Switch({ }: SwitchProps) { const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlockId) - const value = isPreview ? previewValue : propValue !== undefined ? propValue : storeValue + const value = isPreview ? previewValue : (storeValue ?? propValue) const handleChange = (checked: boolean) => { if (!isPreview && !disabled) { diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx index fbbc224651b..22fb31478c0 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx @@ -790,6 +790,7 @@ function SubBlockComponent({ blockId={blockId} subBlockId={config.id} title={config.title ?? ''} + value={typeof config.defaultValue === 'boolean' ? config.defaultValue : undefined} isPreview={isPreview} previewValue={previewValue as any} disabled={isDisabled} diff --git a/apps/sim/blocks/blocks/api.test.ts b/apps/sim/blocks/blocks/api.test.ts new file mode 100644 index 00000000000..4763ee57e6b --- /dev/null +++ b/apps/sim/blocks/blocks/api.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from 'vitest' +import { ApiBlock } from '@/blocks/blocks/api' + +describe('API block redirect policy', () => { + it('uses a versioned safe default without changing legacy blocks', () => { + const version = ApiBlock.subBlocks.find((subBlock) => subBlock.id === 'redirectPolicyVersion') + const sendCredentials = ApiBlock.subBlocks.find( + (subBlock) => subBlock.id === 'sendCredentialsOnCrossOriginRedirect' + ) + + expect(version?.hidden).toBe(true) + expect(version?.defaultValue).toBe('standard-v1') + expect(sendCredentials?.type).toBe('switch') + expect(sendCredentials?.mode).toBe('advanced') + expect(sendCredentials?.defaultValue).toBe(true) + }) +}) diff --git a/apps/sim/blocks/blocks/api.ts b/apps/sim/blocks/blocks/api.ts index 62b1177e53a..40c9cb323b5 100644 --- a/apps/sim/blocks/blocks/api.ts +++ b/apps/sim/blocks/blocks/api.ts @@ -133,6 +133,22 @@ Example: description: 'Allow retries for POST/PATCH requests (may create duplicate requests)', mode: 'advanced', }, + { + id: 'redirectPolicyVersion', + title: 'Redirect policy version', + type: 'short-input', + defaultValue: 'standard-v1', + hidden: true, + }, + { + id: 'sendCredentialsOnCrossOriginRedirect', + title: 'Send credentials on cross-origin redirects', + type: 'switch', + defaultValue: true, + description: + 'Forward credential-bearing headers when a redirect changes scheme, host, or port. Enabled by default for compatibility; disable it when redirected destinations should not receive the same credentials.', + mode: 'advanced', + }, { id: 'proxyUrl', title: 'Proxy URL', @@ -163,6 +179,14 @@ Example: type: 'boolean', description: 'Allow retries for non-idempotent methods like POST/PATCH', }, + redirectPolicyVersion: { + type: 'string', + description: 'Persisted redirect-policy compatibility version', + }, + sendCredentialsOnCrossOriginRedirect: { + type: 'boolean', + description: 'Send credential-bearing headers on redirects to a different origin', + }, proxyUrl: { type: 'string', description: 'Optional http:// proxy URL to route the request through', diff --git a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.test.ts b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.test.ts index c73c80ada27..bf328ff899a 100644 --- a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.test.ts +++ b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.test.ts @@ -53,7 +53,27 @@ const slackBlockConfig = { subBlocks: [{ id: 'channel', type: 'channel-selector' }], } +const apiBlockConfig = { + type: 'api', + name: 'API', + outputs: {}, + subBlocks: [ + { + id: 'redirectPolicyVersion', + type: 'short-input', + hidden: true, + defaultValue: 'standard-v1', + }, + { + id: 'sendCredentialsOnCrossOriginRedirect', + type: 'switch', + defaultValue: true, + }, + ], +} + const blocksByType: Record = { + api: apiBlockConfig, agent: agentBlockConfig, condition: conditionBlockConfig, knowledge: knowledgeBlockConfig, @@ -62,6 +82,7 @@ const blocksByType: Record = { vi.mock('@/blocks/registry', () => ({ getAllBlocks: () => [ + apiBlockConfig, agentBlockConfig, conditionBlockConfig, knowledgeBlockConfig, @@ -143,6 +164,17 @@ describe('createBlockFromParams', () => { expect(filters[0].tagName).toBe('Department') expect(filters[0].id).toEqual(expect.any(String)) }) + + it('seeds hidden compatibility defaults on programmatically created blocks', () => { + const block = createBlockFromParams('api-1', { + type: 'api', + name: 'API', + triggerMode: false, + }) + + expect(block.subBlocks.redirectPolicyVersion.value).toBe('standard-v1') + expect(block.subBlocks.sendCredentialsOnCrossOriginRedirect.value).toBeNull() + }) }) describe('filterDisallowedTools', () => { diff --git a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts index ed094434412..218f82b83b0 100644 --- a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts +++ b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts @@ -213,7 +213,10 @@ export function createBlockFromParams( blockState.subBlocks[subBlock.id] = { id: subBlock.id, type: subBlock.type, - value: null, + value: + subBlock.hidden && subBlock.defaultValue !== undefined + ? structuredClone(subBlock.defaultValue) + : null, } } else { blockState.subBlocks[subBlock.id].type = subBlock.type diff --git a/apps/sim/lib/core/security/http-redirect-policy.ts b/apps/sim/lib/core/security/http-redirect-policy.ts new file mode 100644 index 00000000000..1ed54dcaf60 --- /dev/null +++ b/apps/sim/lib/core/security/http-redirect-policy.ts @@ -0,0 +1,12 @@ +/** + * Redirect behavior for outbound HTTP requests. + * + * `legacy` preserves Sim's historical replay semantics for persisted workflows, while + * `standard` follows Fetch-compatible method rules. Credential forwarding is controlled + * independently in both modes. + */ +export interface HttpRedirectPolicy { + mode: 'legacy' | 'standard' + sendCredentialsOnCrossOriginRedirect: boolean + sensitiveHeaders?: readonly string[] +} diff --git a/apps/sim/lib/core/security/input-validation.server.ts b/apps/sim/lib/core/security/input-validation.server.ts index b5f2e735d5c..08cd4ad311e 100644 --- a/apps/sim/lib/core/security/input-validation.server.ts +++ b/apps/sim/lib/core/security/input-validation.server.ts @@ -8,7 +8,6 @@ import { createLogger } from '@sim/logger' import { preferIpv4, resolveHostAddresses } from '@sim/security/dns' import { isLoopbackIp, isPrivateIp, isPrivateIpHost, unwrapIpv6Brackets } from '@sim/security/ssrf' import { toError } from '@sim/utils/errors' -import { omit } from '@sim/utils/object' import { HttpProxyAgent } from 'http-proxy-agent' import { HttpsProxyAgent } from 'https-proxy-agent' import * as ipaddr from 'ipaddr.js' @@ -19,6 +18,7 @@ import { request as undiciRequest, } from 'undici' import { isHosted, isPrivateDatabaseHostsAllowed } from '@/lib/core/config/env-flags' +import type { HttpRedirectPolicy } from '@/lib/core/security/http-redirect-policy' import { type ValidationResult, validateExternalUrl } from '@/lib/core/security/input-validation' import { nodeReadableToWebStream } from '@/lib/core/utils/node-stream' import { PayloadSizeLimitError } from '@/lib/core/utils/stream-limits' @@ -365,8 +365,13 @@ export interface SecureFetchOptions { */ maxResponseBytes?: number signal?: AbortSignal - /** Drop the Authorization header when following a redirect, so it is not sent to the redirect target's origin. */ + /** + * Drop the Authorization header when following any redirect, including a same-origin hop. + * Use this for endpoints that redirect to a target carrying its own signed URL. + */ stripAuthOnRedirect?: boolean + /** Omit for the historical behavior used by existing workflows. */ + redirectPolicy?: HttpRedirectPolicy /** * Pre-validated, IP-pinned `http://` proxy URL (see {@link validateAndPinProxyUrl}). * When set, the connection routes through this proxy and target-IP pinning is @@ -526,6 +531,56 @@ function assertGuardedRedirectTarget(url: URL, allowedPinnedIp?: string): void { } } +/** Headers that describe a request body and must not outlive it. */ +const ENTITY_HEADERS = [ + 'content-length', + 'content-type', + 'content-encoding', + 'content-language', + 'content-location', + 'transfer-encoding', +] as const + +/** Case-insensitive header removal β€” callers supply arbitrary casing. */ +function stripHeaders( + headers: Record, + remove: readonly string[] +): Record { + const drop = new Set(remove.map((name) => name.toLowerCase())) + const kept: Record = {} + for (const [name, value] of Object.entries(headers)) { + if (!drop.has(name.toLowerCase())) kept[name] = value + } + return kept +} + +interface RedirectHopPolicy { + /** Method for the next hop. */ + method: string + /** Whether the body β€” and the entity headers describing it β€” must be dropped. */ + dropBody: boolean +} + +/** + * Decides how a request may be replayed on a redirect target, per RFC 9110 section 15.4. + * + * `HEAD` is deliberately preserved on 303. Fetch only changes a 303 to GET when the + * current method is neither GET nor HEAD. + */ +function resolveRedirectHop(args: { status: number; method: string }): RedirectHopPolicy { + const method = args.method.toUpperCase() + const isGetOrHead = method === 'GET' || method === 'HEAD' + const dropBody = + (args.status === 303 && !isGetOrHead) || + ((args.status === 301 || args.status === 302) && method === 'POST') + return { + method: dropBody ? 'GET' : method, + dropBody, + } +} + +const CROSS_ORIGIN_CREDENTIAL_HEADERS = ['authorization', 'proxy-authorization', 'cookie'] as const + /** * Manual, revalidating redirect follower used by the guarded fetch. Auto-follow * is unsafe here on two counts the connect-time lookup cannot cover: IP-literal @@ -574,32 +629,24 @@ export async function followRedirectsGuarded( } const nextUrl = new URL(location, currentUrl) assertGuardedRedirectTarget(nextUrl, options?.allowRedirectToIp) - // Per the fetch spec: 303 (and 301/302 on POST) switch to a bodyless GET, dropping - // the entity headers that described the removed body (a retained Content-Length / - // Content-Type on a bodyless GET is malformed and undici rejects it). - if (status === 303 || ((status === 301 || status === 302) && method === 'POST')) { - method = 'GET' - body = undefined - if (headers !== undefined) { - const sanitized = new Headers(headers as HeadersInit) - sanitized.delete('content-length') - sanitized.delete('content-type') - sanitized.delete('content-encoding') - sanitized.delete('transfer-encoding') - // double-cast-allowed: Headers is a valid undici HeadersInit at runtime but the DOM/undici types differ - headers = sanitized as unknown as UndiciRequestInit['headers'] - } - } + const hopPolicy = resolveRedirectHop({ + status, + method, + }) + method = hopPolicy.method + if (hopPolicy.dropBody) body = undefined if (nextUrl.origin !== currentUrl.origin) { headers = undefined - // 307/308 preserve method+body; forwarding a body cross-origin can hand OAuth - // client secrets / tokens to an open-redirect target now that redirects really - // dial the new origin. No legitimate MCP/OAuth flow does this β€” refuse it. if (body !== undefined && body !== null) { throw new Error( 'Blocked by SSRF policy: cross-origin redirect would forward a request body' ) } + } else if (hopPolicy.dropBody && headers !== undefined) { + const sanitized = new Headers(headers as HeadersInit) + for (const name of ENTITY_HEADERS) sanitized.delete(name) + // double-cast-allowed: Headers is a valid undici HeadersInit at runtime but the DOM/undici types differ + headers = sanitized as unknown as UndiciRequestInit['headers'] } currentUrl = nextUrl } @@ -1018,12 +1065,41 @@ export async function secureFetchWithPinnedIP( settledReject(new Error(`Redirect blocked: ${validation.error}`)) return } - const redirectOptions = options.stripAuthOnRedirect - ? { - ...options, - headers: omit(options.headers ?? {}, ['Authorization', 'authorization']), - } - : options + const redirectPolicy = options.redirectPolicy + const hop = + redirectPolicy?.mode === 'standard' + ? resolveRedirectHop({ status: statusCode, method: options.method ?? 'GET' }) + : { method: options.method ?? 'GET', dropBody: false } + const isCrossOrigin = new URL(redirectUrl).origin !== parsed.origin + let redirectHeaders = options.headers + if (redirectHeaders && hop.dropBody) { + redirectHeaders = stripHeaders(redirectHeaders, ENTITY_HEADERS) + } + if ( + redirectHeaders && + redirectPolicy && + isCrossOrigin && + (redirectPolicy.mode === 'standard' || + !redirectPolicy.sendCredentialsOnCrossOriginRedirect) + ) { + const sensitiveHeaders = redirectPolicy.sendCredentialsOnCrossOriginRedirect + ? ['host'] + : [ + 'host', + ...CROSS_ORIGIN_CREDENTIAL_HEADERS, + ...(redirectPolicy.sensitiveHeaders ?? []), + ] + redirectHeaders = stripHeaders(redirectHeaders, sensitiveHeaders) + } + if (redirectHeaders && options.stripAuthOnRedirect) { + redirectHeaders = stripHeaders(redirectHeaders, ['authorization']) + } + const redirectOptions: SecureFetchOptions & { allowHttp?: boolean } = { + ...options, + method: hop.method, + body: hop.dropBody ? undefined : options.body, + headers: redirectHeaders, + } return secureFetchWithPinnedIP( redirectUrl, validation.resolvedIP!, diff --git a/apps/sim/lib/core/security/pinned-redirect-replay.server.test.ts b/apps/sim/lib/core/security/pinned-redirect-replay.server.test.ts new file mode 100644 index 00000000000..5d0141add32 --- /dev/null +++ b/apps/sim/lib/core/security/pinned-redirect-replay.server.test.ts @@ -0,0 +1,341 @@ +/** + * Pins both outbound redirect contracts: historical replay for persisted workflows and + * standards-compatible behavior for newly created API blocks. + * + * @vitest-environment node + */ +import http from 'node:http' +import type { AddressInfo } from 'node:net' +import { afterEach, describe, expect, it, vi } from 'vitest' + +vi.mock('@sim/security/dns', () => ({ + resolveHostAddresses: vi.fn(async () => ({ addresses: ['127.0.0.1'] })), + preferIpv4: (addresses: string[]) => addresses[0], +})) + +vi.mock('@/lib/core/config/env-flags', () => ({ + isHosted: false, + isPrivateDatabaseHostsAllowed: false, + getProxyUrl: () => undefined, +})) + +import { secureFetchWithPinnedIP } from '@/lib/core/security/input-validation.server' + +interface RecordedHop { + method: string + body: string + headers: http.IncomingHttpHeaders +} + +const servers: http.Server[] = [] + +afterEach(() => { + for (const server of servers.splice(0)) server.close() +}) + +async function startServer(handler: http.RequestListener): Promise { + const server = http.createServer(handler) + servers.push(server) + await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)) + return `http://127.0.0.1:${(server.address() as AddressInfo).port}` +} + +/** Records every request it receives, then answers 200. */ +async function startRecordingServer(hops: RecordedHop[]): Promise { + return startServer((req, res) => { + let body = '' + req.on('data', (chunk) => { + body += chunk + }) + req.on('end', () => { + hops.push({ method: req.method ?? '', body, headers: req.headers }) + res.writeHead(200, { 'Content-Type': 'application/json' }) + res.end('{"ok":true}') + }) + }) +} + +describe('secureFetchWithPinnedIP redirect replay', () => { + it('preserves historical replay when no redirect policy is present', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(303, { location: `${target}/after` }) + res.end() + }) + + const response = await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"message":"legacy"}', + headers: { + Authorization: 'Bearer legacy-token', + 'Content-Type': 'application/json', + Host: 'legacy.example', + }, + allowHttp: true, + }) + + expect(response.status).toBe(200) + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('POST') + expect(hops[0].body).toBe('{"message":"legacy"}') + expect(hops[0].headers.authorization).toBe('Bearer legacy-token') + expect(hops[0].headers.host).toBe('legacy.example') + }) + + it('lets a legacy block withhold credentials without changing its replay semantics', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(303, { location: `${target}/after` }) + res.end() + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"message":"legacy"}', + headers: { + Authorization: 'Bearer strip-me', + 'Content-Type': 'application/json', + 'X-Api-Key': 'strip-me-too', + 'X-Trace': 'keep-me', + }, + redirectPolicy: { + mode: 'legacy', + sendCredentialsOnCrossOriginRedirect: false, + sensitiveHeaders: ['x-api-key'], + }, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('POST') + expect(hops[0].body).toBe('{"message":"legacy"}') + expect(hops[0].headers.authorization).toBeUndefined() + expect(hops[0].headers['x-api-key']).toBeUndefined() + expect(hops[0].headers['content-type']).toBe('application/json') + expect(hops[0].headers['x-trace']).toBe('keep-me') + }) + + it('uses Fetch-compatible POST handling for a standard 303', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(303, { location: `${target}/after` }) + res.end() + }) + + const response = await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"message":"standard"}', + headers: { + Authorization: 'Bearer secret-token', + 'Content-Type': 'application/json', + Host: 'origin.example', + 'X-Api-Key': 'secret-key', + 'X-Trace': 'keep-me', + }, + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: false, + sensitiveHeaders: ['x-api-key'], + }, + allowHttp: true, + }) + + expect(response.status).toBe(200) + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('GET') + expect(hops[0].body).toBe('') + expect(hops[0].headers.authorization).toBeUndefined() + expect(hops[0].headers['content-type']).toBeUndefined() + expect(hops[0].headers['content-length']).toBeUndefined() + expect(hops[0].headers['content-language']).toBeUndefined() + expect(hops[0].headers['x-api-key']).toBeUndefined() + expect(hops[0].headers['x-trace']).toBe('keep-me') + expect(hops[0].headers.host).not.toBe('origin.example') + }) + + it('changes a standard POST to a bodyless GET on 301', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(301, { location: `${target}/after` }) + res.end() + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"message":"standard"}', + headers: { + 'Content-Type': 'application/json', + 'Content-Language': 'en', + }, + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: false, + }, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('GET') + expect(hops[0].body).toBe('') + expect(hops[0].headers['content-type']).toBeUndefined() + expect(hops[0].headers['content-language']).toBeUndefined() + }) + + it('keeps HEAD as HEAD on a standard 303', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(303, { location: `${target}/after` }) + res.end() + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'HEAD', + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: false, + }, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('HEAD') + }) + + it('preserves a standard 307 body while withholding cross-origin credentials', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(307, { location: `${target}/after` }) + res.end() + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"payload":"keep"}', + headers: { + Authorization: 'Bearer strip-me', + 'Content-Type': 'application/json', + 'X-Trace': 'keep-me', + }, + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: false, + }, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('POST') + expect(hops[0].body).toBe('{"payload":"keep"}') + expect(hops[0].headers.authorization).toBeUndefined() + expect(hops[0].headers['content-type']).toBe('application/json') + expect(hops[0].headers['x-trace']).toBe('keep-me') + }) + + it('allows an explicit standard-policy credential opt-in', async () => { + const hops: RecordedHop[] = [] + const target = await startRecordingServer(hops) + const origin = await startServer((req, res) => { + req.resume() + res.writeHead(307, { location: `${target}/after` }) + res.end() + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"payload":"keep"}', + headers: { Authorization: 'Bearer keep-me', Host: 'origin.example' }, + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: true, + }, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].headers.authorization).toBe('Bearer keep-me') + expect(hops[0].headers.host).not.toBe('origin.example') + }) + + it('preserves method, body and headers on a same-origin standard 307', async () => { + const hops: RecordedHop[] = [] + let redirected = false + const origin = await startServer((req, res) => { + if (!redirected) { + redirected = true + req.resume() + res.writeHead(307, { location: '/after' }) + res.end() + return + } + let body = '' + req.on('data', (chunk) => { + body += chunk + }) + req.on('end', () => { + hops.push({ method: req.method ?? '', body, headers: req.headers }) + res.writeHead(200, { 'Content-Type': 'application/json' }) + res.end('{"ok":true}') + }) + }) + + const response = await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'POST', + body: '{"keep":"me"}', + headers: { Authorization: 'Bearer same-origin-ok' }, + redirectPolicy: { + mode: 'standard', + sendCredentialsOnCrossOriginRedirect: false, + }, + allowHttp: true, + }) + + expect(response.status).toBe(200) + expect(hops).toHaveLength(1) + expect(hops[0].method).toBe('POST') + expect(hops[0].body).toBe('{"keep":"me"}') + expect(hops[0].headers.authorization).toBe('Bearer same-origin-ok') + }) + + it('honours stripAuthOnRedirect on a same-origin hop', async () => { + const hops: RecordedHop[] = [] + let redirected = false + const origin = await startServer((req, res) => { + if (!redirected) { + redirected = true + req.resume() + res.writeHead(302, { location: '/after' }) + res.end() + return + } + req.resume() + req.on('end', () => { + hops.push({ method: req.method ?? '', body: '', headers: req.headers }) + res.writeHead(200, {}) + res.end('ok') + }) + }) + + await secureFetchWithPinnedIP(origin, '127.0.0.1', { + method: 'GET', + headers: { Authorization: 'Bearer strip-me', 'X-Trace': 'keep-me' }, + stripAuthOnRedirect: true, + allowHttp: true, + }) + + expect(hops).toHaveLength(1) + expect(hops[0].headers.authorization).toBeUndefined() + expect(hops[0].headers['x-trace']).toBe('keep-me') + }) +}) diff --git a/apps/sim/lib/core/security/ssrf-guarded-lookup.test.ts b/apps/sim/lib/core/security/ssrf-guarded-lookup.test.ts index c2b593ebbf1..7a59c48727e 100644 --- a/apps/sim/lib/core/security/ssrf-guarded-lookup.test.ts +++ b/apps/sim/lib/core/security/ssrf-guarded-lookup.test.ts @@ -188,6 +188,15 @@ describe('followRedirectsGuarded', () => { expect(raw.mock.calls[1][1].body).toBeUndefined() }) + it('keeps HEAD as HEAD on 303', async () => { + const raw = vi + .fn() + .mockResolvedValueOnce(redirectTo('https://a.example/next', 303)) + .mockResolvedValueOnce(new Response(null, { status: 200 })) + await followRedirectsGuarded(raw, 'https://a.example/x', { method: 'HEAD' }) + expect(raw.mock.calls[1][1].method).toBe('HEAD') + }) + it('preserves method and body on 307', async () => { const raw = vi .fn() diff --git a/apps/sim/tools/generated/tool-metadata.ts b/apps/sim/tools/generated/tool-metadata.ts index 039e10e85a6..dd92b548717 100644 --- a/apps/sim/tools/generated/tool-metadata.ts +++ b/apps/sim/tools/generated/tool-metadata.ts @@ -3,7 +3,7 @@ /** Serializable metadata for every built-in tool, keyed by tool id. */ const toolMetadata: Record = JSON.parse( - '{"a2a_cancel_task":{"id":"a2a_cancel_task","name":"A2A Cancel Task","description":"Request cancellation of an in-progress A2A task.","version":"1.0.0","params":{"agentUrl":{"type":"string","required":true,"visibility":"user-only","description":"The A2A agent endpoint URL"},"taskId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The task ID to cancel"},"apiKey":{"type":"string","required":false,"visibility":"user-only","description":"API key for authentication (if required)"}}},"a2a_get_agent_card":{"id":"a2a_get_agent_card","name":"A2A Get Agent Card","description":"Fetch the Agent Card (discovery document) for an external A2A agent.","version":"1.0.0","params":{"agentUrl":{"type":"string","required":true,"visibility":"user-only","description":"The A2A agent endpoint URL"},"apiKey":{"type":"string","required":false,"visibility":"user-only","description":"API key for authentication (if required)"}}},"a2a_get_task":{"id":"a2a_get_task","name":"A2A Get Task","description":"Retrieve the current state and result of an A2A task.","version":"1.0.0","params":{"agentUrl":{"type":"string","required":true,"visibility":"user-only","description":"The A2A agent endpoint URL"},"taskId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The task ID to retrieve"},"historyLength":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of history messages to include"},"apiKey":{"type":"string","required":false,"visibility":"user-only","description":"API key for authentication (if required)"}}},"a2a_send_message":{"id":"a2a_send_message","name":"A2A Send Message","description":"Send a message to an external A2A agent and return its response.","version":"1.0.0","params":{"agentUrl":{"type":"string","required":true,"visibility":"user-only","description":"The A2A agent endpoint URL"},"message":{"type":"string","required":true,"visibility":"user-or-llm","description":"The message text to send"},"data":{"type":"json","required":false,"visibility":"user-or-llm","description":"Optional structured JSON data to attach"},"files":{"type":"json","required":false,"visibility":"user-or-llm","description":"Optional files to attach"},"taskId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Existing task ID to continue"},"contextId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Conversation context ID to continue"},"apiKey":{"type":"string","required":false,"visibility":"user-only","description":"API key for authentication (if required)"}}},"affinity_batch_update_entity_fields":{"id":"affinity_batch_update_entity_fields","name":"Affinity Batch Update Entity Fields","description":"Write up to 100 non-list field values on one company or person in a single request.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to write the fields on: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"updates":{"type":"json","required":true,"visibility":"user-or-llm","description":"Up to 100 field updates as [{\\"id\\":\\"\\",\\"value\\":{\\"type\\":\\"…\\",\\"data\\":…}}], using the same value shapes as a single field update"}}},"affinity_batch_update_list_entry_fields":{"id":"affinity_batch_update_list_entry_fields","name":"Affinity Batch Update List Entry Fields","description":"Write up to 100 field values on one list row in a single request. Requires the \\"Export data from Lists\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"updates":{"type":"json","required":true,"visibility":"user-or-llm","description":"Up to 100 field updates as [{\\"id\\":\\"\\",\\"value\\":{\\"type\\":\\"…\\",\\"data\\":…}}], using the same value shapes as a single field update"}}},"affinity_create_list":{"id":"affinity_create_list","name":"Affinity Create List","description":"Create a list. Its type fixes which entities it can hold, and the API key holder becomes its creator and owner.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the new list"},"type":{"type":"string","required":true,"visibility":"user-or-llm","description":"Entity kind the list holds: company, opportunity, or person"},"isPublic":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Whether everyone in the organization can see the list"}}},"affinity_create_list_field_dropdown_option":{"id":"affinity_create_list_field_dropdown_option","name":"Affinity Create List Field Dropdown Option","description":"Add a selectable option to a dropdown field on a list. A ranked or status option also needs a rank and a color.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown field ID on that list"},"type":{"type":"string","required":true,"visibility":"user-or-llm","description":"Kind of option to create, matching the field. dropdown takes only a label; ranked-dropdown also requires rank and color; status-dropdown additionally requires a status category. Sending a field the kind does not accept is rejected"},"text":{"type":"string","required":true,"visibility":"user-or-llm","description":"The option label"},"rank":{"type":"number","required":false,"visibility":"user-or-llm","description":"Sort order. Required on a ranked-dropdown or status-dropdown option"},"color":{"type":"string","required":false,"visibility":"user-or-llm","description":"Option color: white, gray, blue, green, purple, orange, or red. Required on a ranked-dropdown or status-dropdown option"},"statusCategory":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pipeline meaning of the option: open, won, lost, or on-hold. Status-dropdown options only"},"winRate":{"type":"number","required":false,"visibility":"user-or-llm","description":"Expected win rate of the status. Status-dropdown options only"}}},"affinity_create_merge":{"id":"affinity_create_merge","name":"Affinity Create Merge","description":"Fold a duplicate company or person into the record you are keeping. The merge runs asynchronously β€” poll the returned task to see it finish. Requires the \\"Manage duplicates\\" permission and an admin role.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"What to merge: companies or persons"},"primaryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to keep"},"duplicateId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the duplicate record to fold in"}}},"affinity_create_note":{"id":"affinity_create_note","name":"Affinity Create Note","description":"Write a note β€” attached to companies, persons, and opportunities, anchored to a meeting, call, or chat message, or posted as a reply to an existing note.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"type":{"type":"string","required":true,"visibility":"user-or-llm","description":"Note shape: entities to attach it to records, interaction to anchor it to a meeting, call, or chat message, or user-reply to reply to a note"},"html":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note body as HTML"},"companyIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Companies to attach the note to, e.g. [1, 2]. Not used on a reply"},"personIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Persons to attach the note to, e.g. [1, 2]. Not used on a reply"},"opportunityIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Opportunities to attach the note to, e.g. [1, 2]. Not used on a reply"},"interactionId":{"type":"string","required":false,"visibility":"user-or-llm","description":"The interaction to anchor the note to. Required for an interaction note"},"interactionType":{"type":"string","required":false,"visibility":"user-or-llm","description":"Kind of the anchoring interaction: meeting, call, or chat-message. Required for an interaction note"},"parentId":{"type":"string","required":false,"visibility":"user-or-llm","description":"The note being replied to. Required for a user-reply note"},"creatorId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Attribute the note to another internal person. Defaults to the API key holder"},"createdAt":{"type":"string","required":false,"visibility":"user-or-llm","description":"Backdate the note to this ISO 8601 timestamp"}}},"affinity_create_reminder":{"id":"affinity_create_reminder","name":"Affinity Create Reminder","description":"Create a reminder on one company, person, or opportunity. A recurring reminder resets whenever the chosen signal happens instead of firing once.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"type":{"type":"string","required":true,"visibility":"user-or-llm","description":"one-time to fire once, or recurring to reset on a signal"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"What the reminder is about: company, person, or opportunity"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company, person, or opportunity"},"dueDate":{"type":"string","required":false,"visibility":"user-or-llm","description":"When the reminder is due, as an ISO 8601 timestamp. Required for a one-time reminder; on a recurring one Affinity computes it from the period when omitted"},"content":{"type":"string","required":false,"visibility":"user-or-llm","description":"What the reminder says"},"ownerId":{"type":"string","required":true,"visibility":"user-or-llm","description":"User the reminder is assigned to. Must be an internal user. The API key holder is recorded as the creator, which is a separate field"},"resetTrigger":{"type":"string","required":false,"visibility":"user-or-llm","description":"What restarts a recurring reminder: interaction, email, or event. Required when the type is recurring"},"periodDays":{"type":"number","required":false,"visibility":"user-or-llm","description":"Days between firings of a recurring reminder. Required when the type is recurring"}}},"affinity_delete_list_field_dropdown_option":{"id":"affinity_delete_list_field_dropdown_option","name":"Affinity Delete List Field Dropdown Option","description":"Permanently delete a dropdown option on a list field. Every list entry currently set to it is cleared, and those values cannot be recovered.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown field ID on that list"},"dropdownOptionId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown option ID to delete"}}},"affinity_delete_note":{"id":"affinity_delete_note","name":"Affinity Delete Note","description":"Delete a note you created. Deleting a root note also deletes its replies; deleting a reply removes only that reply.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID to delete"}}},"affinity_get_company":{"id":"affinity_get_company","name":"Affinity Get Company","description":"Look up one company by ID. Field data is returned only for the Field IDs or Field Types asked for.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"companyId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The company ID"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"}}},"affinity_get_current_user":{"id":"affinity_get_current_user","name":"Affinity Get Current User","description":"Verify an Affinity API key and return the tenant, the user behind the key, and the scopes the grant carries.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"}}},"affinity_get_entity_field_value":{"id":"affinity_get_entity_field_value","name":"Affinity Get Entity Field Value","description":"Read one non-list field value from a company or person.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to read the field from: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The field ID to read"}}},"affinity_get_list":{"id":"affinity_get_list","name":"Affinity Get List","description":"Read one list β€” its name, type, owner, and privacy setting.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"}}},"affinity_get_list_entry":{"id":"affinity_get_list_entry","name":"Affinity Get List Entry","description":"Read one row of a list with its entity. Field data is returned only for the Field IDs or Field Types asked for.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, list, or relationship-intelligence. Mutually exclusive with Field IDs"}}},"affinity_get_list_entry_field":{"id":"affinity_get_list_entry_field","name":"Affinity Get List Entry Field","description":"Read one field value on a list row.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The field ID to read"}}},"affinity_get_list_field_dropdown_option":{"id":"affinity_get_list_field_dropdown_option","name":"Affinity Get List Field Dropdown Option","description":"Read one dropdown option on a list field.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown field ID on that list"},"dropdownOptionId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown option ID"}}},"affinity_get_merge":{"id":"affinity_get_merge","name":"Affinity Get Merge","description":"Read the status of one company or person merge, including why it failed if it did.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which merge to read: companies or persons"},"mergeId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The merge ID"}}},"affinity_get_merge_task":{"id":"affinity_get_merge_task","name":"Affinity Get Merge Task","description":"Read one merge task and how its merges are progressing. Poll this after starting a merge.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which merge task to read: companies or persons"},"taskId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The merge task ID"}}},"affinity_get_note":{"id":"affinity_get_note","name":"Affinity Get Note","description":"Read one note with its body, author, mentions, and attached records.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID"},"includes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Extra properties to return, e.g. [\\"repliesCount\\",\\"personsPreview\\",\\"companiesPreview\\",\\"opportunitiesPreview\\"]. Those four fields are omitted unless requested here"}}},"affinity_get_opportunity":{"id":"affinity_get_opportunity","name":"Affinity Get Opportunity","description":"Read one opportunity and the list it belongs to. Its field data lives on the list entry.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"opportunityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The opportunity ID"}}},"affinity_get_person":{"id":"affinity_get_person","name":"Affinity Get Person","description":"Look up one person by ID. Field data is returned only for the Field IDs or Field Types asked for.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"personId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The person ID"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"}}},"affinity_get_saved_view":{"id":"affinity_get_saved_view","name":"Affinity Get Saved View","description":"Read one saved view β€” its name, kind, and creation date.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"viewId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The saved view ID"}}},"affinity_get_transcript":{"id":"affinity_get_transcript","name":"Affinity Get Transcript","description":"Read one transcript with its first 100 fragments. Page the fragments endpoint for a longer meeting.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"transcriptId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The transcript ID"}}},"affinity_get_user":{"id":"affinity_get_user","name":"Affinity Get User","description":"Read one internal user. A user and their person record share the same numeric ID, so a person ID works here.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"userId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The user ID, which is also their person ID"}}},"affinity_list_calls":{"id":"affinity_list_calls","name":"Affinity List Calls","description":"Page through logged calls and their participants. Only calls the API key holder can see are returned.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_chat_messages":{"id":"affinity_list_chat_messages","name":"Affinity List Chat Messages","description":"Page through logged chat messages and their participants. Only messages the API key holder can see are returned.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_companies":{"id":"affinity_list_companies","name":"Affinity List Companies","description":"Page through companies. Companies come back without field data unless Field IDs or Field Types asks for it.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the page to these company IDs, e.g. [1, 2, 3]"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_coworker_connections":{"id":"affinity_list_coworker_connections","name":"Affinity List Coworker Connections","description":"Find warm paths into a company through shared work history: who in your Affinity data once worked alongside the people you want to reach. Grouped by target, strongest first.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":true,"visibility":"user-or-llm","description":"Required scope. The only supported filter is target.currentCompany.id, e.g. \\"target.currentCompany.id=123\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of targets to return per page, 1-50. Defaults to 20"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_emails":{"id":"affinity_list_emails","name":"Affinity List Emails","description":"Page through email metadata β€” subject, participants, and timestamps. Affinity never exposes email bodies through the API.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_entity_field_values":{"id":"affinity_list_entity_field_values","name":"Affinity List Entity Field Values","description":"Page through a company\'s or person\'s non-list field values. List fields are not returned here β€” read those through the list entry.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to read field values from: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict to these field IDs. Mutually exclusive with Field Types"},"types":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict to these field categories: enriched, global, relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 20"}}},"affinity_list_entity_list_entries":{"id":"affinity_list_entity_list_entries","name":"Affinity List Entity List Entries","description":"Page through a company\'s or person\'s rows across every list, each carrying that list\'s field values and when the entity was added.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to look up the rows of: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_entity_lists":{"id":"affinity_list_entity_lists","name":"Affinity List Entity Lists","description":"List every list a company or person appears on that the caller can view.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to look up the lists of: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_entity_notes":{"id":"affinity_list_entity_notes","name":"Affinity List Entity Notes","description":"List the notes relevant to one company, person, or opportunity β€” directly attached notes plus notes reaching it through its people and meetings.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity the notes hang off: companies, persons, or opportunities"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company, person, or opportunity"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_entity_relationships":{"id":"affinity_list_entity_relationships","name":"Affinity List Entity Relationships","description":"List who knows a company or person, scored 0.0 to 1.0 by how much the two actually interact. Strongest first by default.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to look up relationships for: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression. This endpoint filters on interactionScore only, e.g. \\"interactionScore>=0.5\\""},"orderBy":{"type":"json","required":false,"visibility":"user-or-llm","description":"Sort order: [\\"interactionScore\\"] for weakest first, [\\"-interactionScore\\"] for strongest first (the default)"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_field_dropdown_options":{"id":"affinity_list_field_dropdown_options","name":"Affinity List Field Dropdown Options","description":"List the selectable options on a dropdown or ranked-dropdown company or person field. Writing such a field needs the option ID, not its text.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which field family the field belongs to: companies or persons"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown or ranked-dropdown field ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_field_metadata":{"id":"affinity_list_field_metadata","name":"Affinity List Field Metadata","description":"List the non-list company or person fields, with the value type, filter operators, and sort support of each. Start here to find the Field IDs the read and write tools take.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which fields to describe: companies or persons"},"includes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Extra properties to return: [\\"filterability\\",\\"sortability\\"]. Both are omitted unless requested here"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression. This endpoint filters on name only, e.g. \\"name=~Status\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_field_value_changes":{"id":"affinity_list_field_value_changes","name":"Affinity List Field Value Changes","description":"Page through field value changes across the whole workspace. Built for delta sync: follow nextCursor to the end of a run, then resume from the last cursor next time.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression over field.id, listEntry.id, changer.id, changedAt, or actionType. Resume a sync with e.g. \\"changedAt>2026-06-01T12:00:00Z\\""},"orderBy":{"type":"json","required":false,"visibility":"user-or-llm","description":"Sort order: [\\"changedAt\\"] for oldest first (the default), [\\"-changedAt\\"] for newest first"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_investor_executive_connections":{"id":"affinity_list_investor_executive_connections","name":"Affinity List Investor Executive Connections","description":"Find warm paths into a company through investment history: which investors in your Affinity data backed a company the people you want to reach once led. Grouped by target, strongest first.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":true,"visibility":"user-or-llm","description":"Required scope. The only supported filter is target.currentCompany.id, e.g. \\"target.currentCompany.id=123\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of targets to return per page, 1-50. Defaults to 20"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_list_entries":{"id":"affinity_list_list_entries","name":"Affinity List List Entries","description":"Page through the rows of a list. Rows come back without field data unless Field IDs or Field Types asks for it.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, list, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_list_entry_field_value_changes":{"id":"affinity_list_list_entry_field_value_changes","name":"Affinity List List Entry Field Value Changes","description":"Page through the history of one list row β€” who changed which field, when, and to what.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression over field.id, changer.id, changedAt, or actionType, e.g. \\"field.id=field-1234\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_list_entry_fields":{"id":"affinity_list_list_entry_fields","name":"Affinity List List Entry Fields","description":"Page through every field value on one list row, including the list-specific columns. All fields are returned unless narrowed.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict to these field IDs. Mutually exclusive with Field Types"},"types":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict to these field categories: enriched, global, list, relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 20"}}},"affinity_list_list_field_dropdown_options":{"id":"affinity_list_list_field_dropdown_options","name":"Affinity List List Field Dropdown Options","description":"List the selectable options on a dropdown, ranked-dropdown, or status-dropdown field of a list.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown field ID on that list"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_list_fields":{"id":"affinity_list_list_fields","name":"Affinity List List Fields","description":"List the fields available on one list, including its list-specific columns. Use these Field IDs when reading or writing list entries.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"includes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Extra properties to return: [\\"filterability\\",\\"sortability\\"]. Both are omitted unless requested here"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression. This endpoint filters on name only, e.g. \\"name=~Stage\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_lists":{"id":"affinity_list_lists","name":"Affinity List Lists","description":"Page through the lists in the organization that the caller can view.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"term":{"type":"string","required":false,"visibility":"user-or-llm","description":"Case-insensitive substring match on the list name"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_meetings":{"id":"affinity_list_meetings","name":"Affinity List Meetings","description":"Page through past and upcoming meetings with their organizer and attendees.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_merge_tasks":{"id":"affinity_list_merge_tasks","name":"Affinity List Merge Tasks","description":"Page through merge tasks, each summarizing how many of its merges are in progress, succeeded, or failed.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which merge tasks to list: companies or persons"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression. This endpoint filters on status only, e.g. \\"status=in-progress\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_merges":{"id":"affinity_list_merges","name":"Affinity List Merges","description":"Page through the company or person merges the organization has run, with the status and the records involved in each.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which merges to list: companies or persons"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression over status or taskId, e.g. \\"status=failed\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_note_attached_companies":{"id":"affinity_list_note_attached_companies","name":"Affinity List Note Attached Companies","description":"List the companies directly attached to one note.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_note_attached_opportunities":{"id":"affinity_list_note_attached_opportunities","name":"Affinity List Note Attached Opportunities","description":"List the opportunities directly attached to one note.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_note_attached_persons":{"id":"affinity_list_note_attached_persons","name":"Affinity List Note Attached Persons","description":"List the persons directly attached to one note.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_note_replies":{"id":"affinity_list_note_replies","name":"Affinity List Note Replies","description":"Page through the replies on one note, including AI Notetaker replies.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID whose replies to read"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_notes":{"id":"affinity_list_notes","name":"Affinity List Notes","description":"Page through every note the caller can see. Replies are excluded.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"includes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Extra properties to return, e.g. [\\"repliesCount\\",\\"personsPreview\\",\\"companiesPreview\\",\\"opportunitiesPreview\\"]. Those four fields are omitted unless requested here"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_opportunities":{"id":"affinity_list_opportunities","name":"Affinity List Opportunities","description":"Page through opportunities. Field data lives on the list entry, not here β€” read it through the list or saved view the opportunity belongs to.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the page to these opportunity IDs, e.g. [1, 2, 3]"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_persons":{"id":"affinity_list_persons","name":"Affinity List Persons","description":"Page through persons. Persons come back without field data unless Field IDs or Field Types asks for it.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the page to these person IDs, e.g. [1, 2, 3]"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_reminders":{"id":"affinity_list_reminders","name":"Affinity List Reminders","description":"Page through the reminders the caller can see. Filter by status to surface what is overdue.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_saved_view_entries":{"id":"affinity_list_saved_view_entries","name":"Affinity List Saved View Entries","description":"Page through the rows of a saved view. The view\'s own filters and columns decide which rows and which field data come back.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"viewId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The saved view ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_saved_views":{"id":"affinity_list_saved_views","name":"Affinity List Saved Views","description":"List the saved views on a list that the caller can view.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_list_transcript_fragments":{"id":"affinity_list_transcript_fragments","name":"Affinity List Transcript Fragments","description":"Page through everything said in a meeting, segment by segment with the speaker.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"transcriptId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The transcript ID"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_transcripts":{"id":"affinity_list_transcripts","name":"Affinity List Transcripts","description":"Page through meeting transcript metadata. Read one transcript to get what was actually said.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression, e.g. \\"createdAt>=2026-01-01\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_list_users":{"id":"affinity_list_users","name":"Affinity List Users","description":"Page through the internal users in the organization. Email addresses and roles are returned only to callers with the \\"Manage Users\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"term":{"type":"string","required":false,"visibility":"user-or-llm","description":"Case-insensitive match across first name, last name, and primary email"},"filter":{"type":"string","required":false,"visibility":"user-or-llm","description":"Affinity Filtering Language expression over id or status, e.g. \\"status=active\\""},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"}}},"affinity_search_companies":{"id":"affinity_search_companies","name":"Affinity Search Companies","description":"Search companies by filters, sorts, and a free-text term. Requires the \\"Export All Organizations directory\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Filter group as {operator: \\"and\\"|\\"or\\", filters: [...]}, at most 50 leaves. Each leaf is {valueType, fieldId, operator, value}, and a leaf may itself be a nested group"},"searchTerm":{"type":"string","required":false,"visibility":"user-or-llm","description":"Free-text term matched against the searchable fields. At least 3 characters"},"searchFieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs the search term is matched against. Defaults to the searchable fields"},"sorts":{"type":"json","required":false,"visibility":"user-or-llm","description":"Sort order as [{fieldId, direction: \\"asc\\"|\\"desc\\", attributeId?}], up to 5, applied in order"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_search_files":{"id":"affinity_search_files","name":"Affinity Search Files","description":"Search files by keyword, ordered by relevance. Narrow to specific files or to one company, or leave both unset to search the whole account.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"prompt":{"type":"string","required":true,"visibility":"user-or-llm","description":"What to search for. Between 3 and 500 characters"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the search to these file IDs. Cannot be combined with Company ID"},"companyId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Restrict the search to one company\'s files. Cannot be combined with file IDs"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of files to return, 1-100. Defaults to 20"}}},"affinity_search_list_entries":{"id":"affinity_search_list_entries","name":"Affinity Search List Entries","description":"Search the rows of one list by filters, sorts, and a free-text term. Requires the \\"Export data from Lists\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID to search"},"filters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Filter group as {operator: \\"and\\"|\\"or\\", filters: [...]}, at most 50 leaves. Each leaf is {valueType, fieldId, operator, value}, and a leaf may itself be a nested group"},"searchTerm":{"type":"string","required":false,"visibility":"user-or-llm","description":"Free-text term matched against the searchable fields. At least 3 characters"},"searchFieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs the search term is matched against. Defaults to the searchable fields"},"sorts":{"type":"json","required":false,"visibility":"user-or-llm","description":"Sort order as [{fieldId, direction: \\"asc\\"|\\"desc\\", attributeId?}], up to 5, applied in order"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, list, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_search_notes":{"id":"affinity_search_notes","name":"Affinity Search Notes","description":"Search notes by keyword, ordered by relevance. Narrow to specific notes or to one company, or leave both unset to search the whole account.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"prompt":{"type":"string","required":true,"visibility":"user-or-llm","description":"What to search for. Between 3 and 500 characters"},"ids":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the search to these note IDs. Cannot be combined with Company ID"},"companyId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Restrict the search to one company\'s notes. Cannot be combined with note IDs"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of notes to return, 1-100. Defaults to 20"}}},"affinity_search_persons":{"id":"affinity_search_persons","name":"Affinity Search Persons","description":"Search persons by filters, sorts, and a free-text term. Requires the \\"Export All People directory\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"filters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Filter group as {operator: \\"and\\"|\\"or\\", filters: [...]}, at most 50 leaves. Each leaf is {valueType, fieldId, operator, value}, and a leaf may itself be a nested group"},"searchTerm":{"type":"string","required":false,"visibility":"user-or-llm","description":"Free-text term matched against the searchable fields. At least 3 characters"},"searchFieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs the search term is matched against. Defaults to the searchable fields"},"sorts":{"type":"json","required":false,"visibility":"user-or-llm","description":"Sort order as [{fieldId, direction: \\"asc\\"|\\"desc\\", attributeId?}], up to 5, applied in order"},"fieldIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field IDs to return values for, e.g. [\\"affinity-data-location\\"]. Mutually exclusive with Field Types"},"fieldTypes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Field categories to return values for: enriched, global, or relationship-intelligence. Mutually exclusive with Field IDs"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous page, returned as nextCursor or prevCursor"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to return per page, 1-100. Defaults to 100"},"totalCount":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the total size of the collection. Costs an extra query"}}},"affinity_semantic_search":{"id":"affinity_semantic_search","name":"Affinity Semantic Search","description":"Find companies from a description in plain language β€” industry, technology, stage, or business model. Currently searches companies only.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"prompt":{"type":"string","required":true,"visibility":"user-or-llm","description":"What to look for, in plain language, e.g. \\"climate tech companies in our pipeline\\". Up to 500 characters"},"listIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Restrict the search to companies on these lists, e.g. [1, 2]"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of companies to return, 1-100. Defaults to 100"}}},"affinity_update_entity_field_value":{"id":"affinity_update_entity_field_value","name":"Affinity Update Entity Field Value","description":"Write one non-list field value on a company or person. The value type must match how the field is defined.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"entityType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Which entity to write the field on: companies or persons"},"entityId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of that company or person"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The field ID to write"},"value":{"type":"json","required":true,"visibility":"user-or-llm","description":"The new value as {type, data}, where type matches the field\'s value type. Examples: {\\"type\\":\\"text\\",\\"data\\":\\"Series B\\"}, {\\"type\\":\\"number\\",\\"data\\":42}, {\\"type\\":\\"dropdown\\",\\"data\\":{\\"dropdownOptionId\\":7}}, {\\"type\\":\\"person\\",\\"data\\":{\\"id\\":123}}, {\\"type\\":\\"person-multi\\",\\"data\\":[{\\"id\\":123}]}. Pass data as null to clear the field"}}},"affinity_update_list_entry_field":{"id":"affinity_update_list_entry_field","name":"Affinity Update List Entry Field","description":"Write one field value on a list row. Requires the \\"Export data from Lists\\" permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"listEntryId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list entry ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The field ID to write"},"value":{"type":"json","required":true,"visibility":"user-or-llm","description":"The new value as {type, data}, where type matches the field\'s value type. Examples: {\\"type\\":\\"text\\",\\"data\\":\\"Series B\\"}, {\\"type\\":\\"number\\",\\"data\\":42}, {\\"type\\":\\"dropdown\\",\\"data\\":{\\"dropdownOptionId\\":7}}, {\\"type\\":\\"person\\",\\"data\\":{\\"id\\":123}}, {\\"type\\":\\"person-multi\\",\\"data\\":[{\\"id\\":123}]}. Pass data as null to clear the field"}}},"affinity_update_list_field_dropdown_option":{"id":"affinity_update_list_field_dropdown_option","name":"Affinity Update List Field Dropdown Option","description":"Change a dropdown option on a list field. Every field is optional β€” supply only what should change, and only fields the option\'s kind actually has.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"listId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The list ID"},"fieldId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown field ID on that list"},"dropdownOptionId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The dropdown option ID to update"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Replacement option label. Supply at least one field to change"},"rank":{"type":"number","required":false,"visibility":"user-or-llm","description":"Sort order. Required on a ranked-dropdown or status-dropdown option"},"color":{"type":"string","required":false,"visibility":"user-or-llm","description":"Option color: white, gray, blue, green, purple, orange, or red. Required on a ranked-dropdown or status-dropdown option"},"statusCategory":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pipeline meaning of the option: open, won, lost, or on-hold. Status-dropdown options only"},"winRate":{"type":"number","required":false,"visibility":"user-or-llm","description":"Expected win rate of the status. Status-dropdown options only"}}},"affinity_update_note":{"id":"affinity_update_note","name":"Affinity Update Note","description":"Rewrite a note\'s body or replace which records it is attached to. Each list of IDs replaces that association wholesale, an empty list clears it, and omitting one leaves it untouched. A note\'s type cannot be changed.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Affinity API key, sent as a bearer token"},"noteId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note ID to update"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"Replacement note body as HTML"},"companyIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Replacement set of attached companies, e.g. [1, 2]. Send [] to detach every company; omit to leave them unchanged"},"personIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Replacement set of attached persons, e.g. [1, 2]. Send [] to detach every person; omit to leave them unchanged"},"opportunityIds":{"type":"json","required":false,"visibility":"user-or-llm","description":"Replacement set of attached opportunities, e.g. [1, 2]. Send [] to detach every opportunity; omit to leave them unchanged"}}},"agentmail_create_draft":{"id":"agentmail_create_draft","name":"Create Draft","description":"Create a new email draft in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to create the draft in"},"to":{"type":"string","required":false,"visibility":"user-or-llm","description":"Recipient email addresses (comma-separated)"},"subject":{"type":"string","required":false,"visibility":"user-or-llm","description":"Draft subject line"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Plain text draft body"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"HTML draft body"},"cc":{"type":"string","required":false,"visibility":"user-or-llm","description":"CC recipient email addresses (comma-separated)"},"bcc":{"type":"string","required":false,"visibility":"user-or-llm","description":"BCC recipient email addresses (comma-separated)"},"inReplyTo":{"type":"string","required":false,"visibility":"user-or-llm","description":"ID of message being replied to"},"sendAt":{"type":"string","required":false,"visibility":"user-or-llm","description":"ISO 8601 timestamp to schedule sending"}}},"agentmail_create_inbox":{"id":"agentmail_create_inbox","name":"Create Inbox","description":"Create a new email inbox with AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"username":{"type":"string","required":false,"visibility":"user-or-llm","description":"Username for the inbox email address"},"domain":{"type":"string","required":false,"visibility":"user-or-llm","description":"Domain for the inbox email address"},"displayName":{"type":"string","required":false,"visibility":"user-or-llm","description":"Display name for the inbox"}}},"agentmail_delete_draft":{"id":"agentmail_delete_draft","name":"Delete Draft","description":"Delete an email draft in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the draft"},"draftId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the draft to delete"}}},"agentmail_delete_inbox":{"id":"agentmail_delete_inbox","name":"Delete Inbox","description":"Delete an email inbox in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to delete"}}},"agentmail_delete_thread":{"id":"agentmail_delete_thread","name":"Delete Thread","description":"Delete an email thread in AgentMail (moves to trash, or permanently deletes if already in trash)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the thread"},"threadId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the thread to delete"},"permanent":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Force permanent deletion instead of moving to trash"}}},"agentmail_forward_message":{"id":"agentmail_forward_message","name":"Forward Message","description":"Forward an email message to new recipients in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the message"},"messageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the message to forward"},"to":{"type":"string","required":true,"visibility":"user-or-llm","description":"Recipient email addresses (comma-separated)"},"subject":{"type":"string","required":false,"visibility":"user-or-llm","description":"Override subject line"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Additional plain text to prepend"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"Additional HTML to prepend"},"cc":{"type":"string","required":false,"visibility":"user-or-llm","description":"CC recipient email addresses (comma-separated)"},"bcc":{"type":"string","required":false,"visibility":"user-or-llm","description":"BCC recipient email addresses (comma-separated)"}}},"agentmail_get_draft":{"id":"agentmail_get_draft","name":"Get Draft","description":"Get details of a specific email draft in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox the draft belongs to"},"draftId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the draft to retrieve"}}},"agentmail_get_inbox":{"id":"agentmail_get_inbox","name":"Get Inbox","description":"Get details of a specific email inbox in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to retrieve"}}},"agentmail_get_message":{"id":"agentmail_get_message","name":"Get Message","description":"Get details of a specific email message in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the message"},"messageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the message to retrieve"}}},"agentmail_get_thread":{"id":"agentmail_get_thread","name":"Get Thread","description":"Get details of a specific email thread including messages in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the thread"},"threadId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the thread to retrieve"}}},"agentmail_list_drafts":{"id":"agentmail_list_drafts","name":"List Drafts","description":"List email drafts in an inbox in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to list drafts from"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of drafts to return"},"pageToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token for next page of results"}}},"agentmail_list_inboxes":{"id":"agentmail_list_inboxes","name":"List Inboxes","description":"List all email inboxes in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of inboxes to return"},"pageToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token for next page of results"}}},"agentmail_list_messages":{"id":"agentmail_list_messages","name":"List Messages","description":"List messages in an inbox in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to list messages from"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of messages to return"},"pageToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token for next page of results"}}},"agentmail_list_threads":{"id":"agentmail_list_threads","name":"List Threads","description":"List email threads in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to list threads from"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of threads to return"},"pageToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token for next page of results"},"labels":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated labels to filter threads by"},"before":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter threads before this ISO 8601 timestamp"},"after":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter threads after this ISO 8601 timestamp"}}},"agentmail_reply_message":{"id":"agentmail_reply_message","name":"Reply to Message","description":"Reply to an existing email message in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to reply from"},"messageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the message to reply to"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Plain text reply body"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"HTML reply body"},"to":{"type":"string","required":false,"visibility":"user-or-llm","description":"Override recipient email addresses (comma-separated)"},"cc":{"type":"string","required":false,"visibility":"user-or-llm","description":"CC email addresses (comma-separated)"},"bcc":{"type":"string","required":false,"visibility":"user-or-llm","description":"BCC email addresses (comma-separated)"},"replyAll":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Reply to all recipients of the original message"}}},"agentmail_send_draft":{"id":"agentmail_send_draft","name":"Send Draft","description":"Send an existing email draft in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the draft"},"draftId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the draft to send"}}},"agentmail_send_message":{"id":"agentmail_send_message","name":"Send Message","description":"Send an email message from an AgentMail inbox","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to send from"},"to":{"type":"string","required":true,"visibility":"user-or-llm","description":"Recipient email address (comma-separated for multiple)"},"subject":{"type":"string","required":true,"visibility":"user-or-llm","description":"Email subject line"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Plain text email body"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"HTML email body"},"cc":{"type":"string","required":false,"visibility":"user-or-llm","description":"CC recipient email addresses (comma-separated)"},"bcc":{"type":"string","required":false,"visibility":"user-or-llm","description":"BCC recipient email addresses (comma-separated)"}}},"agentmail_update_draft":{"id":"agentmail_update_draft","name":"Update Draft","description":"Update an existing email draft in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the draft"},"draftId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the draft to update"},"to":{"type":"string","required":false,"visibility":"user-or-llm","description":"Recipient email addresses (comma-separated)"},"subject":{"type":"string","required":false,"visibility":"user-or-llm","description":"Draft subject line"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Plain text draft body"},"html":{"type":"string","required":false,"visibility":"user-or-llm","description":"HTML draft body"},"cc":{"type":"string","required":false,"visibility":"user-or-llm","description":"CC recipient email addresses (comma-separated)"},"bcc":{"type":"string","required":false,"visibility":"user-or-llm","description":"BCC recipient email addresses (comma-separated)"},"sendAt":{"type":"string","required":false,"visibility":"user-or-llm","description":"ISO 8601 timestamp to schedule sending"}}},"agentmail_update_inbox":{"id":"agentmail_update_inbox","name":"Update Inbox","description":"Update the display name of an email inbox in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox to update"},"displayName":{"type":"string","required":true,"visibility":"user-or-llm","description":"New display name for the inbox"}}},"agentmail_update_message":{"id":"agentmail_update_message","name":"Update Message","description":"Add or remove labels on an email message in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the message"},"messageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the message to update"},"addLabels":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated labels to add to the message"},"removeLabels":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated labels to remove from the message"}}},"agentmail_update_thread":{"id":"agentmail_update_thread","name":"Update Thread Labels","description":"Add or remove labels on an email thread in AgentMail","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentMail API key"},"inboxId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the inbox containing the thread"},"threadId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the thread to update"},"addLabels":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated labels to add to the thread"},"removeLabels":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated labels to remove from the thread"}}},"agentphone_create_call":{"id":"agentphone_create_call","name":"Create Outbound Call","description":"Initiate an outbound voice call from an AgentPhone agent","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"agentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Agent that will handle the call"},"toNumber":{"type":"string","required":true,"visibility":"user-or-llm","description":"Phone number to call in E.164 format (e.g. +14155551234)"},"fromNumberId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Phone number ID to use as caller ID. Must belong to the agent. If omitted, the agent\'s first assigned number is used."},"initialGreeting":{"type":"string","required":false,"visibility":"user-or-llm","description":"Optional greeting spoken when the recipient answers"},"voice":{"type":"string","required":false,"visibility":"user-or-llm","description":"Voice ID override for this call (defaults to the agent\'s configured voice)"},"systemPrompt":{"type":"string","required":false,"visibility":"user-or-llm","description":"When provided, uses a built-in LLM for the conversation instead of forwarding to your webhook"}}},"agentphone_create_contact":{"id":"agentphone_create_contact","name":"Create Contact","description":"Create a new contact in AgentPhone","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"phoneNumber":{"type":"string","required":true,"visibility":"user-or-llm","description":"Phone number in E.164 format (e.g. +14155551234)"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Contact\'s full name"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"Contact\'s email address"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"Freeform notes stored on the contact"}}},"agentphone_create_number":{"id":"agentphone_create_number","name":"Create Phone Number","description":"Provision a new SMS- and voice-enabled phone number","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Two-letter country code (e.g. US, CA). Defaults to US."},"areaCode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Preferred area code (US/CA only, e.g. \\"415\\"). Best-effort β€” may be ignored if unavailable."},"agentId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Optionally attach the number to an agent immediately"}}},"agentphone_delete_contact":{"id":"agentphone_delete_contact","name":"Delete Contact","description":"Delete a contact by ID","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"contactId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Contact ID"}}},"agentphone_get_call":{"id":"agentphone_get_call","name":"Get Call","description":"Fetch a call and its full transcript","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"callId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the call to retrieve"}}},"agentphone_get_call_transcript":{"id":"agentphone_get_call_transcript","name":"Get Call Transcript","description":"Get the full ordered transcript for a call","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"callId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the call to retrieve the transcript for"}}},"agentphone_get_contact":{"id":"agentphone_get_contact","name":"Get Contact","description":"Fetch a single contact by ID","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"contactId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Contact ID"}}},"agentphone_get_conversation":{"id":"agentphone_get_conversation","name":"Get Conversation","description":"Get a conversation along with its recent messages","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"conversationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Conversation ID"},"messageLimit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of recent messages to include (default 50, max 100)"}}},"agentphone_get_conversation_messages":{"id":"agentphone_get_conversation_messages","name":"Get Conversation Messages","description":"Get paginated messages for a conversation","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"conversationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Conversation ID"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of messages to return (default 50, max 200)"},"before":{"type":"string","required":false,"visibility":"user-or-llm","description":"Return messages received before this ISO 8601 timestamp"},"after":{"type":"string","required":false,"visibility":"user-or-llm","description":"Return messages received after this ISO 8601 timestamp"}}},"agentphone_get_number_messages":{"id":"agentphone_get_number_messages","name":"Get Phone Number Messages","description":"Fetch messages received on a specific phone number","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"numberId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the phone number"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of messages to return (default 50, max 200)"},"before":{"type":"string","required":false,"visibility":"user-or-llm","description":"Return messages received before this ISO 8601 timestamp"},"after":{"type":"string","required":false,"visibility":"user-or-llm","description":"Return messages received after this ISO 8601 timestamp"}}},"agentphone_get_usage":{"id":"agentphone_get_usage","name":"Get Usage","description":"Retrieve current usage statistics for the AgentPhone account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"}}},"agentphone_get_usage_daily":{"id":"agentphone_get_usage_daily","name":"Get Daily Usage","description":"Get a daily breakdown of usage (messages, calls, webhooks) for the last N days","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"days":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of days to return (1-365, default 30)"}}},"agentphone_get_usage_monthly":{"id":"agentphone_get_usage_monthly","name":"Get Monthly Usage","description":"Get monthly usage aggregation (messages, calls, webhooks) for the last N months","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"months":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of months to return (1-24, default 6)"}}},"agentphone_list_calls":{"id":"agentphone_list_calls","name":"List Calls","description":"List voice calls for this AgentPhone account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to return (default 20, max 100)"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to skip (min 0)"},"status":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter by status (completed, in-progress, failed)"},"direction":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter by direction (inbound, outbound)"},"type":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter by call type (pstn, web)"},"search":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search by phone number (matches fromNumber or toNumber)"}}},"agentphone_list_contacts":{"id":"agentphone_list_contacts","name":"List Contacts","description":"List contacts for this AgentPhone account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"search":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter by name or phone number (case-insensitive contains)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to return (default 50, max 200)"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to skip (min 0)"}}},"agentphone_list_conversations":{"id":"agentphone_list_conversations","name":"List Conversations","description":"List conversations (message threads) for this AgentPhone account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to return (default 20, max 100)"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to skip (min 0)"}}},"agentphone_list_numbers":{"id":"agentphone_list_numbers","name":"List Phone Numbers","description":"List all phone numbers provisioned for this AgentPhone account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to return (default 20, max 100)"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to skip (min 0)"}}},"agentphone_react_to_message":{"id":"agentphone_react_to_message","name":"React to Message","description":"Send an iMessage tapback reaction to a message (iMessage only)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"messageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the message to react to"},"reaction":{"type":"string","required":true,"visibility":"user-or-llm","description":"Reaction type: love, like, dislike, laugh, emphasize, or question"}}},"agentphone_release_number":{"id":"agentphone_release_number","name":"Release Phone Number","description":"Release (delete) a phone number. This action is irreversible.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"numberId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the phone number to release"}}},"agentphone_send_message":{"id":"agentphone_send_message","name":"Send Message","description":"Send an outbound SMS or iMessage from an AgentPhone agent","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"agentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Agent sending the message"},"toNumber":{"type":"string","required":true,"visibility":"user-or-llm","description":"Recipient phone number in E.164 format (e.g. +14155551234)"},"body":{"type":"string","required":true,"visibility":"user-or-llm","description":"Message text to send"},"mediaUrl":{"type":"string","required":false,"visibility":"user-or-llm","description":"Optional URL of an image, video, or file to attach"},"numberId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Phone number ID to send from. If omitted, the agent\'s first assigned number is used."}}},"agentphone_update_contact":{"id":"agentphone_update_contact","name":"Update Contact","description":"Update a contact\'s fields","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"contactId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Contact ID"},"phoneNumber":{"type":"string","required":false,"visibility":"user-or-llm","description":"New phone number in E.164 format"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"New contact name"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"New email address"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"New freeform notes"}}},"agentphone_update_conversation":{"id":"agentphone_update_conversation","name":"Update Conversation","description":"Update conversation metadata (stored state). Pass null to clear existing metadata.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"AgentPhone API key"},"conversationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Conversation ID"},"metadata":{"type":"json","required":false,"visibility":"user-or-llm","description":"Custom key-value metadata to store on the conversation. Pass null to clear existing metadata."}}},"agiloft_async_status":{"id":"agiloft_async_status","name":"Agiloft Async Status","description":"Check whether an asynchronous Agiloft call, such as a run action button, has completed.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table the asynchronous call was made against"},"callbackId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Callback ID returned by the asynchronous call, e.g. from Run Action Button"}}},"agiloft_attach_file":{"id":"agiloft_attach_file","name":"Agiloft Attach File","description":"Attach a file to a field in an Agiloft record.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to attach the file to"},"fieldName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the attachment field"},"file":{"type":"file","required":true,"visibility":"user-or-llm","description":"File to attach"},"fileName":{"type":"string","required":false,"visibility":"user-or-llm","description":"Name to assign to the file (defaults to original file name)"},"overwrite":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Replace the contents of the field instead of adding another file to it"}}},"agiloft_attachment_info":{"id":"agiloft_attachment_info","name":"Agiloft Attachment Info","description":"Get information about file attachments on a record field.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to check attachments on"},"fieldName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the attachment field to inspect"}}},"agiloft_create_record":{"id":"agiloft_create_record","name":"Agiloft Create Record","description":"Create a new record in an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"data":{"type":"string","required":true,"visibility":"user-or-llm","description":"Record field values as a JSON object (e.g., {\\"first_name\\": \\"John\\", \\"status\\": \\"Active\\"})"}}},"agiloft_delete_record":{"id":"agiloft_delete_record","name":"Agiloft Delete Record","description":"Delete a record from an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to delete"},"substituteIds":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated IDs of records that adopt the dependants of the deleted record. Read only when the delete rule is REPLACE_WITH_ANOTHER."},"deleteRule":{"type":"string","required":false,"visibility":"user-or-llm","description":"How to treat records that depend on this one: ERROR_IF_DEPENDANTS (default β€” fails rather than cascading), APPLY_DELETE_WHERE_POSSIBLE, DELETE_WHERE_POSSIBLE_OTHERWISE_UNLINK, APPLY_UNLINK, UNLINK_WHERE_POSSIBLE_OTHERWISE_DELETE, or REPLACE_WITH_ANOTHER"}}},"agiloft_get_choice_line_id":{"id":"agiloft_get_choice_line_id","name":"Agiloft Get Choice Line ID","description":"Resolve the internal numeric ID of a choice-list value, for use in EWSelect WHERE clauses against choice fields.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"case\\", \\"contracts\\")"},"fieldName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Choice field name (e.g., \\"priority\\", \\"status\\")"},"value":{"type":"string","required":true,"visibility":"user-or-llm","description":"Choice display value to resolve (e.g., \\"High\\", \\"Active\\")"}}},"agiloft_list_tables":{"id":"agiloft_list_tables","name":"Agiloft List Tables","description":"List the tables and fields in an Agiloft knowledge base, to discover the logical names other operations need.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":false,"visibility":"user-or-llm","description":"Logical name of a single table to describe (e.g., \\"contacts\\"). Leave empty to list every table in the knowledge base."},"includeLinkedInfo":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Include the source table and column behind each linked field"},"skipColumnsInfo":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Return table names only, omitting field details, for a much smaller response"}}},"agiloft_lock_record":{"id":"agiloft_lock_record","name":"Agiloft Lock Record","description":"Lock, unlock, or check the lock status of an Agiloft record.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to lock, unlock, or check"},"lockAction":{"type":"string","required":true,"visibility":"user-or-llm","description":"Action to perform: \\"lock\\", \\"unlock\\", or \\"check\\""},"force":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Unlock only: release a lock held by another user."}}},"agiloft_nlp_search":{"id":"agiloft_nlp_search","name":"Agiloft Natural Language Search","description":"Search Agiloft records by describing what you want in plain language, such as \\"active NDAs submitted last month\\".","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"nlpQuery":{"type":"string","required":true,"visibility":"user-or-llm","description":"The request in plain language, e.g. \\"Show me open, high-priority contracts\\". Structured field filters are not accepted β€” use Search Records for those."},"fields":{"type":"string","required":true,"visibility":"user-or-llm","description":"Comma-separated field names to return, e.g. \\"id, contract_title1, company_name\\""},"page":{"type":"string","required":false,"visibility":"user-or-llm","description":"Page number, starting from 0"},"limit":{"type":"string","required":false,"visibility":"user-or-llm","description":"Records per page"}}},"agiloft_read_record":{"id":"agiloft_read_record","name":"Agiloft Read Record","description":"Read a record by ID from an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to read"},"fields":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of field names to include in the response"}}},"agiloft_remove_attachment":{"id":"agiloft_remove_attachment","name":"Agiloft Remove Attachment","description":"Remove an attached file from a field in an Agiloft record.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record containing the attachment"},"fieldName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the attachment field"},"position":{"type":"string","required":true,"visibility":"user-or-llm","description":"Position index of the file to remove (starting from 0)"}}},"agiloft_retrieve_attachment":{"id":"agiloft_retrieve_attachment","name":"Agiloft Retrieve Attachment","description":"Download an attached file from an Agiloft record field.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record containing the attachment"},"fieldName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the attachment field"},"position":{"type":"string","required":true,"visibility":"user-or-llm","description":"Position index of the file in the field (starting from 0)"}}},"agiloft_run_action_button":{"id":"agiloft_run_action_button","name":"Agiloft Run Action Button","description":"Run an action button on an Agiloft record, such as an approval or send-for-signature step.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"case\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to run the action button on"},"actionButtonField":{"type":"string","required":true,"visibility":"user-or-llm","description":"Logical name of the field holding the action button (e.g., \\"ab_field\\")"}}},"agiloft_saved_search":{"id":"agiloft_saved_search","name":"Agiloft Saved Search","description":"List the saved searches defined for an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Logical table name to list saved searches for (e.g., \\"contract\\")"}}},"agiloft_search_records":{"id":"agiloft_search_records","name":"Agiloft Search Records","description":"Search for records in an Agiloft table using a query.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name to search in (e.g., \\"contracts\\", \\"contacts.employees\\")"},"query":{"type":"string","required":false,"visibility":"user-or-llm","description":"Ad hoc EWSearch query. Combine conditions with && (and) or || (or) and quote every value β€” e.g. \\"summary~=\'test\'&&priority=\'High\'\\". Required unless a saved search is given."},"search":{"type":"string","required":false,"visibility":"user-or-llm","description":"Label of a saved search defined on the table (e.g., \\"C: Status is Closed\\"). Can be combined with a query to narrow it further."},"fields":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of field names to include in the results"},"page":{"type":"string","required":false,"visibility":"user-or-llm","description":"Page number for paginated results (starting from 0)"},"limit":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum number of records to return per page. Agiloft treats 0 as \\"all records\\", so leave it unset or use a positive value to keep result sizes bounded."}}},"agiloft_select_records":{"id":"agiloft_select_records","name":"Agiloft Select Records","description":"Select record IDs matching a SQL WHERE clause from an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"where":{"type":"string","required":true,"visibility":"user-or-llm","description":"SQL WHERE clause using database column names (e.g., \\"summary like \'%new%\'\\" or \\"assigned_person=\'John Doe\'\\"). EWSelect has no page size and returns every matching ID, so append a database limit such as \\"limit 0,200\\" to bound the result."}}},"agiloft_update_record":{"id":"agiloft_update_record","name":"Agiloft Update Record","description":"Update an existing record in an Agiloft table.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the record to update"},"data":{"type":"string","required":true,"visibility":"user-or-llm","description":"Updated field values as a JSON object (e.g., {\\"status\\": \\"Active\\", \\"priority\\": \\"High\\"})"}}},"agiloft_upsert_record":{"id":"agiloft_upsert_record","name":"Agiloft Upsert Record","description":"Create an Agiloft record, or update it when a record already matches the given fields.","version":"1.0.0","params":{"instanceUrl":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft instance URL (e.g., https://mycompany.agiloft.com)"},"knowledgeBase":{"type":"string","required":true,"visibility":"user-only","description":"Knowledge base name"},"login":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft username"},"password":{"type":"string","required":true,"visibility":"user-only","description":"Agiloft password"},"table":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table name (e.g., \\"contracts\\", \\"contacts.employees\\")"},"match":{"type":"string","required":true,"visibility":"user-or-llm","description":"Field used to find an existing record (e.g., \\"ext_id\\"). Pick something that identifies a record uniquely β€” if more than one record matches, Agiloft writes nothing and returns a conflict."},"async":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Queue the write instead of waiting for it. Returns a callback ID instead of a record ID; pass that to Async Status to poll the result."},"data":{"type":"string","required":true,"visibility":"user-or-llm","description":"Field values as a JSON object. On create these populate the new record; on update only the supplied fields change."}}},"ahrefs_anchors":{"id":"ahrefs_anchors","name":"Ahrefs Anchors","description":"Get the anchor text distribution for a target domain or URL\'s backlinks, showing how many links and referring domains use each anchor text.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"history":{"type":"string","required":false,"visibility":"user-or-llm","description":"Historical scope: \\"live\\" (currently live), \\"all_time\\" (default, includes lost backlinks), or \\"since:YYYY-MM-DD\\" (backlinks found since a date)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_backlinks":{"id":"ahrefs_backlinks","name":"Ahrefs Backlinks","description":"Get a list of backlinks pointing to a target domain or URL. Returns details about each backlink including source URL, anchor text, and domain rating.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"history":{"type":"string","required":false,"visibility":"user-or-llm","description":"Historical scope: \\"live\\" (currently live backlinks), \\"all_time\\" (default, includes lost backlinks), or \\"since:YYYY-MM-DD\\" (backlinks found since a date)."},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_backlinks_stats":{"id":"ahrefs_backlinks_stats","name":"Ahrefs Backlinks Stats","description":"Get backlink and referring domain totals for a target domain or URL, both currently live and across all time.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_batch_analysis":{"id":"ahrefs_batch_analysis","name":"Ahrefs Batch Analysis","description":"Get bulk SEO metrics (Domain Rating, backlinks, referring domains, organic traffic, and more) for multiple domains or URLs in a single request. Useful for comparing many competitors at once.","version":"1.0.0","params":{"targets":{"type":"string","required":true,"visibility":"user-or-llm","description":"Comma-separated list of domains or URLs to analyze. Example: \\"example.com,competitor.com\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode applied to every target: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"protocol":{"type":"string","required":false,"visibility":"user-or-llm","description":"Protocol applied to every target: \\"both\\" (default), \\"http\\", or \\"https\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for traffic data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"volumeMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search volume calculation: \\"monthly\\" or \\"average\\" (default: \\"monthly\\")"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_broken_backlinks":{"id":"ahrefs_broken_backlinks","name":"Ahrefs Broken Backlinks","description":"Get a list of broken backlinks pointing to a target domain or URL. Useful for identifying link reclamation opportunities.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_domain_rating":{"id":"ahrefs_domain_rating","name":"Ahrefs Domain Rating","description":"Get the Domain Rating (DR) and Ahrefs Rank for a target domain. Domain Rating shows the strength of a website\'s backlink profile on a scale from 0 to 100.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain to analyze (e.g., example.com)"},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date for historical data in YYYY-MM-DD format (defaults to today)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_domain_rating_history":{"id":"ahrefs_domain_rating_history","name":"Ahrefs Domain Rating History","description":"Get the historical Domain Rating (DR) trend for a target domain or URL over a date range, grouped daily, weekly, or monthly.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"dateFrom":{"type":"string","required":true,"visibility":"user-only","description":"Start date of the historical period, in YYYY-MM-DD format"},"dateTo":{"type":"string","required":false,"visibility":"user-only","description":"End date of the historical period, in YYYY-MM-DD format (defaults to today)"},"historyGrouping":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval for grouping data points: \\"daily\\", \\"weekly\\", or \\"monthly\\" (default: \\"monthly\\")"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_keyword_overview":{"id":"ahrefs_keyword_overview","name":"Ahrefs Keyword Overview","description":"Get detailed metrics for a keyword including search volume, keyword difficulty, CPC, clicks, and traffic potential.","version":"1.0.0","params":{"keyword":{"type":"string","required":true,"visibility":"user-or-llm","description":"The keyword to analyze"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for keyword data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_keywords_history":{"id":"ahrefs_keywords_history","name":"Ahrefs Keywords History","description":"Get the historical organic keyword ranking distribution for a target domain or URL over a date range: how many keywords rank in each position bucket at each point in time.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"dateFrom":{"type":"string","required":true,"visibility":"user-only","description":"Start date of the historical period, in YYYY-MM-DD format"},"dateTo":{"type":"string","required":false,"visibility":"user-only","description":"End date of the historical period, in YYYY-MM-DD format (defaults to today)"},"historyGrouping":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval for grouping data points: \\"daily\\", \\"weekly\\", or \\"monthly\\" (default: \\"monthly\\")"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for search results. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_metrics":{"id":"ahrefs_metrics","name":"Ahrefs Metrics","description":"Get a one-call organic and paid search overview for a target domain or URL: organic traffic, organic keywords, paid traffic, paid keywords, and estimated traffic cost.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for traffic data. Example: \\"us\\", \\"gb\\", \\"de\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_metrics_history":{"id":"ahrefs_metrics_history","name":"Ahrefs Metrics History","description":"Get the historical organic and paid traffic trend for a target domain or URL over a date range: organic traffic/cost and paid traffic/cost at each point in time.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"dateFrom":{"type":"string","required":true,"visibility":"user-only","description":"Start date of the historical period, in YYYY-MM-DD format"},"dateTo":{"type":"string","required":false,"visibility":"user-only","description":"End date of the historical period, in YYYY-MM-DD format (defaults to today)"},"volumeMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search volume calculation: \\"monthly\\" or \\"average\\" (default: \\"monthly\\")"},"historyGrouping":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval for grouping data points: \\"daily\\", \\"weekly\\", or \\"monthly\\" (default: \\"monthly\\")"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for traffic data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_organic_competitors":{"id":"ahrefs_organic_competitors","name":"Ahrefs Organic Competitors","description":"Get domains that compete with a target domain or URL for the same organic keywords, ranked by keyword overlap.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for search results. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_organic_keywords":{"id":"ahrefs_organic_keywords","name":"Ahrefs Organic Keywords","description":"Get organic keywords that a target domain or URL ranks for in Google search results. Returns keyword details including search volume, ranking position, and estimated traffic.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for search results. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_paid_pages":{"id":"ahrefs_paid_pages","name":"Ahrefs Paid Pages","description":"Get a target domain\'s pages that receive paid search traffic, sorted by estimated paid traffic. Returns page URLs with their paid traffic, keyword counts, and estimated spend.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for traffic data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_rank_tracker_competitors_overview":{"id":"ahrefs_rank_tracker_competitors_overview","name":"Ahrefs Rank Tracker Competitors Overview","description":"Get competitor rankings for the keywords tracked in an Ahrefs Rank Tracker project: each tracked keyword\'s volume and difficulty alongside every competitor\'s position, traffic, and traffic value. This endpoint is free and does not consume API units.","version":"1.0.0","params":{"projectId":{"type":"number","required":true,"visibility":"user-or-llm","description":"The Rank Tracker project ID (found in the project URL in Ahrefs)"},"date":{"type":"string","required":true,"visibility":"user-only","description":"Date to report rankings for, in YYYY-MM-DD format"},"device":{"type":"string","required":true,"visibility":"user-or-llm","description":"Rankings device type: \\"desktop\\" or \\"mobile\\""},"dateCompared":{"type":"string","required":false,"visibility":"user-only","description":"Comparison date in YYYY-MM-DD format, to compute position/traffic deltas"},"volumeMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search volume calculation: \\"monthly\\" or \\"average\\" (default: \\"monthly\\")"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_rank_tracker_competitors_stats":{"id":"ahrefs_rank_tracker_competitors_stats","name":"Ahrefs Rank Tracker Competitors Stats","description":"Get aggregate competitor stats for an Ahrefs Rank Tracker project: each competitor\'s traffic, traffic value, average position, and share of voice across all tracked keywords. This endpoint is free and does not consume API units.","version":"1.0.0","params":{"projectId":{"type":"number","required":true,"visibility":"user-or-llm","description":"The Rank Tracker project ID (found in the project URL in Ahrefs)"},"date":{"type":"string","required":true,"visibility":"user-only","description":"Date to report metrics for, in YYYY-MM-DD format"},"device":{"type":"string","required":true,"visibility":"user-or-llm","description":"Rankings device type: \\"desktop\\" or \\"mobile\\""},"volumeMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search volume calculation: \\"monthly\\" or \\"average\\" (default: \\"monthly\\")"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_rank_tracker_overview":{"id":"ahrefs_rank_tracker_overview","name":"Ahrefs Rank Tracker Overview","description":"Get ranking overview metrics for the keywords tracked in an Ahrefs Rank Tracker project: position, search volume, keyword difficulty, and estimated traffic. This endpoint is free and does not consume API units.","version":"1.0.0","params":{"projectId":{"type":"number","required":true,"visibility":"user-or-llm","description":"The Rank Tracker project ID (found in the project URL in Ahrefs)"},"date":{"type":"string","required":true,"visibility":"user-only","description":"Date to report rankings for, in YYYY-MM-DD format"},"device":{"type":"string","required":true,"visibility":"user-or-llm","description":"Rankings device type: \\"desktop\\" or \\"mobile\\""},"dateCompared":{"type":"string","required":false,"visibility":"user-only","description":"Comparison date in YYYY-MM-DD format, to compute position/traffic deltas"},"volumeMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search volume calculation: \\"monthly\\" or \\"average\\" (default: \\"monthly\\")"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_rank_tracker_serp_overview":{"id":"ahrefs_rank_tracker_serp_overview","name":"Ahrefs Rank Tracker SERP Overview","description":"Get the full SERP (search engine results page) for a keyword tracked in an Ahrefs Rank Tracker project, including every ranking URL with its position, title, and authority metrics. This endpoint is free and does not consume API units.","version":"1.0.0","params":{"projectId":{"type":"number","required":true,"visibility":"user-or-llm","description":"The Rank Tracker project ID (found in the project URL in Ahrefs)"},"keyword":{"type":"string","required":true,"visibility":"user-or-llm","description":"The tracked keyword to retrieve SERP data for"},"country":{"type":"string","required":true,"visibility":"user-or-llm","description":"Country code for the tracked keyword. Example: \\"us\\", \\"gb\\", \\"de\\""},"device":{"type":"string","required":true,"visibility":"user-or-llm","description":"Rankings device type: \\"desktop\\" or \\"mobile\\""},"topPositions":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of top organic positions to return (defaults to all available)"},"date":{"type":"string","required":false,"visibility":"user-only","description":"Timestamp to return the last available SERP Overview at, in YYYY-MM-DDThh:mm:ss format"},"locationId":{"type":"number","required":false,"visibility":"user-or-llm","description":"Location ID of the tracked keyword, if tracked at a specific location"},"languageCode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Language code of the tracked keyword"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_refdomains_history":{"id":"ahrefs_refdomains_history","name":"Ahrefs Referring Domains History","description":"Get the historical referring domains trend for a target domain or URL over a date range, grouped daily, weekly, or monthly.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\""},"dateFrom":{"type":"string","required":true,"visibility":"user-only","description":"Start date of the historical period, in YYYY-MM-DD format"},"dateTo":{"type":"string","required":false,"visibility":"user-only","description":"End date of the historical period, in YYYY-MM-DD format (defaults to today)"},"historyGrouping":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval for grouping data points: \\"daily\\", \\"weekly\\", or \\"monthly\\" (default: \\"monthly\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_referring_domains":{"id":"ahrefs_referring_domains","name":"Ahrefs Referring Domains","description":"Get a list of domains that link to a target domain or URL. Returns unique referring domains with their domain rating, backlink counts, and discovery dates.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain or URL to analyze. Example: \\"example.com\\" or \\"https://example.com/page\\""},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"history":{"type":"string","required":false,"visibility":"user-or-llm","description":"Historical scope: \\"live\\" (currently live), \\"all_time\\" (default, includes lost domains), or \\"since:YYYY-MM-DD\\" (domains found since a date)."},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_related_terms":{"id":"ahrefs_related_terms","name":"Ahrefs Related Terms","description":"Get keyword ideas related to a seed keyword: terms the same top-ranking pages also rank for (\\"also rank for\\") or also discuss (\\"also talk about\\"), with volume, difficulty, and CPC.","version":"1.0.0","params":{"keyword":{"type":"string","required":true,"visibility":"user-or-llm","description":"The seed keyword to find related terms for"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for keyword data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"terms":{"type":"string","required":false,"visibility":"user-or-llm","description":"Type of related keywords to return: \\"also_rank_for\\", \\"also_talk_about\\", or \\"all\\" (default: \\"all\\")"},"viewFor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Whether to derive related terms from the top 10 or top 100 ranking pages (default: \\"top_10\\")"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_site_audit_page_explorer":{"id":"ahrefs_site_audit_page_explorer","name":"Ahrefs Site Audit Page Explorer","description":"Get crawled pages from an Ahrefs Site Audit project with health and SEO metrics: HTTP status, title, link counts, backlinks, indexability, and traffic. Optionally filter to pages affected by a specific issue.","version":"1.0.0","params":{"projectId":{"type":"number","required":true,"visibility":"user-or-llm","description":"The Site Audit project ID (found in the project URL in Ahrefs)"},"date":{"type":"string","required":false,"visibility":"user-only","description":"Crawl date in YYYY-MM-DDThh:mm:ss format (defaults to the most recent crawl)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of results to skip, for pagination"},"issueId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Only return pages affected by this issue ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"ahrefs_top_pages":{"id":"ahrefs_top_pages","name":"Ahrefs Top Pages","description":"Get the top pages of a target domain sorted by organic traffic. Returns page URLs with their traffic, keyword counts, and estimated traffic value.","version":"1.0.0","params":{"target":{"type":"string","required":true,"visibility":"user-or-llm","description":"The target domain to analyze. Example: \\"example.com\\""},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Country code for traffic data. Example: \\"us\\", \\"gb\\", \\"de\\" (default: \\"us\\")"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Analysis mode: domain (entire domain), prefix (URL prefix), subdomains (include all subdomains, default), exact (exact URL match). Example: \\"domain\\""},"date":{"type":"string","required":false,"visibility":"user-only","description":"Date to report metrics on, in YYYY-MM-DD format (defaults to today)"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of results to return. Example: 50 (default: 1000)"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ahrefs API Key"}}},"airtable_create_records":{"id":"airtable_create_records","name":"Airtable Create Records","description":"Write new records to an Airtable table","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"records":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of records to create, each with a `fields` object"},"typecast":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"When true, Airtable automatically converts string values to the field type"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_delete_records":{"id":"airtable_delete_records","name":"Airtable Delete Records","description":"Delete one or more records from an Airtable table by ID","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"recordIds":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of record IDs to delete (each starts with \\"rec\\", e.g., [\\"recXXXXXXXXXXXXXX\\"]). Pass a single-element array to delete one record."}},"oauth":{"required":true,"provider":"airtable"}},"airtable_get_base_schema":{"id":"airtable_get_base_schema","name":"Airtable Get Base Schema","description":"Get the schema of all tables, fields, and views in an Airtable base","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_get_record":{"id":"airtable_get_record","name":"Airtable Get Record","description":"Retrieve a single record from an Airtable table by its ID","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Record ID to retrieve (starts with \\"rec\\", e.g., \\"recXXXXXXXXXXXXXX\\")"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_list_bases":{"id":"airtable_list_bases","name":"Airtable List Bases","description":"List all bases the authenticated user has access to","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"offset":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination offset for retrieving additional bases"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_list_records":{"id":"airtable_list_records","name":"Airtable List Records","description":"Read records from an Airtable table","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"maxRecords":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of records to return (default: all records)"},"filterFormula":{"type":"string","required":false,"visibility":"user-or-llm","description":"Formula to filter records (e.g., \\"({Field Name} = \'Value\')\\")"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_list_tables":{"id":"airtable_list_tables","name":"Airtable List Tables","description":"List all tables and their schema in an Airtable base","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_update_multiple_records":{"id":"airtable_update_multiple_records","name":"Airtable Update Multiple Records","description":"Update multiple existing records in an Airtable table","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"records":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of records to update, each with an `id` and a `fields` object"},"typecast":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"When true, Airtable automatically converts string values to the field type"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_update_record":{"id":"airtable_update_record","name":"Airtable Update Record","description":"Update an existing record in an Airtable table by ID","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"recordId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Record ID to update (starts with \\"rec\\", e.g., \\"recXXXXXXXXXXXXXX\\")"},"fields":{"type":"json","required":true,"visibility":"user-or-llm","description":"An object containing the field names and their new values"},"typecast":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"When true, Airtable automatically converts string values to the field type"}},"oauth":{"required":true,"provider":"airtable"}},"airtable_upsert_records":{"id":"airtable_upsert_records","name":"Airtable Upsert Records","description":"Update existing records or create new ones in an Airtable table, matching on the specified merge fields","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token"},"baseId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Airtable base ID (starts with \\"app\\", e.g., \\"appXXXXXXXXXXXXXX\\")"},"tableId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Table ID (starts with \\"tbl\\") or table name"},"records":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of records to upsert, each with a `fields` object"},"fieldsToMergeOn":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of field names used to match existing records (max 3). A record is updated when all merge fields match, otherwise it is created. Example: [\\"Name\\"]"},"typecast":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"When true, Airtable automatically converts string values to the field type"}},"oauth":{"required":true,"provider":"airtable"}},"airweave_search":{"id":"airweave_search","name":"Airweave Search","description":"Search your synced data collections using Airweave. Supports semantic search with hybrid, neural, or keyword retrieval strategies. Optionally generate AI-powered answers from search results.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Airweave API Key for authentication"},"collectionId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The readable ID of the collection to search"},"query":{"type":"string","required":true,"visibility":"user-or-llm","description":"The search query text"},"limit":{"type":"number","required":false,"visibility":"user-only","description":"Maximum number of results to return (default: 100)"},"retrievalStrategy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Retrieval strategy: hybrid (default), neural, or keyword"},"expandQuery":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Generate query variations to improve recall"},"rerank":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Reorder results for improved relevance using LLM"},"generateAnswer":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Generate a natural-language answer to the query"}}},"algolia_add_record":{"id":"algolia_add_record","name":"Algolia Add Record","description":"Add or replace a record in an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"objectID":{"type":"string","required":false,"visibility":"user-or-llm","description":"Object ID for the record (auto-generated if not provided)"},"record":{"type":"json","required":true,"visibility":"user-or-llm","description":"JSON object representing the record to add"}}},"algolia_batch_operations":{"id":"algolia_batch_operations","name":"Algolia Batch Operations","description":"Perform batch add, update, partial update, or delete operations on records in an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"requests":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of batch operations. Each item has \\"action\\" (addObject, updateObject, partialUpdateObject, partialUpdateObjectNoCreate, deleteObject, delete, clear) and \\"body\\" (the record data; must include objectID for update/delete; use an empty object {} for the index-level delete/clear actions)"}}},"algolia_browse_records":{"id":"algolia_browse_records","name":"Algolia Browse Records","description":"Browse and iterate over all records in an Algolia index using cursor pagination","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key (must have browse ACL)"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index to browse"},"query":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search query to filter browsed records"},"filters":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter string to narrow down results"},"attributesToRetrieve":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of attributes to retrieve"},"hitsPerPage":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of hits per page (default: 1000, max: 1000)"},"cursor":{"type":"string","required":false,"visibility":"user-or-llm","description":"Cursor from a previous browse response for pagination"},"aroundLatLng":{"type":"string","required":false,"visibility":"user-or-llm","description":"Coordinates for geo-search (e.g., \\"40.71,-74.01\\")"},"aroundRadius":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum radius in meters for geo-search, or \\"all\\" for unlimited"},"insideBoundingBox":{"type":"json","required":false,"visibility":"user-or-llm","description":"Bounding box coordinates as [[lat1, lng1, lat2, lng2]] for geo-search"},"insidePolygon":{"type":"json","required":false,"visibility":"user-or-llm","description":"Polygon coordinates as [[lat1, lng1, lat2, lng2, lat3, lng3, ...]] for geo-search"}}},"algolia_clear_records":{"id":"algolia_clear_records","name":"Algolia Clear Records","description":"Clear all records from an Algolia index while keeping settings, synonyms, and rules","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key (must have deleteIndex ACL)"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index to clear"}}},"algolia_copy_move_index":{"id":"algolia_copy_move_index","name":"Algolia Copy/Move Index","description":"Copy or move an Algolia index to a new destination","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the source index"},"operation":{"type":"string","required":true,"visibility":"user-or-llm","description":"Operation to perform: \\"copy\\" or \\"move\\""},"destination":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the destination index"},"scope":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of scopes to copy (only for \\"copy\\" operation): [\\"settings\\", \\"synonyms\\", \\"rules\\"]. Omit to copy everything including records."}}},"algolia_delete_by_filter":{"id":"algolia_delete_by_filter","name":"Algolia Delete By Filter","description":"Delete all records matching a filter from an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key (must have deleteIndex ACL)"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"filters":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter expression to match records for deletion (e.g., \\"category:outdated\\")"},"facetFilters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of facet filters (e.g., [\\"brand:Acme\\"])"},"numericFilters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of numeric filters (e.g., [\\"price > 100\\"])"},"tagFilters":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of tag filters using the _tags attribute (e.g., [\\"published\\"])"},"aroundLatLng":{"type":"string","required":false,"visibility":"user-or-llm","description":"Coordinates for geo-search filter (e.g., \\"40.71,-74.01\\")"},"aroundRadius":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum radius in meters for geo-search, or \\"all\\" for unlimited"},"insideBoundingBox":{"type":"json","required":false,"visibility":"user-or-llm","description":"Bounding box coordinates as [[lat1, lng1, lat2, lng2]] for geo-search filter"},"insidePolygon":{"type":"json","required":false,"visibility":"user-or-llm","description":"Polygon coordinates as [[lat1, lng1, lat2, lng2, lat3, lng3, ...]] for geo-search filter"}}},"algolia_delete_index":{"id":"algolia_delete_index","name":"Algolia Delete Index","description":"Delete an entire Algolia index and all its records","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key (must have deleteIndex ACL)"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index to delete"}}},"algolia_delete_record":{"id":"algolia_delete_record","name":"Algolia Delete Record","description":"Delete a record by objectID from an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"objectID":{"type":"string","required":true,"visibility":"user-or-llm","description":"The objectID of the record to delete"}}},"algolia_get_record":{"id":"algolia_get_record","name":"Algolia Get Record","description":"Get a record by objectID from an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"objectID":{"type":"string","required":true,"visibility":"user-or-llm","description":"The objectID of the record to retrieve"},"attributesToRetrieve":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of attributes to retrieve"}}},"algolia_get_records":{"id":"algolia_get_records","name":"Algolia Get Records","description":"Retrieve multiple records by objectID from one or more Algolia indices","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Default index name for all requests"},"requests":{"type":"json","required":true,"visibility":"user-or-llm","description":"Array of objects specifying records to retrieve. Each must have \\"objectID\\" and optionally \\"indexName\\" and \\"attributesToRetrieve\\"."}}},"algolia_get_settings":{"id":"algolia_get_settings","name":"Algolia Get Settings","description":"Retrieve the settings of an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"}}},"algolia_get_task_status":{"id":"algolia_get_task_status","name":"Algolia Get Task Status","description":"Check whether an Algolia indexing task has finished publishing","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index the task ran against"},"taskID":{"type":"number","required":true,"visibility":"user-or-llm","description":"The taskID returned by a previous write operation"}}},"algolia_list_indices":{"id":"algolia_list_indices","name":"Algolia List Indices","description":"List all indices in an Algolia application","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for paginating indices (default: not paginated)"},"hitsPerPage":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of indices per page (default: 100)"}}},"algolia_partial_update_record":{"id":"algolia_partial_update_record","name":"Algolia Partial Update Record","description":"Partially update a record in an Algolia index without replacing it entirely","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"objectID":{"type":"string","required":true,"visibility":"user-or-llm","description":"The objectID of the record to update"},"attributes":{"type":"json","required":true,"visibility":"user-or-llm","description":"JSON object with attributes to update. Supports built-in operations like {\\"stock\\": {\\"_operation\\": \\"Decrement\\", \\"value\\": 1}}"},"createIfNotExists":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Whether to create the record if it does not exist (default: true)"}}},"algolia_search":{"id":"algolia_search","name":"Algolia Search","description":"Search an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia API Key"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index to search"},"query":{"type":"string","required":true,"visibility":"user-or-llm","description":"Search query text"},"hitsPerPage":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of hits per page (default: 20)"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number to retrieve (default: 0)"},"filters":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter string (e.g., \\"category:electronics AND price < 100\\")"},"attributesToRetrieve":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of attributes to retrieve"},"facets":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of facet attribute names to retrieve counts for (use \\"*\\" for all)"},"getRankingInfo":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Whether to include detailed ranking information in each hit"},"aroundLatLng":{"type":"string","required":false,"visibility":"user-or-llm","description":"Coordinates for geo-search (e.g., \\"40.71,-74.01\\")"},"aroundRadius":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum radius in meters for geo-search, or \\"all\\" for unlimited"},"insideBoundingBox":{"type":"json","required":false,"visibility":"user-or-llm","description":"Bounding box coordinates as [[lat1, lng1, lat2, lng2]] for geo-search"},"insidePolygon":{"type":"json","required":false,"visibility":"user-or-llm","description":"Polygon coordinates as [[lat1, lng1, lat2, lng2, lat3, lng3, ...]] for geo-search"}}},"algolia_update_settings":{"id":"algolia_update_settings","name":"Algolia Update Settings","description":"Update the settings of an Algolia index","version":"1.0","params":{"applicationId":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Application ID"},"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Algolia Admin API Key (must have editSettings ACL)"},"indexName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the Algolia index"},"settings":{"type":"json","required":true,"visibility":"user-or-llm","description":"JSON object with settings to update (e.g., {\\"searchableAttributes\\": [\\"name\\", \\"description\\"], \\"customRanking\\": [\\"desc(popularity)\\"]})"},"forwardToReplicas":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Whether to apply changes to replica indices (default: false)"}}},"amplitude_event_segmentation":{"id":"amplitude_event_segmentation","name":"Amplitude Event Segmentation","description":"Query event analytics data with segmentation. Get event counts, uniques, averages, and more.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"eventType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Event type name to analyze"},"start":{"type":"string","required":true,"visibility":"user-or-llm","description":"Start date in YYYYMMDD format"},"end":{"type":"string","required":true,"visibility":"user-or-llm","description":"End date in YYYYMMDD format"},"metric":{"type":"string","required":false,"visibility":"user-or-llm","description":"Metric type: uniques, totals, pct_dau, average, histogram, sums, value_avg, or formula (default: uniques)"},"interval":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval: 1 (daily), 7 (weekly), or 30 (monthly)"},"groupBy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Property name to group by (prefix custom user properties with \\"gp:\\")"},"groupBy2":{"type":"string","required":false,"visibility":"user-or-llm","description":"Second property name to group by (prefix custom user properties with \\"gp:\\")"},"limit":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum number of group-by values (max 1000)"},"filters":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON array of filter objects applied to the event, e.g. [{\\"subprop_type\\":\\"event\\",\\"subprop_key\\":\\"city\\",\\"subprop_op\\":\\"is\\",\\"subprop_value\\":[\\"San Francisco\\"]}]"},"formula":{"type":"string","required":false,"visibility":"user-or-llm","description":"Required when metric is \\"formula\\", e.g. \\"UNIQUES(A)/UNIQUES(B)\\""},"segment":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON segment definition(s) applied to the query"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_funnels":{"id":"amplitude_funnels","name":"Amplitude Funnels","description":"Analyze conversion rates and drop-off between a sequence of events.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"events":{"type":"string","required":true,"visibility":"user-or-llm","description":"JSON array of event objects, one per funnel step in order, e.g. [{\\"event_type\\":\\"signup\\"},{\\"event_type\\":\\"purchase\\"}]"},"start":{"type":"string","required":true,"visibility":"user-or-llm","description":"Start date in YYYYMMDD format"},"end":{"type":"string","required":true,"visibility":"user-or-llm","description":"End date in YYYYMMDD format"},"mode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Funnel ordering: \\"ordered\\", \\"unordered\\", or \\"sequential\\" (default: ordered)"},"userType":{"type":"string","required":false,"visibility":"user-or-llm","description":"User type: \\"new\\" or \\"active\\" (default: active)"},"interval":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval: -300000 (real-time), -3600000 (hourly), 1 (daily), 7 (weekly), or 30 (monthly)"},"conversionWindowSeconds":{"type":"string","required":false,"visibility":"user-or-llm","description":"Conversion window in seconds (default: 2592000, i.e. 30 days)"},"groupBy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Property to group by (limit: one; prefix custom properties with \\"gp:\\")"},"limit":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum number of group-by values (default: 100, max: 1000)"},"segment":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON segment definition(s) applied to the query"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_get_active_users":{"id":"amplitude_get_active_users","name":"Amplitude Get Active Users","description":"Get active or new user counts over a date range from the Dashboard REST API.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"start":{"type":"string","required":true,"visibility":"user-or-llm","description":"Start date in YYYYMMDD format"},"end":{"type":"string","required":true,"visibility":"user-or-llm","description":"End date in YYYYMMDD format"},"metric":{"type":"string","required":false,"visibility":"user-or-llm","description":"Metric type: \\"active\\" or \\"new\\" (default: active)"},"interval":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval: 1 (daily), 7 (weekly), or 30 (monthly)"},"groupBy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Property name to group by"},"segment":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON segment definition(s) applied to the query"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_get_revenue":{"id":"amplitude_get_revenue","name":"Amplitude Get Revenue","description":"Get revenue LTV data including ARPU, ARPPU, total revenue, and paying user counts.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"start":{"type":"string","required":true,"visibility":"user-or-llm","description":"Start date in YYYYMMDD format"},"end":{"type":"string","required":true,"visibility":"user-or-llm","description":"End date in YYYYMMDD format"},"metric":{"type":"string","required":false,"visibility":"user-or-llm","description":"Metric: 0 (ARPU), 1 (ARPPU), 2 (Total Revenue), 3 (Paying Users)"},"interval":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval: 1 (daily), 7 (weekly), or 30 (monthly)"},"groupBy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Property name to group by (limit: one)"},"segment":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON segment definition(s) applied to the query"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_group_identify":{"id":"amplitude_group_identify","name":"Amplitude Group Identify","description":"Set group-level properties in Amplitude. Supports $set, $setOnce, $add, $append, $unset operations.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"groupType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Group classification (e.g., \\"company\\", \\"org_id\\")"},"groupValue":{"type":"string","required":true,"visibility":"user-or-llm","description":"Specific group identifier (e.g., \\"Acme Corp\\")"},"groupProperties":{"type":"string","required":true,"visibility":"user-or-llm","description":"JSON object of group properties. Use operations like $set, $setOnce, $add, $append, $unset."},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_identify_user":{"id":"amplitude_identify_user","name":"Amplitude Identify User","description":"Set user properties in Amplitude using the Identify API. Supports $set, $setOnce, $add, $append, $unset operations.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"userId":{"type":"string","required":false,"visibility":"user-or-llm","description":"User ID (required if no device_id)"},"deviceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Device ID (required if no user_id)"},"userProperties":{"type":"string","required":true,"visibility":"user-or-llm","description":"JSON object of user properties. Use operations like $set, $setOnce, $add, $append, $unset."},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_list_events":{"id":"amplitude_list_events","name":"Amplitude List Events","description":"List all event types in the Amplitude project with their weekly totals and unique counts.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_realtime_active_users":{"id":"amplitude_realtime_active_users","name":"Amplitude Real-time Active Users","description":"Get real-time active user counts at 5-minute granularity for the last 2 days.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_retention":{"id":"amplitude_retention","name":"Amplitude Retention","description":"Measure how many users return to perform an action after a starting action.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"startEvent":{"type":"string","required":true,"visibility":"user-or-llm","description":"JSON starting event object, e.g. {\\"event_type\\":\\"_new\\"} or {\\"event_type\\":\\"_active\\"}"},"returnEvent":{"type":"string","required":true,"visibility":"user-or-llm","description":"JSON returning event object, e.g. {\\"event_type\\":\\"_all\\"} or {\\"event_type\\":\\"_active\\"}"},"start":{"type":"string","required":true,"visibility":"user-or-llm","description":"Start date in YYYYMMDD format"},"end":{"type":"string","required":true,"visibility":"user-or-llm","description":"End date in YYYYMMDD format"},"retentionMode":{"type":"string","required":false,"visibility":"user-or-llm","description":"Retention type: \\"bracket\\", \\"rolling\\", or \\"n-day\\" (default: n-day)"},"retentionBrackets":{"type":"string","required":false,"visibility":"user-or-llm","description":"Required when Retention Mode is \\"bracket\\". Day ranges, e.g. [[0,4]]"},"interval":{"type":"string","required":false,"visibility":"user-or-llm","description":"Time interval: 1 (daily), 7 (weekly), or 30 (monthly)"},"groupBy":{"type":"string","required":false,"visibility":"user-or-llm","description":"Property to group by (limit: one; prefix custom properties with \\"gp:\\")"},"segment":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON segment definition(s) applied to the query"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_send_event":{"id":"amplitude_send_event","name":"Amplitude Send Event","description":"Track an event in Amplitude using the HTTP V2 API.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"userId":{"type":"string","required":false,"visibility":"user-or-llm","description":"User ID (required if no device_id)"},"deviceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Device ID (required if no user_id)"},"eventType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the event (e.g., \\"page_view\\", \\"purchase\\")"},"eventProperties":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON object of custom event properties"},"userProperties":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON object of user properties to set (supports $set, $setOnce, $add, $append, $unset)"},"time":{"type":"string","required":false,"visibility":"user-or-llm","description":"Event timestamp in milliseconds since epoch"},"sessionId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Session start time in milliseconds since epoch"},"insertId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Unique ID for deduplication (within 7-day window)"},"appVersion":{"type":"string","required":false,"visibility":"user-or-llm","description":"Application version string"},"platform":{"type":"string","required":false,"visibility":"user-or-llm","description":"Platform (e.g., \\"Web\\", \\"iOS\\", \\"Android\\")"},"country":{"type":"string","required":false,"visibility":"user-or-llm","description":"Two-letter country code"},"language":{"type":"string","required":false,"visibility":"user-or-llm","description":"Language code (e.g., \\"en\\")"},"ip":{"type":"string","required":false,"visibility":"user-or-llm","description":"IP address for geo-location"},"price":{"type":"string","required":false,"visibility":"user-or-llm","description":"Price of the item purchased"},"quantity":{"type":"string","required":false,"visibility":"user-or-llm","description":"Quantity of items purchased"},"revenue":{"type":"string","required":false,"visibility":"user-or-llm","description":"Revenue amount"},"productId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Product identifier"},"revenueType":{"type":"string","required":false,"visibility":"user-or-llm","description":"Revenue type (e.g., \\"purchase\\", \\"refund\\")"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_user_activity":{"id":"amplitude_user_activity","name":"Amplitude User Activity","description":"Get the event stream for a specific user by their Amplitude ID.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"amplitudeId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Amplitude internal user ID"},"offset":{"type":"string","required":false,"visibility":"user-or-llm","description":"Offset for pagination (default 0)"},"limit":{"type":"string","required":false,"visibility":"user-or-llm","description":"Maximum number of events to return (default 1000, max 1000)"},"direction":{"type":"string","required":false,"visibility":"user-or-llm","description":"Sort direction: \\"latest\\" or \\"earliest\\" (default: latest)"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"amplitude_user_profile":{"id":"amplitude_user_profile","name":"Amplitude User Profile","description":"Get a user profile including properties, cohort memberships, and computed properties. Not available for EU data-residency projects.","version":"1.0.0","params":{"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"userId":{"type":"string","required":false,"visibility":"user-or-llm","description":"External user ID (required if no device_id)"},"deviceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Device ID (required if no user_id)"},"getAmpProps":{"type":"string","required":false,"visibility":"user-or-llm","description":"Include Amplitude user properties (true/false, default: false)"},"getCohortIds":{"type":"string","required":false,"visibility":"user-or-llm","description":"Include cohort IDs the user belongs to (true/false, default: false)"},"getComputations":{"type":"string","required":false,"visibility":"user-or-llm","description":"Include computed user properties (true/false, default: false)"}}},"amplitude_user_search":{"id":"amplitude_user_search","name":"Amplitude User Search","description":"Search for a user by User ID, Device ID, or Amplitude ID using the Dashboard REST API.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude API Key"},"secretKey":{"type":"string","required":true,"visibility":"user-only","description":"Amplitude Secret Key"},"user":{"type":"string","required":true,"visibility":"user-or-llm","description":"User ID, Device ID, or Amplitude ID to search for"},"dataResidency":{"type":"string","required":false,"visibility":"user-or-llm","description":"Data residency region: \\"us\\" (default) or \\"eu\\""}}},"apify_get_dataset_items":{"id":"apify_get_dataset_items","name":"APIFY Get Dataset Items","description":"Retrieve items stored in an APIFY dataset","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"APIFY API token from console.apify.com/account#/integrations"},"datasetId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Dataset ID to read items from. Example: \\"9RnD3Pql2vGZkc5H5\\""},"itemLimit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Max items to return (1-250000). Default: all items. Example: 500"},"offset":{"type":"number","required":false,"visibility":"user-or-llm","description":"Number of items to skip at the start. Default: 0"},"fields":{"type":"string","required":false,"visibility":"user-or-llm","description":"Comma-separated list of fields to include. Example: \\"title,url,price\\""}}},"apify_get_run":{"id":"apify_get_run","name":"APIFY Get Run","description":"Get the status and details of an APIFY actor run","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"APIFY API token from console.apify.com/account#/integrations"},"runId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Actor run ID to fetch. Example: \\"HG7ML7M8z78YcAPEB\\""}}},"apify_run_actor_async":{"id":"apify_run_actor_async","name":"APIFY Run Actor (Async)","description":"Run an APIFY actor asynchronously with polling for long-running tasks","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"APIFY API token from console.apify.com/account#/integrations"},"actorId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Actor ID or username/actor-name. Examples: \\"apify/web-scraper\\", \\"janedoe/my-actor\\", \\"moJRLRc85AitArpNN\\""},"input":{"type":"string","required":false,"visibility":"user-or-llm","description":"Actor input as JSON string. Example: {\\"startUrls\\": [{\\"url\\": \\"https://example.com\\"}], \\"maxPages\\": 10}"},"waitForFinish":{"type":"number","required":false,"visibility":"user-or-llm","description":"Initial wait time in seconds (0-60) before polling starts. Example: 30"},"itemLimit":{"type":"number","required":false,"default":100,"visibility":"user-or-llm","description":"Max dataset items to fetch (1-250000). Default: 100. Example: 500"},"memory":{"type":"number","required":false,"visibility":"user-or-llm","description":"Memory in megabytes allocated for the actor run (128-32768). Example: 1024 for 1GB, 2048 for 2GB"},"timeout":{"type":"number","required":false,"visibility":"user-or-llm","description":"Timeout in seconds for the actor run. Example: 300 for 5 minutes, 3600 for 1 hour"},"build":{"type":"string","required":false,"visibility":"user-or-llm","description":"Actor build to run. Examples: \\"latest\\", \\"beta\\", \\"1.2.3\\", \\"build-tag-name\\""}}},"apify_run_actor_sync":{"id":"apify_run_actor_sync","name":"APIFY Run Actor (Sync)","description":"Run an APIFY actor synchronously and get results (max 5 minutes)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"APIFY API token from console.apify.com/account#/integrations"},"actorId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Actor ID or username/actor-name. Examples: \\"apify/web-scraper\\", \\"janedoe/my-actor\\", \\"moJRLRc85AitArpNN\\""},"input":{"type":"string","required":false,"visibility":"user-or-llm","description":"Actor input as JSON string. Example: {\\"startUrls\\": [{\\"url\\": \\"https://example.com\\"}], \\"maxPages\\": 10}"},"memory":{"type":"number","required":false,"visibility":"user-or-llm","description":"Memory in megabytes allocated for the actor run (128-32768). Example: 1024 for 1GB, 2048 for 2GB"},"timeout":{"type":"number","required":false,"visibility":"user-or-llm","description":"Timeout in seconds for the actor run. Example: 300 for 5 minutes, 3600 for 1 hour"},"build":{"type":"string","required":false,"visibility":"user-or-llm","description":"Actor build to run. Examples: \\"latest\\", \\"beta\\", \\"1.2.3\\", \\"build-tag-name\\""}}},"apify_run_task":{"id":"apify_run_task","name":"APIFY Run Task","description":"Run a saved APIFY actor task synchronously and get dataset items (max 5 minutes)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"APIFY API token from console.apify.com/account#/integrations"},"taskId":{"type":"string","required":true,"visibility":"user-or-llm","description":"Task ID or username/task-name. Examples: \\"janedoe/my-task\\", \\"moJRLRc85AitArpNN\\""},"input":{"type":"string","required":false,"visibility":"user-or-llm","description":"JSON string that overrides the task\'s saved input. Example: {\\"startUrls\\": [{\\"url\\": \\"https://example.com\\"}]}"},"itemLimit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Max dataset items to return (1-250000). Example: 500"},"memory":{"type":"number","required":false,"visibility":"user-or-llm","description":"Memory in megabytes allocated for the run (128-32768). Example: 1024 for 1GB"},"timeout":{"type":"number","required":false,"visibility":"user-or-llm","description":"Timeout in seconds for the run. Example: 300 for 5 minutes"},"build":{"type":"string","required":false,"visibility":"user-or-llm","description":"Actor build to run. Examples: \\"latest\\", \\"beta\\", \\"1.2.3\\""}}},"apollo_account_bulk_create":{"id":"apollo_account_bulk_create","name":"Apollo Bulk Create Accounts","description":"Create up to 100 accounts at once in your Apollo database. Set run_dedupe=true to deduplicate by domain, organization_id, and name. Master key required.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"accounts":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of accounts to create (max 100). Each account should include a name, and may optionally include domain, phone, phone_status_cd, raw_address, owner_id, linkedin_url, facebook_url, twitter_url, salesforce_id, and hubspot_id."},"append_label_names":{"type":"array","required":false,"visibility":"user-only","description":"Array of label names to add to ALL accounts in this request"},"run_dedupe":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"When true, performs aggressive deduplication by domain, organization_id, and name (defaults to false)"}}},"apollo_account_bulk_update":{"id":"apollo_account_bulk_update","name":"Apollo Bulk Update Accounts","description":"Update up to 1000 existing accounts at once in your Apollo database (higher limit than contacts!). Each account must include an id field. Master key required.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"account_ids":{"type":"array","required":false,"visibility":"user-or-llm","description":"Array of account IDs to update with the same values (max 1000). Use with name/owner_id for uniform updates. Use either this OR account_attributes."},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"When using account_ids, apply this name to all accounts"},"owner_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"When using account_ids, apply this owner to all accounts"},"account_stage_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"When using account_ids, apply this account stage to all accounts"},"account_attributes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of account objects with individual updates (each must include id). Example: [{\\"id\\": \\"acc1\\", \\"name\\": \\"Acme\\", \\"owner_id\\": \\"u1\\", \\"account_stage_id\\": \\"s1\\", \\"typed_custom_fields\\": {\\"field_id\\": \\"value\\"}}]"},"async":{"type":"boolean","required":false,"visibility":"user-only","description":"When true, processes the update asynchronously. Only supported when using account_ids; returns 422 if used with account_attributes."}}},"apollo_account_create":{"id":"apollo_account_create","name":"Apollo Create Account","description":"Create a new account (company) in your Apollo database","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Company name (e.g., \\"Acme Corporation\\")"},"domain":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company domain without www. prefix (e.g., \\"acme.com\\")"},"phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Primary phone number for the account"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"Apollo user ID of the account owner"},"account_stage_id":{"type":"string","required":false,"visibility":"user-only","description":"Apollo ID for the account stage to assign this account to"},"raw_address":{"type":"string","required":false,"visibility":"user-or-llm","description":"Corporate location (e.g., \\"San Francisco, CA, USA\\")"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-only","description":"Custom field values as { custom_field_id: value } map"}}},"apollo_account_search":{"id":"apollo_account_search","name":"Apollo Search Accounts","description":"Search your team\'s accounts in Apollo. Display limit: 50,000 records (100 records per page, 500 pages max). Use filters to narrow results. Master key required.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"q_organization_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter accounts by organization name (partial-match search)"},"account_stage_ids":{"type":"array","required":false,"visibility":"user-only","description":"Filter by account stage IDs"},"account_label_ids":{"type":"array","required":false,"visibility":"user-only","description":"Filter by account label IDs"},"sort_by_field":{"type":"string","required":false,"visibility":"user-or-llm","description":"Sort field: \\"account_last_activity_date\\", \\"account_created_at\\", or \\"account_updated_at\\""},"sort_ascending":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Sort ascending when true. Defaults to descending."},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"apollo_account_update":{"id":"apollo_account_update","name":"Apollo Update Account","description":"Update an existing account in your Apollo database","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"account_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the account to update (e.g., \\"acc_abc123\\")"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company name (e.g., \\"Acme Corporation\\")"},"domain":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company domain (e.g., \\"acme.com\\")"},"phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company phone number"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"Apollo user ID of the account owner"},"account_stage_id":{"type":"string","required":false,"visibility":"user-only","description":"Apollo ID for the account stage to assign this account to"},"raw_address":{"type":"string","required":false,"visibility":"user-or-llm","description":"Corporate location (e.g., \\"San Francisco, CA, USA\\")"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-only","description":"Custom field values as { custom_field_id: value } map"}}},"apollo_contact_bulk_create":{"id":"apollo_contact_bulk_create","name":"Apollo Bulk Create Contacts","description":"Create up to 100 contacts at once in your Apollo database. Supports deduplication to prevent creating duplicate contacts. Master key required.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"contacts":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of contacts to create (max 100). Each contact may include first_name, last_name, email, title, organization_name, account_id, owner_id, contact_stage_id, linkedin_url, phone (single string) or phone_numbers (array of {raw_number, position}), contact_emails, typed_custom_fields, and CRM IDs (salesforce_contact_id, hubspot_id, team_id) for cross-system matching"},"append_label_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Label names to add to all contacts in this request (e.g., [\\"Hot Lead\\"])"},"run_dedupe":{"type":"boolean","required":false,"visibility":"user-only","description":"Enable deduplication to prevent creating duplicate contacts. When true, existing contacts are returned without modification"}}},"apollo_contact_bulk_update":{"id":"apollo_contact_bulk_update","name":"Apollo Bulk Update Contacts","description":"Update up to 100 existing contacts at once in your Apollo database. Each contact must include an id field. Master key required.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"contact_ids":{"type":"array","required":false,"visibility":"user-or-llm","description":"Array of contact IDs to update. Must be paired with an object-form contact_attributes specifying the fields to apply uniformly to all listed contacts."},"contact_attributes":{"type":"json","required":false,"visibility":"user-or-llm","description":"Required. Either an array of per-contact updates (each with id) β€” used standalone β€” or a single object of attributes to apply to all contact_ids. Supported fields: owner_id, email, organization_name, title, first_name, last_name, account_id, present_raw_address, linkedin_url, typed_custom_fields"},"async":{"type":"boolean","required":false,"visibility":"user-only","description":"Force asynchronous processing. Automatically enabled for >100 contacts"}}},"apollo_contact_create":{"id":"apollo_contact_create","name":"Apollo Create Contact","description":"Create a new contact in your Apollo database","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"first_name":{"type":"string","required":true,"visibility":"user-or-llm","description":"First name of the contact"},"last_name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Last name of the contact"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"Email address of the contact"},"title":{"type":"string","required":false,"visibility":"user-or-llm","description":"Job title (e.g., \\"VP of Sales\\", \\"Software Engineer\\")"},"account_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"Apollo account ID to associate with (e.g., \\"acc_abc123\\")"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"User ID of the contact owner (accepted by Apollo but not officially documented for POST /contacts)"},"organization_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Name of the contact\'s employer (e.g., \\"Apollo\\")"},"website_url":{"type":"string","required":false,"visibility":"user-or-llm","description":"Corporate website URL (e.g., \\"https://www.apollo.io/\\")"},"label_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Lists/labels to add the contact to (e.g., [\\"Prospects\\"])"},"contact_stage_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"Apollo ID for the contact stage"},"present_raw_address":{"type":"string","required":false,"visibility":"user-or-llm","description":"Personal location for the contact (e.g., \\"Atlanta, United States\\")"},"direct_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Primary phone number"},"corporate_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Work/office phone number"},"mobile_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Mobile phone number"},"home_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Home phone number"},"other_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Alternative phone number"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-or-llm","description":"Custom field values keyed by custom field ID"},"run_dedupe":{"type":"boolean","required":false,"visibility":"user-only","description":"When true, Apollo deduplicates against existing contacts"}}},"apollo_contact_search":{"id":"apollo_contact_search","name":"Apollo Search Contacts","description":"Search your team\'s contacts in Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"q_keywords":{"type":"string","required":false,"visibility":"user-or-llm","description":"Keywords to search for"},"contact_stage_ids":{"type":"array","required":false,"visibility":"user-only","description":"Filter by contact stage IDs"},"contact_label_ids":{"type":"array","required":false,"visibility":"user-only","description":"Filter by Apollo label IDs (lists)"},"sort_by_field":{"type":"string","required":false,"visibility":"user-only","description":"Sort field: contact_last_activity_date, contact_email_last_opened_at, contact_email_last_clicked_at, contact_created_at, or contact_updated_at"},"sort_ascending":{"type":"boolean","required":false,"visibility":"user-only","description":"When true, sort ascending. Must be used together with sort_by_field"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"apollo_contact_update":{"id":"apollo_contact_update","name":"Apollo Update Contact","description":"Update an existing contact in your Apollo database","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"contact_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the contact to update (e.g., \\"con_abc123\\")"},"first_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"First name of the contact"},"last_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Last name of the contact"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"Email address"},"title":{"type":"string","required":false,"visibility":"user-or-llm","description":"Job title (e.g., \\"VP of Sales\\", \\"Software Engineer\\")"},"account_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"Apollo account ID (e.g., \\"acc_abc123\\")"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"User ID of the contact owner (accepted by Apollo but not officially documented for PATCH /contacts/{id})"},"organization_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Name of the contact\'s employer (e.g., \\"Apollo\\")"},"website_url":{"type":"string","required":false,"visibility":"user-or-llm","description":"Corporate website URL (e.g., \\"https://www.apollo.io/\\")"},"label_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Lists/labels to add the contact to (e.g., [\\"Prospects\\"])"},"contact_stage_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"Apollo ID for the contact stage"},"present_raw_address":{"type":"string","required":false,"visibility":"user-or-llm","description":"Personal location for the contact (e.g., \\"Atlanta, United States\\")"},"direct_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Primary phone number"},"corporate_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Work/office phone number"},"mobile_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Mobile phone number"},"home_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Home phone number"},"other_phone":{"type":"string","required":false,"visibility":"user-or-llm","description":"Alternative phone number"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-or-llm","description":"Custom field values keyed by custom field ID"}}},"apollo_email_accounts":{"id":"apollo_email_accounts","name":"Apollo Get Email Accounts","description":"Get list of team\'s linked email accounts in Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"}}},"apollo_opportunity_create":{"id":"apollo_opportunity_create","name":"Apollo Create Opportunity","description":"Create a new deal for an account in your Apollo database (master key required)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the opportunity/deal (e.g., \\"Enterprise License - Q1\\")"},"account_id":{"type":"string","required":false,"visibility":"user-or-llm","description":"ID of the account this opportunity belongs to (e.g., \\"acc_abc123\\")"},"amount":{"type":"string","required":false,"visibility":"user-or-llm","description":"Monetary value as a plain number string with no commas or currency symbols"},"opportunity_stage_id":{"type":"string","required":false,"visibility":"user-only","description":"ID of the opportunity stage"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"User ID of the opportunity owner"},"closed_date":{"type":"string","required":false,"visibility":"user-or-llm","description":"Expected close date in YYYY-MM-DD format"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-only","description":"Custom field values as { custom_field_id: value } map"}}},"apollo_opportunity_get":{"id":"apollo_opportunity_get","name":"Apollo Get Opportunity","description":"Retrieve complete details of a specific deal/opportunity by ID","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"opportunity_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the opportunity to retrieve (e.g., \\"opp_abc123\\")"}}},"apollo_opportunity_search":{"id":"apollo_opportunity_search","name":"Apollo Search Opportunities","description":"Search and list all deals/opportunities in your team\'s Apollo account","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"sort_by_field":{"type":"string","required":false,"visibility":"user-or-llm","description":"Sort field: \\"amount\\", \\"is_closed\\", or \\"is_won\\""},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"apollo_opportunity_update":{"id":"apollo_opportunity_update","name":"Apollo Update Opportunity","description":"Update an existing deal/opportunity in your Apollo database","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"opportunity_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the opportunity to update (e.g., \\"opp_abc123\\")"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Name of the opportunity/deal (e.g., \\"Enterprise License - Q1\\")"},"amount":{"type":"string","required":false,"visibility":"user-or-llm","description":"Monetary value as a plain number string with no commas or currency symbols"},"opportunity_stage_id":{"type":"string","required":false,"visibility":"user-only","description":"ID of the opportunity stage"},"owner_id":{"type":"string","required":false,"visibility":"user-only","description":"User ID of the opportunity owner"},"closed_date":{"type":"string","required":false,"visibility":"user-or-llm","description":"Expected close date in YYYY-MM-DD format"},"typed_custom_fields":{"type":"json","required":false,"visibility":"user-only","description":"Custom field values as { custom_field_id: value } map"}}},"apollo_organization_bulk_enrich":{"id":"apollo_organization_bulk_enrich","name":"Apollo Bulk Organization Enrichment","description":"Enrich data for up to 10 organizations at once using Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"domains":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of company domains to enrich (max 10, no www. or @, e.g., [\\"apollo.io\\", \\"stripe.com\\"])"}}},"apollo_organization_enrich":{"id":"apollo_organization_enrich","name":"Apollo Organization Enrichment","description":"Enrich data for a single organization using Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"domain":{"type":"string","required":true,"visibility":"user-or-llm","description":"Company domain (e.g., \\"apollo.io\\", \\"acme.com\\")"}}},"apollo_organization_search":{"id":"apollo_organization_search","name":"Apollo Organization Search","description":"Search Apollo\'s database for companies using filters","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"organization_locations":{"type":"array","required":false,"visibility":"user-or-llm","description":"Company HQ locations (cities, US states, or countries)"},"organization_not_locations":{"type":"array","required":false,"visibility":"user-or-llm","description":"Exclude companies whose HQ is in these locations"},"organization_num_employees_ranges":{"type":"array","required":false,"visibility":"user-or-llm","description":"Employee count ranges as \\"min,max\\" strings (e.g., [\\"1,10\\", \\"250,500\\", \\"10000,20000\\"])"},"q_organization_keyword_tags":{"type":"array","required":false,"visibility":"user-or-llm","description":"Industry or keyword tags"},"q_organization_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Organization name to search for (e.g., \\"Acme\\", \\"TechCorp\\")"},"organization_ids":{"type":"array","required":false,"visibility":"user-or-llm","description":"Apollo organization IDs to include (e.g., [\\"5e66b6381e05b4008c8331b8\\"])"},"q_organization_domains_list":{"type":"array","required":false,"visibility":"user-or-llm","description":"Domain names to filter by (no www. or @, up to 1,000)"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"apollo_people_bulk_enrich":{"id":"apollo_people_bulk_enrich","name":"Apollo Bulk People Enrichment","description":"Enrich data for up to 10 people at once using Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"people":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of people to enrich (max 10)"},"reveal_personal_emails":{"type":"boolean","required":false,"visibility":"user-only","description":"Reveal personal email addresses (uses credits)"},"reveal_phone_number":{"type":"boolean","required":false,"visibility":"user-only","description":"Reveal phone numbers (uses credits, requires webhook_url)"},"webhook_url":{"type":"string","required":false,"visibility":"user-only","description":"Webhook URL for async phone number delivery (required when reveal_phone_number is true)"}}},"apollo_people_enrich":{"id":"apollo_people_enrich","name":"Apollo People Enrichment","description":"Enrich data for a single person using Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"first_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"First name of the person"},"last_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Last name of the person"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Full name of the person (alternative to first_name/last_name)"},"id":{"type":"string","required":false,"visibility":"user-or-llm","description":"Apollo ID for the person"},"hashed_email":{"type":"string","required":false,"visibility":"user-or-llm","description":"MD5 or SHA-256 hashed email"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"Email address of the person"},"organization_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company name where the person works"},"domain":{"type":"string","required":false,"visibility":"user-or-llm","description":"Company domain (e.g., \\"apollo.io\\", \\"acme.com\\")"},"linkedin_url":{"type":"string","required":false,"visibility":"user-or-llm","description":"LinkedIn profile URL"},"reveal_personal_emails":{"type":"boolean","required":false,"visibility":"user-only","description":"Reveal personal email addresses (uses credits)"},"reveal_phone_number":{"type":"boolean","required":false,"visibility":"user-only","description":"Reveal phone numbers (uses credits, requires webhook_url)"},"webhook_url":{"type":"string","required":false,"visibility":"user-only","description":"Webhook URL for async phone number delivery (required when reveal_phone_number is true)"}}},"apollo_people_search":{"id":"apollo_people_search","name":"Apollo People Search","description":"Search Apollo\'s database for people using demographic filters","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key"},"person_titles":{"type":"array","required":false,"visibility":"user-or-llm","description":"Job titles to search for (e.g., [\\"CEO\\", \\"VP of Sales\\"])"},"include_similar_titles":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Whether to return people with job titles similar to person_titles"},"person_locations":{"type":"array","required":false,"visibility":"user-or-llm","description":"Locations to search in (e.g., [\\"San Francisco, CA\\", \\"New York, NY\\"])"},"person_seniorities":{"type":"array","required":false,"visibility":"user-or-llm","description":"Seniority levels (one of: owner, founder, c_suite, partner, vp, head, director, manager, senior, entry, intern)"},"organization_ids":{"type":"array","required":false,"visibility":"user-or-llm","description":"Apollo organization IDs to filter by (e.g., [\\"5e66b6381e05b4008c8331b8\\"])"},"organization_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Company names to search within (legacy filter)"},"organization_locations":{"type":"array","required":false,"visibility":"user-or-llm","description":"Headquarters locations of the people\'s current employer (e.g., [\'texas\', \'tokyo\', \'spain\'])"},"q_organization_domains_list":{"type":"array","required":false,"visibility":"user-or-llm","description":"Employer domain names (e.g., [\\"apollo.io\\", \\"microsoft.com\\"]) β€” up to 1,000, no www. or @"},"organization_num_employees_ranges":{"type":"array","required":false,"visibility":"user-or-llm","description":"Employee count ranges for the person\'s current employer. Each entry is \\"min,max\\" (e.g., [\\"1,10\\", \\"250,500\\", \\"10000,20000\\"])"},"contact_email_status":{"type":"array","required":false,"visibility":"user-or-llm","description":"Email statuses to filter by: \\"verified\\", \\"unverified\\", \\"likely to engage\\", \\"unavailable\\""},"q_keywords":{"type":"string","required":false,"visibility":"user-or-llm","description":"Keywords to search for"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination, default 1 (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, default 25, max 100 (e.g., 25, 50, 100)"}}},"apollo_sequence_add_contacts":{"id":"apollo_sequence_add_contacts","name":"Apollo Add Contacts to Sequence","description":"Add contacts to an Apollo sequence","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"sequence_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the sequence to add contacts to (e.g., \\"seq_abc123\\")"},"contact_ids":{"type":"array","required":false,"visibility":"user-or-llm","description":"Array of contact IDs to add to the sequence (e.g., [\\"con_abc123\\", \\"con_def456\\"]). Either contact_ids or label_names must be provided."},"label_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Array of label names to identify contacts to add to the sequence. Either contact_ids or label_names must be provided."},"send_email_from_email_account_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the email account to send from. Use the Get Email Accounts operation to look this up."},"send_email_from_email_address":{"type":"string","required":false,"visibility":"user-only","description":"Specific email address to send from within the email account."},"sequence_no_email":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts even if they have no email address"},"sequence_unverified_email":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts with unverified email addresses"},"sequence_job_change":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts who recently changed jobs"},"sequence_active_in_other_campaigns":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts active in other campaigns"},"sequence_finished_in_other_campaigns":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts who finished other campaigns"},"sequence_same_company_in_same_campaign":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts even if others from the same company are in the sequence"},"contacts_without_ownership_permission":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts without ownership permission"},"add_if_in_queue":{"type":"boolean","required":false,"visibility":"user-only","description":"Add contacts even if they are in the queue"},"contact_verification_skipped":{"type":"boolean","required":false,"visibility":"user-only","description":"Skip contact verification when adding"},"user_id":{"type":"string","required":false,"visibility":"user-only","description":"ID of the user performing the action"},"status":{"type":"string","required":false,"visibility":"user-only","description":"Initial status for added contacts: \\"active\\" or \\"paused\\""},"auto_unpause_at":{"type":"string","required":false,"visibility":"user-only","description":"ISO 8601 datetime to automatically unpause contacts"}}},"apollo_sequence_search":{"id":"apollo_sequence_search","name":"Apollo Search Sequences","description":"Search for sequences/campaigns in your team\'s Apollo account (master key required)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"q_name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Search sequences by name (e.g., \\"Outbound Q1\\", \\"Follow-up\\")"},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"apollo_task_create":{"id":"apollo_task_create","name":"Apollo Create Task","description":"Create one or more tasks in Apollo (one task per contact_id, master key required)","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"user_id":{"type":"string","required":true,"visibility":"user-or-llm","description":"ID of the Apollo user the task is assigned to"},"contact_ids":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of contact IDs. One task is created per contact."},"priority":{"type":"string","required":false,"visibility":"user-or-llm","description":"Task priority: \\"high\\", \\"medium\\", or \\"low\\" (defaults to \\"medium\\")"},"due_at":{"type":"string","required":true,"visibility":"user-or-llm","description":"Due date/time in ISO 8601 format (e.g., \\"2024-12-31T23:59:59Z\\")"},"type":{"type":"string","required":true,"visibility":"user-or-llm","description":"Task type: \\"call\\", \\"outreach_manual_email\\", \\"linkedin_step_connect\\", \\"linkedin_step_message\\", \\"linkedin_step_view_profile\\", \\"linkedin_step_interact_post\\", or \\"action_item\\""},"status":{"type":"string","required":true,"visibility":"user-or-llm","description":"Task status: \\"scheduled\\", \\"completed\\", or \\"skipped\\""},"note":{"type":"string","required":false,"visibility":"user-or-llm","description":"Free-form note providing context for the task"}}},"apollo_task_search":{"id":"apollo_task_search","name":"Apollo Search Tasks","description":"Search for tasks in Apollo","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Apollo API key (master key required)"},"sort_by_field":{"type":"string","required":false,"visibility":"user-or-llm","description":"Sort field: \\"task_due_at\\" or \\"task_priority\\""},"open_factor_names":{"type":"array","required":false,"visibility":"user-or-llm","description":"Filter by status. Common values: [\\"task_types\\"] for open tasks, [\\"task_completed_at\\"] for completed tasks."},"page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Page number for pagination (e.g., 1, 2, 3)"},"per_page":{"type":"number","required":false,"visibility":"user-or-llm","description":"Results per page, max 100 (e.g., 25, 50, 100)"}}},"appconfig_create_application":{"id":"appconfig_create_application","name":"AppConfig Create Application","description":"Create an application in AWS AppConfig","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the application to create"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"Description of the application"}}},"appconfig_create_configuration_profile":{"id":"appconfig_create_configuration_profile","name":"AppConfig Create Configuration Profile","description":"Create a configuration profile in an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to create the configuration profile in"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the configuration profile"},"locationUri":{"type":"string","required":true,"visibility":"user-or-llm","description":"Where the configuration is stored. Use \\"hosted\\" for AppConfig-hosted configurations, or an SSM/S3 URI"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"Description of the configuration profile"},"retrievalRoleArn":{"type":"string","required":false,"visibility":"user-or-llm","description":"ARN of an IAM role to retrieve the configuration (required for non-hosted URIs)"},"type":{"type":"string","required":false,"visibility":"user-or-llm","description":"Profile type: AWS.Freeform (default) or AWS.AppConfig.FeatureFlags"}}},"appconfig_create_environment":{"id":"appconfig_create_environment","name":"AppConfig Create Environment","description":"Create an environment for an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to create the environment in"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the environment to create"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"Description of the environment"}}},"appconfig_create_hosted_configuration_version":{"id":"appconfig_create_hosted_configuration_version","name":"AppConfig Create Hosted Configuration Version","description":"Create a new hosted configuration version for an AppConfig configuration profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to add the version to"},"content":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration content (e.g., a JSON or YAML document)"},"contentType":{"type":"string","required":true,"visibility":"user-or-llm","description":"Content type of the configuration (e.g., application/json, text/plain)"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"Description of the configuration version"},"latestVersionNumber":{"type":"number","required":false,"visibility":"user-or-llm","description":"The version number of the latest version, used for optimistic concurrency"},"versionLabel":{"type":"string","required":false,"visibility":"user-or-llm","description":"A user-defined label for the configuration version"}}},"appconfig_delete_application":{"id":"appconfig_delete_application","name":"AppConfig Delete Application","description":"Delete an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to delete"}}},"appconfig_delete_configuration_profile":{"id":"appconfig_delete_configuration_profile","name":"AppConfig Delete Configuration Profile","description":"Delete an AWS AppConfig configuration profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to delete"}}},"appconfig_delete_environment":{"id":"appconfig_delete_environment","name":"AppConfig Delete Environment","description":"Delete an AWS AppConfig environment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the environment"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID to delete"}}},"appconfig_delete_hosted_configuration_version":{"id":"appconfig_delete_hosted_configuration_version","name":"AppConfig Delete Hosted Configuration Version","description":"Delete a specific hosted configuration version from an AppConfig profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID that owns the version"},"versionNumber":{"type":"number","required":true,"visibility":"user-or-llm","description":"The version number to delete"}}},"appconfig_get_application":{"id":"appconfig_get_application","name":"AppConfig Get Application","description":"Get details about a single AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to retrieve"}}},"appconfig_get_configuration":{"id":"appconfig_get_configuration","name":"AppConfig Get Configuration","description":"Retrieve the latest deployed configuration for an AppConfig application, environment, and profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID or name to retrieve configuration for"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID or name to retrieve configuration for"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID or name to retrieve"}}},"appconfig_get_configuration_profile":{"id":"appconfig_get_configuration_profile","name":"AppConfig Get Configuration Profile","description":"Get details about a single AWS AppConfig configuration profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to retrieve"}}},"appconfig_get_deployment":{"id":"appconfig_get_deployment","name":"AppConfig Get Deployment","description":"Get details about a specific AWS AppConfig deployment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID of the deployment"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID of the deployment"},"deploymentNumber":{"type":"number","required":true,"visibility":"user-or-llm","description":"The sequence number of the deployment"}}},"appconfig_get_environment":{"id":"appconfig_get_environment","name":"AppConfig Get Environment","description":"Get details about a single AWS AppConfig environment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the environment"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID to retrieve"}}},"appconfig_get_hosted_configuration_version":{"id":"appconfig_get_hosted_configuration_version","name":"AppConfig Get Hosted Configuration Version","description":"Retrieve a specific hosted configuration version from an AppConfig profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to read the version from"},"versionNumber":{"type":"number","required":true,"visibility":"user-or-llm","description":"The version number to retrieve"}}},"appconfig_list_applications":{"id":"appconfig_list_applications","name":"AppConfig List Applications","description":"List applications in AWS AppConfig","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of applications to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_list_configuration_profiles":{"id":"appconfig_list_configuration_profiles","name":"AppConfig List Configuration Profiles","description":"List configuration profiles for an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profiles"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of configuration profiles to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_list_deployment_strategies":{"id":"appconfig_list_deployment_strategies","name":"AppConfig List Deployment Strategies","description":"List deployment strategies available in AWS AppConfig","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of deployment strategies to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_list_deployments":{"id":"appconfig_list_deployments","name":"AppConfig List Deployments","description":"List deployments for an AWS AppConfig environment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID of the deployments"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID of the deployments"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of deployments to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_list_environments":{"id":"appconfig_list_environments","name":"AppConfig List Environments","description":"List environments for an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the environments"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of environments to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_list_hosted_configuration_versions":{"id":"appconfig_list_hosted_configuration_versions","name":"AppConfig List Hosted Configuration Versions","description":"List hosted configuration versions for an AWS AppConfig configuration profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to list versions for"},"maxResults":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of versions to return (1-50)"},"nextToken":{"type":"string","required":false,"visibility":"user-or-llm","description":"Pagination token from a previous response"}}},"appconfig_start_deployment":{"id":"appconfig_start_deployment","name":"AppConfig Start Deployment","description":"Start deploying a configuration version to an AWS AppConfig environment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to deploy in"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID to deploy to"},"deploymentStrategyId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The deployment strategy ID to use"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to deploy"},"configurationVersion":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration version to deploy"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"Description of the deployment"}}},"appconfig_stop_deployment":{"id":"appconfig_stop_deployment","name":"AppConfig Stop Deployment","description":"Stop an in-progress AWS AppConfig deployment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID of the deployment"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID of the deployment"},"deploymentNumber":{"type":"number","required":true,"visibility":"user-or-llm","description":"The sequence number of the deployment to stop"}}},"appconfig_update_application":{"id":"appconfig_update_application","name":"AppConfig Update Application","description":"Update the name or description of an AWS AppConfig application","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID to update"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"New name for the application"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"New description for the application"}}},"appconfig_update_configuration_profile":{"id":"appconfig_update_configuration_profile","name":"AppConfig Update Configuration Profile","description":"Update the name, description, or retrieval role of an AppConfig configuration profile","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the configuration profile"},"configurationProfileId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The configuration profile ID to update"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"New name for the configuration profile"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"New description for the configuration profile"},"retrievalRoleArn":{"type":"string","required":false,"visibility":"user-or-llm","description":"New ARN of the IAM role used to retrieve the configuration"}}},"appconfig_update_environment":{"id":"appconfig_update_environment","name":"AppConfig Update Environment","description":"Update the name or description of an AWS AppConfig environment","version":"1.0","params":{"region":{"type":"string","required":true,"visibility":"user-only","description":"AWS region (e.g., us-east-1)"},"accessKeyId":{"type":"string","required":true,"visibility":"user-only","description":"AWS access key ID"},"secretAccessKey":{"type":"string","required":true,"visibility":"user-only","description":"AWS secret access key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The application ID that owns the environment"},"environmentId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The environment ID to update"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"New name for the environment"},"description":{"type":"string","required":false,"visibility":"user-or-llm","description":"New description for the environment"}}},"arxiv_get_author_papers":{"id":"arxiv_get_author_papers","name":"ArXiv Get Author Papers","description":"Search for papers by a specific author on ArXiv.","version":"1.0.0","params":{"authorName":{"type":"string","required":true,"visibility":"user-or-llm","description":"Author name to search for"},"maxResults":{"type":"number","required":false,"visibility":"user-only","description":"Maximum number of results to return (default: 10, max: 2000)"}}},"arxiv_get_paper":{"id":"arxiv_get_paper","name":"ArXiv Get Paper","description":"Get detailed information about a specific ArXiv paper by its ID.","version":"1.0.0","params":{"paperId":{"type":"string","required":true,"visibility":"user-or-llm","description":"ArXiv paper ID (e.g., \\"1706.03762\\")"}}},"arxiv_search":{"id":"arxiv_search","name":"ArXiv Search","description":"Search for academic papers on ArXiv by keywords, authors, titles, or other fields.","version":"1.0.0","params":{"searchQuery":{"type":"string","required":true,"visibility":"user-or-llm","description":"The search query to execute"},"searchField":{"type":"string","required":false,"visibility":"user-only","description":"Field to search in: all, ti (title), au (author), abs (abstract), co (comment), jr (journal), cat (category), rn (report number)"},"maxResults":{"type":"number","required":false,"visibility":"user-only","description":"Maximum number of results to return (default: 10, max: 2000)"},"sortBy":{"type":"string","required":false,"visibility":"user-only","description":"Sort by: relevance, lastUpdatedDate, submittedDate (default: relevance)"},"sortOrder":{"type":"string","required":false,"visibility":"user-only","description":"Sort order: ascending, descending (default: descending)"}}},"asana_add_comment":{"id":"asana_add_comment","name":"Asana Add Comment","description":"Add a comment (story) to an Asana task","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana task GID (numeric string)"},"text":{"type":"string","required":true,"visibility":"user-or-llm","description":"The text content of the comment"}},"oauth":{"required":true,"provider":"asana"}},"asana_add_followers":{"id":"asana_add_followers","name":"Asana Add Followers","description":"Add one or more followers to an Asana task","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"GID of the Asana task (numeric string)"},"followers":{"type":"array","required":true,"visibility":"user-or-llm","description":"Array of user GIDs to add as followers to the task"}},"oauth":{"required":true,"provider":"asana"}},"asana_create_project":{"id":"asana_create_project","name":"Asana Create Project","description":"Create a new project in an Asana workspace","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"workspace":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana workspace GID (numeric string) where the project will be created"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the project"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"Notes or description for the project"}},"oauth":{"required":true,"provider":"asana"}},"asana_create_section":{"id":"asana_create_section","name":"Asana Create Section","description":"Create a new section in an Asana project","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"projectGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"GID of the Asana project (numeric string) to add the section to"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the section"}},"oauth":{"required":true,"provider":"asana"}},"asana_create_subtask":{"id":"asana_create_subtask","name":"Asana Create Subtask","description":"Create a subtask under an existing Asana task","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"GID of the parent Asana task (numeric string)"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the subtask"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"Notes or description for the subtask"},"assignee":{"type":"string","required":false,"visibility":"user-or-llm","description":"User GID to assign the subtask to"},"due_on":{"type":"string","required":false,"visibility":"user-or-llm","description":"Due date in YYYY-MM-DD format"}},"oauth":{"required":true,"provider":"asana"}},"asana_create_task":{"id":"asana_create_task","name":"Asana Create Task","description":"Create a new task in Asana","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"workspace":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana workspace GID (numeric string) where the task will be created"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"Name of the task"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"Notes or description for the task"},"assignee":{"type":"string","required":false,"visibility":"user-or-llm","description":"User GID to assign the task to"},"due_on":{"type":"string","required":false,"visibility":"user-or-llm","description":"Due date in YYYY-MM-DD format"}},"oauth":{"required":true,"provider":"asana"}},"asana_delete_task":{"id":"asana_delete_task","name":"Asana Delete Task","description":"Delete an Asana task by its GID (moves it to the trash)","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"GID of the Asana task to delete (numeric string)"}},"oauth":{"required":true,"provider":"asana"}},"asana_get_project":{"id":"asana_get_project","name":"Asana Get Project","description":"Retrieve a single Asana project by its GID","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"projectGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana project GID (numeric string) to retrieve"}},"oauth":{"required":true,"provider":"asana"}},"asana_get_projects":{"id":"asana_get_projects","name":"Asana Get Projects","description":"Retrieve all projects from an Asana workspace","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"workspace":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana workspace GID (numeric string) to retrieve projects from"}},"oauth":{"required":true,"provider":"asana"}},"asana_get_task":{"id":"asana_get_task","name":"Asana Get Task","description":"Retrieve a single task by GID or get multiple tasks with filters","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":false,"visibility":"user-or-llm","description":"The globally unique identifier (GID) of the task. If not provided, will get multiple tasks."},"workspace":{"type":"string","required":false,"visibility":"user-or-llm","description":"Asana workspace GID (numeric string) to filter tasks (required when not using taskGid)"},"project":{"type":"string","required":false,"visibility":"user-or-llm","description":"Asana project GID (numeric string) to filter tasks"},"limit":{"type":"number","required":false,"visibility":"user-or-llm","description":"Maximum number of tasks to return (default: 50)"}},"oauth":{"required":true,"provider":"asana"}},"asana_list_sections":{"id":"asana_list_sections","name":"Asana List Sections","description":"List all sections in an Asana project","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"projectGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"GID of the Asana project (numeric string) to list sections from"}},"oauth":{"required":true,"provider":"asana"}},"asana_list_workspaces":{"id":"asana_list_workspaces","name":"Asana List Workspaces","description":"List all Asana workspaces and organizations the authenticated user belongs to","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"}},"oauth":{"required":true,"provider":"asana"}},"asana_search_tasks":{"id":"asana_search_tasks","name":"Asana Search Tasks","description":"Search for tasks in an Asana workspace","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"workspace":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana workspace GID (numeric string) to search tasks in"},"text":{"type":"string","required":false,"visibility":"user-or-llm","description":"Text to search for in task names"},"assignee":{"type":"string","required":false,"visibility":"user-or-llm","description":"Filter tasks by assignee user GID"},"projects":{"type":"array","required":false,"visibility":"user-or-llm","description":"Array of Asana project GIDs (numeric strings) to filter tasks by"},"completed":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Filter by completion status"}},"oauth":{"required":true,"provider":"asana"}},"asana_update_task":{"id":"asana_update_task","name":"Asana Update Task","description":"Update an existing task in Asana","version":"1.0.0","params":{"accessToken":{"type":"string","required":true,"visibility":"hidden","description":"OAuth access token for Asana"},"taskGid":{"type":"string","required":true,"visibility":"user-or-llm","description":"Asana task GID (numeric string) of the task to update"},"name":{"type":"string","required":false,"visibility":"user-or-llm","description":"Updated name for the task"},"notes":{"type":"string","required":false,"visibility":"user-or-llm","description":"Updated notes or description for the task"},"assignee":{"type":"string","required":false,"visibility":"user-or-llm","description":"Updated assignee user GID"},"completed":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Mark task as completed or not completed"},"due_on":{"type":"string","required":false,"visibility":"user-or-llm","description":"Updated due date in YYYY-MM-DD format"}},"oauth":{"required":true,"provider":"asana"}},"ashby_add_candidate_tag":{"id":"ashby_add_candidate_tag","name":"Ashby Add Candidate Tag","description":"Adds a tag to a candidate in Ashby and returns the updated candidate.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"candidateId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the candidate to add the tag to"},"tagId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the tag to add"}}},"ashby_anonymize_candidate":{"id":"ashby_anonymize_candidate","name":"Ashby Anonymize Candidate","description":"Strips personally identifiable information from a candidate in Ashby. This does not delete the candidate - the record and its applications remain, with the PII removed. Ashby exposes no candidate deletion endpoint; true deletion is UI-only, restricted by role, and limited to a 10-day window. Requires the candidatesWrite permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"candidateId":{"type":"string","required":true,"visibility":"user-or-llm","description":"UUID of the candidate to anonymize"}}},"ashby_change_application_source":{"id":"ashby_change_application_source","name":"Ashby Change Application Source","description":"Changes the source attributed to an existing application, so programmatically created applications report correctly on the recruiting side. Requires the candidatesWrite permission.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"UUID of the application whose source should change"},"sourceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the source to attribute the application to, as returned by List Sources. Omit only when unsetSource is true."},"unsetSource":{"type":"boolean","required":false,"visibility":"user-or-llm","description":"Set true to deliberately clear the application source. Required to unset, so that a missing or empty sourceId cannot wipe attribution by accident."}}},"ashby_change_application_stage":{"id":"ashby_change_application_stage","name":"Ashby Change Application Stage","description":"Moves an application to a different interview stage. Requires an archive reason when moving to an Archived stage.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"applicationId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the application to update the stage of"},"interviewStageId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the interview stage to move the application to"},"archiveReasonId":{"type":"string","required":false,"visibility":"user-or-llm","description":"Archive reason UUID. Required when moving to an Archived stage, ignored otherwise"}}},"ashby_create_application":{"id":"ashby_create_application","name":"Ashby Create Application","description":"Creates a new application for a candidate on a job. Optionally specify interview plan, stage, source, and credited user.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"candidateId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the candidate to consider for the job"},"jobId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the job to consider the candidate for"},"interviewPlanId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the interview plan to use (defaults to the job default plan)"},"interviewStageId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the interview stage to place the application in (defaults to first Lead stage)"},"sourceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the source to set on the application"},"creditedToUserId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the user the application is credited to"},"createdAt":{"type":"string","required":false,"visibility":"user-or-llm","description":"ISO 8601 timestamp to set as the application creation date (defaults to now)"}}},"ashby_create_candidate":{"id":"ashby_create_candidate","name":"Ashby Create Candidate","description":"Creates a new candidate record in Ashby.","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"name":{"type":"string","required":true,"visibility":"user-or-llm","description":"The candidate full name"},"email":{"type":"string","required":false,"visibility":"user-or-llm","description":"Primary email address for the candidate"},"phoneNumber":{"type":"string","required":false,"visibility":"user-or-llm","description":"Primary phone number for the candidate"},"linkedInUrl":{"type":"string","required":false,"visibility":"user-or-llm","description":"LinkedIn profile URL"},"githubUrl":{"type":"string","required":false,"visibility":"user-or-llm","description":"GitHub profile URL"},"website":{"type":"string","required":false,"visibility":"user-or-llm","description":"Personal website URL"},"sourceId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the source to attribute the candidate to"},"creditedToUserId":{"type":"string","required":false,"visibility":"user-or-llm","description":"UUID of the Ashby user to credit with sourcing this candidate"},"createdAt":{"type":"string","required":false,"visibility":"user-or-llm","description":"Backdated creation timestamp in ISO 8601 (e.g. 2024-01-01T00:00:00Z). Defaults to now."},"alternateEmailAddresses":{"type":"json","required":false,"visibility":"user-or-llm","description":"Array of additional email address strings to add to the candidate, e.g. [\\"a@x.com\\",\\"b@y.com\\"]"}}},"ashby_create_note":{"id":"ashby_create_note","name":"Ashby Create Note","description":"Creates a note on a candidate in Ashby. Supports plain text and HTML content (bold, italic, underline, links, lists, code).","version":"1.0.0","params":{"apiKey":{"type":"string","required":true,"visibility":"user-only","description":"Ashby API Key"},"candidateId":{"type":"string","required":true,"visibility":"user-or-llm","description":"The UUID of the candidate to add the note to"},"note":{"type":"string","required":true,"visibility":"user-or-llm","description":"The note content. If noteType is text/html, supports: , , , ,