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

# Entities API

> Find the users, addresses, keys, and resources that security events and findings name, rank them by risk, and read what an identity did.

An entity is one thing that security events or security findings name: a user, an IP address, an
access key, a repository, a cloud account, a host, a service, and more. Every entity has one
`entity_id`. The ID is made from three parts:

* `type`: what the entity is (see the table below).
* `scope`: the namespace of the value, for example `aws:123456789012`, `okta`, or `github`. An empty
  scope means the value is global, for example an IP address.
* `value`: the strongest identifier of the entity in that scope (a provider user ID, an address, a
  key ID, an ARN).

The same type, scope, and value always give the same `entity_id`, so the ID from `entities.search`,
from a finding's `entity_refs`, and from `entities.risky` opens the same entity. A user named `cat`
in GitHub and a user named `cat` in Okta are two entities.

## Operations

| Operation | Method and path | Purpose |
| - | - | - |
| `entities.search` | `GET /v1/projects/{project_id}/entities` | Find entities of one type that security events name. |
| `entities.get` | `GET /v1/projects/{project_id}/entities/{entity_id}` | Event count and first and last seen time of one entity. |
| `entities.timeline` | `GET /v1/projects/{project_id}/entities/{entity_id}/timeline` | The security events that name one entity, newest first. |
| `entities.risky` | `GET /v1/projects/{project_id}/entities/risky` | The entities with the highest risk score, with the breakdown. |
| `entities.profile` | `GET /v1/projects/{project_id}/entities/{entity_id}/profile` | Risk, findings, related entities, and other names of one entity. |
| `entities.updateControls` | `PATCH /v1/projects/{project_id}/entities/{entity_id}` | Set the criticality or the watchlist flag of an entity. |
| `entities.activity` | `GET /v1/projects/{project_id}/entities/{entity_id}/activity` | What a user or access key did: identity, action, resource. |
| `entities.findingCorrelations` | `GET /v1/projects/{project_id}/findings/{finding_id}/correlations` | The findings that share an entity with one finding. |

`entities.search`, `entities.get`, and `entities.timeline` need `errors:read`. The other reads need
`findings:read`. `entities.updateControls` needs `findings:write`.

## Entity types and roles

| `type` | Example value |
| - | - |
| `user` | A provider user ID or a user name |
| `ip` | `203.0.113.9` |
| `host` | `web-1.internal` |
| `service` | `checkout` |
| `access_key` | `AKIA...` key ID |
| `repository` | `acme/api` |
| `cloud_account` | `123456789012` |
| `cloud_resource` | An ARN or a resource ID |
| `container` | A container ID |
| `package` | A package URL (`pkg:npm/...`) |
| `url` | `/.env` |
| `email` | `alice@example.com` |
| `domain` | `example.com` |

Logs name `user`, `ip`, `access_key`, `repository`, `cloud_account`, and `host`, so
`entities.search`, `entities.get`, and `entities.timeline` accept only those types. Findings can name
all types.

A finding names each entity in a role: `actor` (who did it), `target` (who or what it was done to),
`source` (where it came from, for example an address), or `affected` (a resource or asset in scope).

Records of the same person in two systems become one group only when they share a strong key, such
as the same email address. Squasher never joins records on a display name or on a shared IP address.
`entities.profile` lists the other records of the group in `resolution_group`.

## Risk score

```bash theme={null}
curl "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/entities/risky?limit=10" \
  -H "Authorization: Bearer $SQUASHER_API_KEY"
```

The risk score is 0 to 100. Each open security finding that names the entity adds points by its
severity: `informational` 1, `low` 4, `medium` 10, `high` 25, `critical` 40, `fatal` 50. The points
of a finding halve every 14 days after the finding was last seen. The sum is multiplied by the
entity's criticality (`low` 0.5, `normal` 1, `high` 1.5, `critical` 2) and capped at 100.

| Score | `level` |
| - | - |
| 0-24 | `low` |
| 25-49 | `moderate` |
| 50-74 | `high` |
| 75-100 | `critical` |

Every `risk` object has the breakdown: `contributions` lists each open finding with its `points`,
`decay`, and `contribution`, largest first; `raw` is the sum and `multiplier` is the criticality
multiplier. `entities.risky` returns the five largest contributions of each entity;
`entities.profile` returns all of them and `risk_timeline`, the score of each of the last 30 days.

## Set criticality

```bash theme={null}
curl -X PATCH "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/entities/$ENTITY_ID" \
  -H "Authorization: Bearer $SQUASHER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"criticality": "high", "watchlisted": true}'
```

Set `criticality` for an entity that matters more (a production account) or less (a test user).

## Graphs

`entities.activity` and `entities.findingCorrelations` return a graph: `nodes` (`kind` is
`entity`, `finding`, or `action`) and `edges` (`label` is the role, or `performed` and `on` for
activity). The node with `focus: true` is the identity or the finding you asked about.
`truncated: true` means that the graph left out the least linked nodes.

`entities.activity` reads the security events of the last 24 hours by default; pass `from` and `to`
to change the range. Only `user` and `access_key` entities have activity.


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