> The index of all pages is at https://docs.afffast.com/llms.txt.

# Security

How AffFast protects your network credentials and your data, and how roles and two-factor sign-in work.

This page tells you how AffFast protects your account and your data.

## Network credentials

Your network credentials give access to your income. AffFast encrypts each credential with envelope encryption before it stores it. After you save a credential, nobody can read it again, not in the dashboard and not in the API. You can only replace it. Only owners and admins can add or change a connection. AffFast only reads data from your networks. See [Connect a network](https://docs.afffast.com/docs/connect.md).

## Roles

Each member of a workspace has one role.

| Role   | What the role can do                                                                                |
| ------ | --------------------------------------------------------------------------------------------------- |
| Owner  | All actions, including billing and the deletion of the workspace.                                   |
| Admin  | All actions, except the deletion of the workspace. An admin can read the billing but not change it. |
| Member | Read connections and webhooks. Read and make links.                                                 |

Only the owner can make an API key with the scope `full`. See the [quickstart](https://docs.afffast.com/docs/quickstart.md). An API key also has scopes, so you can give a script only the access that it needs. You can rotate and revoke a key at any time.

### Scopes of a sink

A sink sends data out of the API. A webhook endpoint, a destination, a log drain and a notification channel are sinks. The write scope of the sink is not enough. A key must also be able to read the data that the sink sends. Without this rule, a key with a narrow scope could send data that it cannot read.

When you make or change a sink, the key needs these scopes. A change needs the scopes of the event types or the sources that the sink has after the change, also when the request does not change them. This applies to a change of the receiver (URL, `config` or `credentials`), of the selection (`events`, `event_types`, `sources`) or of the filters, and to a change of the status to `enabled` or `active`. The resume of a notification channel or a log drain, and the restore of a sink from the Trash, also turn a sink on, so they need the same scopes. A new label, new metadata or a pause needs only the write scope of the sink.

- `events:read`, for a webhook endpoint, a destination or a notification channel.
- The read scope of the object of each event type in `events` or `event_types`. For example, `conversion.created` needs `conversions:read`, and `payout.created` needs `payouts:read`. The type `*` needs all of these scopes. A destination and a notification channel do not accept the type `*`.
- For a log drain, the read scope of each source in `sources`: `api_request` needs `logs:read`, `click` needs `clicks:read`, `sync_run` needs `connections:read`, and `delivery` needs `webhooks:read` and `destinations:read`.
- For a destination backfill, the read scope of `object`, for example `payouts:read` for `payouts`.

If a scope is missing, the API returns 403 `scope_insufficient`. The field `param` names the field of the request: `events`, `event_types`, `sources` or `object`. A key with the scope `full` and a dashboard session of an owner or an admin pass this check.

### Events and delivery payloads

An event holds a copy of an object, for example a conversion. A key sees this object only when it can read the type of the object. This applies to `GET /v1/events`, `GET /v1/events/{id}`, and to the `payload` of a webhook delivery (`GET /v1/webhook_endpoints/{id}/deliveries` and the answer of a retry). For example, `conversion.created` needs `conversions:read`, and `payout.created` needs `payouts:read`.

When the key cannot read the object, the API hides it:

- `data.object` has only `id` and `object`.
- `data.previous_attributes` is not there.
- `data.object_hidden` is `true`.

The other fields of the event stay: `id`, `type`, `created_at` and the rest. An event type with no object, such as `usage.limit_near`, needs only `events:read`. A key with the scope `full` and a dashboard session of an owner or an admin always see the full object. The request that the API sends to your endpoint does not change: it has the full object.

## AI apps

Claude, ChatGPT and other AI apps connect to the [MCP server](https://docs.afffast.com/docs/mcp.md) with a sign-in. The user selects one workspace, one mode and the access. The app cannot do more than the role of the user.

- Each user sees the own connections on the **AI** page and in the account settings, and can disconnect each one. Owners and admins see and disconnect all connections of the workspace on the **AI** page.
- A disconnect stops the app at its next request.
- The user gets an email for each new connection.
- Owners and admins can turn off **Allow AI apps** in the workspace settings. This pauses all connections of the workspace at once. When it is on again, they work again.
- Each tool call is in the request logs with the source `oauth`, and each change is in the audit log.

## Two-factor sign-in

Each user can turn on two-factor sign-in in the account settings of the dashboard.

## Separate data for each workspace

Each workspace has its own data. AffFast scopes each query to one workspace. The database checks this on each query too, as a second check (row-level security). A request from one workspace cannot read the data of another workspace, also not by a mistake.

Live data and [test data](https://docs.afffast.com/docs/test-mode.md) are fully separate. A test key never sees live data.

## Logs

The API keeps a log of each request for 30 days. It never keeps the `Authorization` header or cookies. It replaces secrets (API keys, passwords, tokens and credentials) in the bodies before it stores them. See [Request logs](https://docs.afffast.com/docs/errors.md#request-logs).

## Data retention

AffFast deletes raw clicks after the retention time of your plan (13 months, 3 years or 5 years), or after a shorter time that you choose. See [Plans and billing](https://docs.afffast.com/docs/plans.md). See [Links and click tracking](https://docs.afffast.com/docs/links.md). Read the [legal pages](https://docs.afffast.com/docs/legal.md) for the terms, the privacy policy and the list of sub-processors.
