# See what changed

You read your own account's history through an integration you made in Portal. The history lists the changes we record
to models, products, prices, billing details, properties, integrations, the subscription and users, with who or what
made each one. First [make an integration and get a token](/en/developers/api/authentication/).

The requests below use three shell variables: `$CLIENT_ID` and `$CLIENT_SECRET` from your integration, and `$TOKEN`
set to the `access_token` from the first step.

## Get a token

Exchange the integration's ID and secret for a token:

```sh title="Request"
curl -X POST https://api.virtualdisplay.io/v1/oauth/token \
  -d grant_type=client_credentials \
  -d client_id=$CLIENT_ID \
  -d client_secret=$CLIENT_SECRET
```

Copy `access_token` from the response into `TOKEN`.

## Read the history

`GET /v1/activity` returns one page of changes, newest first. Each change says what it was to, what happened and who
made it:

<Operation id="listActivity" />

- `kind` is what the change was to, and `action` what happened to it. The table below lists the pairs.
- `part` is set only when a part of the thing changed, such as a model's `camera`, an integration's `secret` or `access`,
  or a user's `password`.
- `actor.type` is `customer` or `admin`. `actor.client` and `actor.client_id` name the integration that made the change,
  when one did, and `actor.name` is empty for an integration: it names no person.
- `changes` holds each field that changed, with its value before (`from`) and after (`to`).

## Kinds and actions

| Kind              | What it is             | Actions                                     |
| ----------------- | ---------------------- | ------------------------------------------- |
| `model`           | a 3D model             | `created`, `changed`, `deleted`             |
| `product`         | a product              | `created`, `changed`, `deleted`             |
| `pricing`         | a model's price rules  | `created`, `changed`                        |
| `billing_details` | the billing details    | `created`, `changed`                        |
| `property`        | a product property     | `created`, `changed`, `deleted`             |
| `integration`     | an integration         | `created`, `granted`, `replaced`, `revoked` |
| `subscription`    | the subscription       | `chosen`, `set`, `cancelled`, `reactivated` |
| `account`         | the account            | `opened`                                    |
| `user`            | a user who can sign in | `created`, `changed`, `deleted`, `reset`    |

`account` and `subscription` changes can be made by us. Then `actor.type` is `admin`.

## Names are first names

An integration sees people by first name only. In `actor.name`, and in the `subject` of a `user` row, `Sanne de Vries`
reads as `Sanne`. Things that are not people keep their whole name, so a product or a filename is unchanged. A
customer's own token sees full names.

## Narrow the list

Add these query parameters to `GET /v1/activity`:

| Parameter          | What it keeps                                                                                 |
| ------------------ | --------------------------------------------------------------------------------------------- |
| `kind`             | the kinds you name, comma-separated, such as `kind=model,product`. An unknown kind is a `400` |
| `client_id`        | one integration's public client ID: what it did, and what was done to it                      |
| `q`                | changes whose `subject` contains this text, ignoring case, as your integration reads it       |
| `page`, `per_page` | the page, and how many a page holds: 20 by default, 100 at most                               |

A `client_id` that matches no integration on your account returns an empty page, not an error.

Narrow by kind:

<Operation id="listActivity" query={['kind']} />

Narrow by one integration, using its client ID:

<Operation id="listActivity" query={['client_id']} />

Narrow by the text in a subject:

<Operation id="listActivity" query={['q']} />

If a request fails, the [errors](/en/developers/api/errors/) page says what each status means and what to do next.