Docs

# Attio

Connect Attio with an access token: referred people appear in Attio with their partner, and a deal moved to your won stage pays that partner.

The Attio connection works in both directions:

* **To Attio**: each person a partner refers is created or updated as an Attio person, by email address, with the attribute **Affiligato partner** set to the partner’s name and id.
* **From Attio**: when a deal moves to the stage you picked as won, and one of its associated people is a person Affiligato sent, the partner who referred that person earns commission on the deal’s value, through your commission rules.

With Attio connected, you do not record those payments by hand. See [Quotes and invoices](https://affiligato.com/docs/quotes-and-invoices/) for the rest of the setup.

## Connect

Connect in the dashboard, so the token goes from Attio to Affiligato and never passes through an AI agent. An agent can call `get_integrations` to see whether Attio is connected, and why a broken connection stopped.

1. ### Turn on Deals in Attio

   Deals are off in a new Attio workspace. A workspace admin turns them on under the workspace’s object settings. With Deals off, connecting stops with **Turn on Deals in Attio (Settings → Objects), then connect again.**

2. ### Create an access token in Attio

   Open **Workspace settings → Developers** and create a new access token with three scopes, each read-write: **Records** (`record_permission:read-write`), **Object configuration** (`object_configuration:read-write`) and **Webhooks** (`webhook:read-write`).

3. ### Paste it into Affiligato

   Open **Settings → Connect → Attio**, paste the token into **Access token** and choose **Connect Attio**.

4. ### Pick the won stage

   Attio’s deal stages are your workspace’s own, so Affiligato asks which one means won. Pick it under **Won stage**. No deal pays a partner until you pick one.

Connecting checks the token, creates the people attribute `affiligato_partner` (title **Affiligato partner**) if it does not exist, and registers a webhook in Attio that reports changes to deals. Affiligato keeps the token and the webhook’s secret encrypted. The panel then names the workspace it reached.

Connecting again clears the won stage: pick it again.

## What goes to Attio

* While Attio is connected, a person is sent when they become a referral and when their customer record changes. Affiligato creates or updates the person with that email address and sets **Affiligato partner** to the partner’s name followed by their id in brackets. It writes no other attribute.
* People are sent about once a minute. A person Attio does not accept is tried again later, up to eight times.
* People referred before you connected are not sent when you connect.
* Sample partners and demo programs are never sent.

## Won deals

Attio tells Affiligato when a deal changes. Affiligato refuses a delivery whose signature does not match, and takes each delivery once however often Attio sends it. About once a minute, it reads each changed deal:

* When the deal is in your won stage, and one of its associated people is a person Affiligato sent to Attio, the partner who referred that person earns. A deal with no such person is left alone.
* The sale is the deal’s value, in the value’s currency, or in your program’s currency when it has none, dated the day Affiligato reads the deal.
* Each deal is credited once. Its transaction id is `attio:` followed by the deal’s record id.

## Lost deals

* A deal outside the won stage that was never credited is left alone.
* A credited deal that moves out of the won stage, to any other stage, has its commission reversed, as a refund of the whole value. A commission already paid out is taken back from the partner’s next payout.

## When the connection breaks

When Attio refuses the token, because it was deleted or lost a scope, Affiligato stops using it. The Attio panel says **Attio refused this API key. Connect again with a new key.** and shows the form again.

* People who were waiting to be sent are kept, and go out once you connect again.
* People referred while the connection was broken are not sent.

When Attio answers that there are too many requests, Affiligato stops and tries again on its next run.

## Disconnect

**Disconnect** on the Attio panel removes the webhook from Attio, when the token still works, and forgets the token. After a broken connection, delete the webhook in Attio yourself. The `affiligato_partner` attribute and the people stay in Attio. Delete the access token in Attio too.
