# Affinity

> Read and write Affinity relationship-intelligence CRM data - persons, organizations, opportunities, lists, fields, notes, and interactions.

Lets an agent work with your Affinity relationship-intelligence CRM through the REST API: search and read persons, organizations, and opportunities; browse lists and their entries; inspect custom fields; read and create notes; and pull interactions (meetings, calls, chats, emails).

## What it can do

| Method | What it does |
| --- | --- |
| `affinity_persons_list` | List/search persons (optional term, interaction dates, pagination). |
| `affinity_person_get` | Get one person by ID. |
| `affinity_organizations_list` | List/search organizations. |
| `affinity_organization_get` | Get one organization by ID. |
| `affinity_opportunities_list` | List/search opportunities. |
| `affinity_opportunity_get` | Get one opportunity by ID. |
| `affinity_lists_list` | List all lists. |
| `affinity_list_get` | Get one list (with its fields) by ID. |
| `affinity_list_entries_list` | List entries within a list. |
| `affinity_fields_list` | List custom fields (optionally for one list). |
| `affinity_notes_list` | List notes (filter by person, organization, or opportunity). |
| `affinity_note_create` | Create a note and attach it to people, organizations, or opportunities. |
| `affinity_interactions_list` | List interactions (meetings, calls, chats, emails) in a window. |
| `affinity_request` | Generic passthrough to any endpoint for full API coverage. |

## How to get your key

Affinity authenticates with HTTP Basic auth: an **empty username** and your **API key** as the password. FlyMyAI builds that header for you - you only paste the key.

1. Sign in to Affinity.
2. Open **Settings -> API** ([affinity.co](https://www.affinity.co/)).
3. Create an API key and copy it. Keep it private; it grants access to your CRM data.
4. Paste it into FlyMyAI.

## Fields to fill

| FlyMyAI field | Where it comes from |
| --- | --- |
| `AFFINITY_API_KEY` | Affinity -> Settings -> API (used as the HTTP Basic password) |

## Troubleshooting

- **`401 Unauthorized`** - the key is wrong or revoked. Generate a new one under Settings -> API. Remember the key is the Basic-auth password, with an empty username.
- **`403 Forbidden`** - your Affinity plan or seat does not include API access, or the key lacks permission for that object.
- **`429 Too Many Requests`** - Affinity rate-limits the API; pause and retry with backoff.
- **Empty results** - check the `term` filter and pagination (`page_token`). Some objects are scoped to lists; use `affinity_list_entries_list` for list-specific records.

## Links

- [Affinity API reference](https://api-docs.affinity.co)
- [Affinity](https://www.affinity.co/)
