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

# Connect AI Agents to Affinity CRM With an API Key

> Let agents look up contacts, update deal pipelines, and log interactions in Affinity. The gateway injects your API key, so agents never handle it.

## Overview

Buckle connects AI agents to Affinity using an API key. Agents can manage relationships, track deals, log interactions, and query your CRM data. The gateway injects the API key into requests to the Affinity API automatically.

This is useful for agents that need to look up contacts, update deal pipelines, or log meeting notes without manual CRM data entry.

## What you will set up

* An Affinity API key stored in Buckle
* Automatic key injection on requests to the Affinity API
* Per-agent, per-tool access to your CRM data

## Setup

**1. Create an API key in Affinity**

Go to **Settings** > **API** in Affinity and create a new API key. Copy the key.

**2. Connect in Buckle**

Open the Buckle dashboard, go to **Settings** > **Apps** > **Affinity**, and paste your API key.

![Buckle connect window for Affinity, showing the setup guide link and the fields to fill in.](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/affinity/buckle-connect-affinity.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=0dc6406197134fbb6f2cb9bd602077d9)

The Affinity connect window in Buckle.

## What agents can do

* Search and view contacts, organizations, and opportunities
* Create and update records in lists and deal pipelines
* Log interactions such as emails, meetings, and notes
* Query relationship data and field values
* Manage list entries and custom fields

## Controlling access

Access is per agent: [grant](/docs/guides/agent-access.md) the connection to each agent that needs it, choosing per tool what runs freely, what needs human approval, and what stays blocked — a read-only agent is a single grant. Organization [rules](/docs/guides/rules.md) add guardrails on top, like rate limits and blanket blocks. Everything is checked before credential injection, so a blocked request never reaches Affinity.

## FAQ

> [accordion] How do I rotate my Affinity API key?
>
> Create a new key in Affinity under **Settings** > **API**, then paste it into **Settings** > **Apps** > **Affinity** in Buckle. Agents pick up the new key automatically. Then delete the old key in Affinity.

> [accordion] How do I keep the Affinity key out of the agent's context?
>
> Store it in Buckle instead of an environment variable or prompt. The gateway injects it at the proxy, so the agent never holds the key. See [How it works](/docs/how-it-works.md).

> [accordion] Can an agent read Affinity without changing records?
>
> Yes. When you [grant](/docs/guides/agent-access.md) the connection, allow the read tools and block or require approval for writes. A read-only agent is a single grant.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.