> ## Documentation Index
> Fetch the complete documentation index at: https://docs.guild.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To act on a user's behalf in Guild, use the Guild REST API at https://api.guild.ai/v1.
> The OpenAPI spec is unauthenticated: https://docs.guild.ai/openapi.json (or openapi.yaml).
> Authenticate with an account API key, sent as HTTP Basic (key id as username, secret as password) or as `Authorization: Bearer <api_key_id>:<api_key_secret>`. See https://docs.guild.ai/api-reference/introduction#authentication.
> To run one agent on demand without account-wide access, use an API trigger instead: https://docs.guild.ai/platform/api-triggers.
> To act on Guild from an MCP client, connect to https://api.guild.ai/mcp (OAuth) or run `guild mcp` locally. Setup: https://docs.guild.ai/api-reference/mcp.
> To search these docs from an MCP client, connect to https://docs.guild.ai/mcp. The full page index is https://docs.guild.ai/llms.txt.

# Query and manage Xata branches from Guild agents

> Let Guild agents create Xata projects and branches, run SQL queries, manage organizations, control SSO, and handle billing, all with governed credentials.

Integrations · Xata

Guild agents create and delete Xata projects and branches, run SQL queries against them, and manage the organizations, members, and billing that surround them. Credentials are stored server-side and injected by Guild's proxy, so agent code never sees the API key. Credential policies let you restrict which operations each agent may perform, and every call is recorded in the audit trail.

> [card] [Book a demo](https://guild-ai.cal.com/gtm/meeting-with-guild.ai)
>
> See how teams govern agents that use Xata.

> [card] [Talk to sales](https://guild.ai/talk-to-sales)
>
> Get access to Guild, then connect Xata to your first agent.

## What the Xata tools cover

The tools reach Xata's control-plane API at api.xata.tech and its branch-scoped SQL gateway. They cover project and branch lifecycle, SQL query execution, organization membership and roles, SSO domain claims and provider configuration, API key management for both users and organizations, GitHub repository mappings, branch backups and credential rotation, and billing sessions and invoices. The xata\_delete\_organization tool is marked not implemented yet in the Xata API.

## How it works

**1. Open your credentials page**

In Guild, go to Access & setup > Credentials. The page lists connected credentials and shows a gallery of available integrations.

**2. Connect the Xata integration**

Click Connect, select xata, and paste your Xata API key into the API Key field. Guild sends it as a bearer token in the Authorization header on every request.

**3. Add the tools to your agent**

Import XataTools from the `guildai~xata` package and spread it into your agent's tools object. Use pick() to include only the specific tools your agent needs, referenced by their xata\_ prefix names.

## Why Xata access needs governing

The Xata tools can permanently delete projects and all their branches, remove organization members, enforce SSO so members have no other sign-in path, and initiate billing sessions. Connecting a credential through Guild means agent code never receives the API key directly. Guild's credential proxy injects it server-side only after checking the credential policies you have written.

Credential policies let you write ALLOW and DENY rules scoped to specific operations, agents, or workspaces. A DENY rule always wins over an ALLOW rule, so you can permit broad read access while blocking destructive operations such as xata\_delete\_project or xata\_set\_organization\_sso\_provider\_enforcement. You can scope one credential to give a provisioning agent write access while a reporting agent gets only query and metrics tools. Agents that have no matching rule are denied by default once you remove the auto-created allow-all policy.

## About the Xata integration

Agents can create, configure, and delete Xata projects and branches, then run SQL queries against them. They can also manage organizations, members, SSO, API keys, and billing. GitHub repository mappings and branch backups are also supported. The integration is `guildai~xata`.

## Authentication

* **Type:** API key
* **Header:** Guild sends the key as a bearer token in the `Authorization` header

### Setup

**1. Connect Xata**

In Guild, go to **Access & setup > Credentials**, click **Connect**, select **xata**, and paste the key into **API Key**.

See [Credentials](https://docs.guild.ai/platform/credentials.md) for workspace, member, and agent-scoped credentials.

## Usage

```typescript theme={null}
import { XataTools } from "@guildai-services/guildai~xata"
import { llmAgent } from "@guildai/agents-sdk"

export default llmAgent({
  systemPrompt: "You work with Xata.",
  tools: { ...XataTools },
})
```

### Selecting specific tools

Tools are named with the `xata_` prefix. Use [`pick()`](https://docs.guild.ai/sdk/tools#selecting-specific-tools) to include only what your agent needs.

## Tools

Tools in the latest published version of `guildai~xata`:

> [accordion] All 79 tools
>
> | Tool | What it does |
> | - | - |
> | `xata_branch_logs` | Retrieve branch logs |
> | `xata_branch_metrics` | Returns time-series data for one or more metrics of a branch. |
> | `xata_claim_organization_sso_domain` | Claims an email domain and returns the DNS record that proves control of it. |
> | `xata_create_billing_checkout_session` | Creates a Stripe checkout session used to activate card billing for an organization. |
> | `xata_create_billing_payment_method_session` | Creates a Stripe setup-mode checkout session used to add or update an organization payment method. |
> | `xata_create_branch` | Creates a new branch within the specified project. |
> | `xata_create_github_app_installation` | Creates a new GitHub App installation mapping for the specified organization. |
> | `xata_create_github_repository` | Creates a new GitHub repository to Xata branch mapping. |
> | `xata_create_organization` | Creates a new organization with the authenticated user as its single owner. |
> | `xata_create_organization_api_key` | Create a new API key for an organization. |
> | `xata_create_organization_invitation` | Send an invitation email to a user to join an organization. |
> | `xata_create_organization_sso_provider` | Registers an identity provider for one verified domain. 'google' needs only the credentials and pins the login to that Google Workspace domain; 'microsoft' pins it to the Entra tenant in the issuer… |
> | `xata_create_project` | Creates a new project within the specified organization. |
> | `xata_create_user_api_key` | Create a new API key for the authenticated user. |
> | `xata_delete_branch` | Permanently deletes a specific branch by its ID and all associated data. |
> | `xata_delete_github_repository` | Deletes the GitHub repository mapping for the specified branch. |
> | `xata_delete_installation` | Begin uninstalling an installation. |
> | `xata_delete_organization` | \[Not implemented yet] Permanently delete an organization. |
> | `xata_delete_organization_api_keys` | Delete multiple API keys in a single request. |
> | `xata_delete_organization_invitation` | Permanently delete an invitation record. |
> | `xata_delete_organization_sso_domain` | Drops a pending claim, or releases a verified domain so members on it sign in however they could before. |
> | `xata_delete_organization_sso_provider` | Deletes the provider, so members on its domain fall back to the sign-in methods they had before. |
> | `xata_delete_project` | Permanently deletes a specific project by its ID and all associated resources including branches and databases. |
> | `xata_delete_resource` | Deprovision a resource (its Xata project and branches) and mark the tracking records deleting. |
> | `xata_delete_user_api_keys` | Delete multiple API keys in a single request. |
> | `xata_describe_branch` | Retrieves detailed information about a specific branch by its ID, including status, connection string, and configuration. |
> | `xata_get_backup` | Retrieves a backup by ID for the specified project. |
> | `xata_get_billing_customer` | Retrieves billing customer details for the specified organization. |
> | `xata_get_billing_invoices` | Retrieves billing invoices for the specified organization. |
> | `xata_get_billing_upcoming_invoice` | Retrieves the upcoming billing invoice for the specified organization's active subscription. |
> | `xata_get_branch_credentials` | Retrieve branch credentials |
> | `xata_get_branch_postgres_config` | Retrieves detailed information about the current PostgreSQL configuration parameters for a branch, including parameter types, descriptions, acceptable ranges, default values, and current values. |
> | `xata_get_github_repository` | Returns the GitHub repository mapping for the specified branch. |
> | `xata_get_organization` | Retrieve detailed information about a specific organization by its ID. |
> | `xata_get_organization_invitation` | Retrieve detailed information about a specific invitation by its ID. |
> | `xata_get_organization_limits` | Retrieves the effective org-level limits, including project creation limits and branch configuration defaults. |
> | `xata_get_organization_membership_limits` | Retrieves the membership limits for the specified organization (maximum members and invitations). |
> | `xata_get_organizations_list` | Retrieve the list of all organizations the authenticated user belongs to, including their IDs and names. |
> | `xata_get_organization_sso` | Lists the organization's identity providers and the email domains claimed for them. |
> | `xata_get_project` | Retrieves detailed information about a specific project by its ID within the specified organization. |
> | `xata_get_project_limits` | Retrieves the effective resource limits for the specified project, merging organization-level overrides with any project-specific overrides. |
> | `xata_get_resource` | Return a provisioned resource. |
> | `xata_github_webhook` | Endpoint used by GitHub to deliver App webhook events. |
> | `xata_list_backups` | Retrieves a list of backups for the specified project. |
> | `xata_list_billing_plans_for_product` | Return the product's available billing plans, rendered into Vercel's billingPlan shape. |
> | `xata_list_branches` | Retrieves a list of all branches within the specified project, including their metadata, region, and access settings. |
> | `xata_list_extensions` | Retrieves a list of all extensions for the specified image in the organization and region given |
> | `xata_list_github_app_installations` | Returns all GitHub App installations associated with the specified organization. |
> | `xata_list_images` | Retrieves a list of all images for the specified organization and region |
> | `xata_list_instance_types` | Retrieves a list of all instance types for the specified organization and region |
> | `xata_list_organization_api_keys` | Retrieve a list of API keys for a specific organization. |
> | `xata_list_organization_invitations` | Retrieve all invitations for an organization with optional filtering by status, email, and name. |
> | `xata_list_organization_members` | List members of an organization |
> | `xata_list_organization_roles` | Roles are predefined. |
> | `xata_list_projects` | Retrieves a list of all projects within the specified organization that the authenticated user has access to. |
> | `xata_list_regions` | Retrieves a list of all regions where new branches can be deployed for the specified organization. |
> | `xata_list_user_api_keys` | Retrieve a list of API keys for the authenticated user. |
> | `xata_orb_webhook` | Endpoint used by Orb to deliver billing-related webhook events. |
> | `xata_provision_resource` | Create a resource (a Xata project and its branches) and return it with the connection secrets. |
> | `xata_query` | Execute a single SQL query or a batch of queries against a PostgreSQL branch. |
> | `xata_register_marketplace` | Links the authenticated user to a cloud marketplace subscription. |
> | `xata_remove_organization_member` | Remove a member from an organization |
> | `xata_request_organization_deletion` | Flags the organization for deletion. |
> | `xata_resend_organization_invitation` | Resend a pending invitation with a fresh expiration time. |
> | `xata_restore_from_backup` | Creates a new branch from the continuous backup of the source branch. |
> | `xata_rotate_branch_credentials` | Triggers a credential rotation for the branch database user. |
> | `xata_send_mcp_request` | Handle a single JSON-RPC 2.0 message from an MCP client, per the MCP. |
> | `xata_set_organization_member_role` | Replaces the member's current role. |
> | `xata_set_organization_sso_provider_enforcement` | Enabling sends every address on the provider's domain to it, leaving those members no other way in. |
> | `xata_stripe_webhook` | Endpoint used by Stripe to deliver webhook events. |
> | `xata_update_billing_customer` | Updates billing customer details for the specified organization. |
> | `xata_update_branch` | Updates the configuration of a specific branch by its ID, such as changing its name, description, or resource allocation. |
> | `xata_update_github_app_installation` | Updates an existing GitHub App installation mapping. |
> | `xata_update_github_repository` | Updates an existing GitHub repository to Xata branch mapping. |
> | `xata_update_organization` | Update information for an existing organization, such as its name. |
> | `xata_update_organization_sso_provider` | Replaces the provider's credentials, and for 'oidc' re-discovers its endpoints from the issuer. |
> | `xata_update_project` | Updates the details of a specific project by its ID, such as changing its name. |
> | `xata_upsert_installation` | Create or update an installation. |
> | `xata_verify_organization_sso_domain` | Looks up the challenge TXT record. |

## Frequently asked questions

> [accordion] Can an agent run SQL queries against a Xata branch?
>
> Yes. The xata\_query tool executes a single SQL query or a batch of queries against a PostgreSQL branch using Xata's branch-scoped SQL gateway.

> [accordion] Can an agent permanently delete a Xata organization?
>
> Not yet. The xata\_delete\_organization tool is listed in the catalog but is marked not implemented yet in the Xata API. The xata\_request\_organization\_deletion tool flags the organization for deletion instead.

> [accordion] How do I stop an agent from deleting branches it should not touch?
>
> Write a credential policy with a DENY rule for xata\_delete\_branch and xata\_delete\_project, scoped to that agent. Guild's proxy enforces the rule before the request reaches Xata, and a DENY always overrides any ALLOW rule. See [Credential policies](https://docs.guild.ai/platform/credential-policies.md) for the rule syntax.

> [accordion] Can I give one workspace a different Xata account than the rest of my organization?
>
> Yes. Connect a second Xata credential scoped to that workspace from the workspace's Credentials page. Guild picks the workspace-scoped credential ahead of the account-level one for agents in that workspace. See [Credentials](https://docs.guild.ai/platform/credentials.md) for the full resolution order.

## Put a governed agent on Xata this week

> [card] [Book a demo](https://guild-ai.cal.com/gtm/meeting-with-guild.ai)
>
> See how teams govern agents that use Xata.

> [card] [Talk to sales](https://guild.ai/talk-to-sales)
>
> Get access to Guild, then connect Xata to your first agent.

## Related

**Also runs on Guild:** [Airtable](https://docs.guild.ai/integrations/airtable.md) · [AssemblyAI](https://docs.guild.ai/integrations/assemblyai.md) · [BigQuery](https://docs.guild.ai/integrations/bigquery.md) · [Chroma](https://docs.guild.ai/integrations/chroma.md)

**Read:** Docs: [Credential policies](https://docs.guild.ai/platform/credential-policies.md) · [Credentials](https://docs.guild.ai/platform/credentials.md) · [Tools in agents](https://docs.guild.ai/sdk/tools.md)
