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

# Activities Webhooks

> Learn about activities webhooks.

There are two types of activity webhook events:

* Events that trigger only during the initial scan when a new account is connected: `activities.fully_synced` and `activities.partially_synced`. They trigger once per invocation for each added account.
* Events that trigger later on, when new activities are added or removed in the future: `activities.added`, `activities.updated`, and `activities.removed`. These only trigger on a periodic scan for accounts that are already connected and have been fully synced, and only after the `activities.fully_synced` event is triggered.

A typical account can contain thousands of activities and `activities.fully_synced` only fires after all of the activities are scanned, which in some cases might take hours.

Use `activities.partially_synced` if you only need a partial range of the activities. For example, you need a history of the last 30 days instead of a complete history of activities. This reduces the sync time to minutes or, in some cases, seconds.

## Fully synced

**POST** `/v1/webhooks`

Implement the `activities.fully_synced` webhook to know when all activities have been scanned.

* The `activities.fully_synced` webhook triggers when all activities are fully scanned. Scanning starts from the most recent activities and finishes with the oldest ones.
* This webhook only triggers when the initial scan finishes. It is not invoked during periodic scanning.

### Request body

<Note>
  ### Webhook message

  * `name` (string, optional): Name used for the webhook subscription.
  * `data` (object, optional)
  * `account` (string (uuid), optional): ID of the account.
  * `user` (string (uuid), optional): ID of the user.
  * `available_to` (string (timestamp), optional): The date of the most recent available activity.
  * `available_count` (integer, optional): The total number of activities associated with the account at the moment the webhook call is made.
</Note>

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request POST \\
    --url https://api.argyle.com/v1/webhooks \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json' \\
    --data '{
    "events": ["activities.fully_synced"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }'
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks"
    payload = {
    "events": ["activities.fully_synced"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
"event": "activities.fully_synced",
"name": "All historical data synced",
"data": {
"account": "12db5af4-fd5f-4d1f-bd98-0360df770aa8",
"user": "abdb5af4-fd5f-4d1f-bd10-0360df77012c",
"available_from": "2019-03-07T20:12:09Z",
"available_to": "2019-09-23T23:57:31Z",
"available_count": 432
}
},
null,
2
  
```

<RefSubLayout.Divider />

## Partially synced

**POST** `/v1/webhooks`

Implement the `activities.partially_synced` webhook to know when 30 days of historical activities have been scanned.

* By default, the `activities.partially_synced` webhook triggers when 30 days of historical activities have been successfully scanned (starting from the date [when the account was added](/legacy/api-reference/accounts-webhooks#added)).
* The number of days scanned is a configurable parameter. This webhook can be subscribed to multiple times with different day ranges.
* Triggers only on the initial scan, and does not trigger during a periodic scan. If an account has zero or a small number of activities, the initial scan may return all historical data and only fire the `activities.fully_synced` webhook.

### Request body

### Webhook message

* `name` (string, optional): Name used for the webhook subscription.
* `data` (object, optional)
* `account` (string (uuid), optional): ID of the account.
* `user` (string (uuid), optional): ID of the user.
* `days_synced` (integer, optional): Number of historical days synced.
* `available_count` (integer, optional): The total number of activities associated with the account at the moment the webhook call is made.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request POST \\
    --url https://api.argyle.com/v1/webhooks \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json' \\
    --data '{
    "events": ["activities.partially_synced"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret",
    "config": { "days_synced": 7 }
    }'
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks"
    payload = {
    "events": ["activities.partially_synced"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret",
    "config": { "days_synced": 7 }
    }
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
"event": "activities.partially_synced",
"name": "7 days synced",
"data": {
"account": "12db5af4-fd5f-4d1f-bd98-0360df770aa8",
"user": "abdb5af4-fd5f-4d1f-bd10-0360df77012c",
"days_synced": 7,
"available_from": "2019-06-07T20:12:09Z",
"available_to": "2019-06-14T20:12:09Z",
"available_count": 324
}
},
null,
2
  
```

<RefSubLayout.Divider />

## Added

**POST** `/v1/webhooks`

Implement the `activities.added` webhook to know when a new [activity object](/legacy/api-reference/activities#activity-object) is added.

An activity object will be added:

* When a new account is connected, and its scanned data includes activities data
* On a continuous basis, if a new activity is retrieved during Argyle's periodic scanning of connected accounts

Two time periods are recorded and delivered in the `activities.added` payload:

* `available_from` and `available_to` specify the date range of all activities associated with the account
* `added_from` and `added_to` specify the date range of the newly added activities

<Note>
  To retrieve recently added activities, [list activities](/legacy/api-reference/activities#list) using the query parameters:

  * `account` = the ID returned in the account field of the `activities.added` webhook payload
  * `from_start_date` = the `added_from` timestamp in the `activities.added` webhook payload
  * `to_start_date` = the `added_to` timestamp in the `activities.added` webhook payload
</Note>

### Request body

### Webhook message

* `name` (string, optional): Name used for the webhook subscription.
* `data` (object, optional)
* `account` (string (uuid), optional): ID of the account.
* `user` (string (uuid), optional): ID of the user.
* `added_to` (string (timestamp), optional): The time of the latest activity that was recently added.
* `added_count` (integer, optional): The number of activities added to the account.
* `available_to` (string (timestamp), optional): The date of the most recent available activity.
* `available_count` (integer, optional): The total number of activities associated with the account at the moment the webhook call is made.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request POST \\
    --url https://api.argyle.com/v1/webhooks \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json' \\
    --data '{
    "events": ["activities.added"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }'
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks"
    payload = {
    "events": ["activities.added"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
"event": "activities.added",
"name": "Activities added",
"data": {
"account": "12db5af4-fd5f-4d1f-bd98-0360df770aa8",
"user": "abdb5af4-fd5f-4d1f-bd10-0360df77012c",
"added_from": "2019-08-07T20:12:09Z",
"added_to": "2019-09-23T23:57:31Z",
"added_count": 10,
"available_from": "2019-03-07T20:12:09Z",
"available_to": "2019-09-23T23:57:31Z",
"available_count": 456
}
},
null,
2
  
```

<RefSubLayout.Divider />

## Updated

**POST** `/v1/webhooks`

Implement the `activities.updated` webhook to know when an [activity object](/legacy/api-reference/activities#activity-object) is updated.

* Activity objects are updated through periodic scanning.

### Request body

### Webhook message

* `name` (string, optional): Name used for the webhook subscription.
* `data` (object, optional)
* `account` (string (uuid), optional): ID of the account.
* `user` (string (uuid), optional): ID of the user.
* `updated_to` (string (timestamp), optional): Represents the end of the time period the activities were updated in.
* `updated_count` (integer, optional): The number of activities that were updated.
* `updated_activities` (array of (uuid) strings, optional): ID's of the updated activities.
* `available_to` (string (timestamp), optional): Represents the end of the time period the activities are available for.
* `available_count` (integer, optional): The total number of activities associated with the account at the moment the webhook call is made.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request POST \\
    --url https://api.argyle.com/v1/webhooks \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json' \\
    --data '{
    "events": ["activities.updated"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }'
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks"
    payload = {
    "events": ["activities.updated"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
"event": "activities.updated",
"name": "Activities updated",
"data": {
"account": "12db5af4-fd5f-4d1f-bd98-0360df770aa8",
"user": "abdb5af4-fd5f-4d1f-bd10-0360df77012c",
"updated_from": "2019-09-10T10:00:00Z",
"updated_to": "2019-09-12T12:00:00Z",
"updated_count": 2,
"updated_activities": [
"d667a477-e252-4f8a-9518-92a51b235187",
"27f3cde1-1ca0-4b5a-940d-337fd33f97b5"
],
"available_from": "2019-03-07T20:12:09Z",
"available_to": "2019-09-23T23:57:31Z",
"available_count": 456
}
},
null,
2
  
```

<RefSubLayout.Divider />

## Removed

**POST** `/v1/webhooks`

<Note>
  Implement the `activities.removed` webhook to know when an [activity object](/legacy/api-reference/activities#activity-object) is removed.

  * An activity object is **removed** when specific activities are deleted from an account by a data provider and are found to be missing during a periodic scan.
</Note>

### Request body

### Webhook message

* `name` (string, optional): Name used for the webhook subscription.
* `data` (object, optional)
* `account` (string (uuid), optional): ID of the account.
* `user` (string (uuid), optional): ID of the user.
* `removed_to` (string (timestamp), optional): Represents the end of the time period the activities were removed in.
* `removed_count` (integer, optional): The total number of activities removed from the account at the moment the webhook call is made.
* `removed_activities` (array of (uuid) strings, optional): ID's of the removed activities.
* `available_to` (string (timestamp), optional): Represents the end of the time period the activities are available for.
* `available_count` (integer, optional): The total number of activities associated with the account at the moment the webhook call is made.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request POST \\
    --url https://api.argyle.com/v1/webhooks \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json' \\
    --data '{
    "events": ["activities.removed"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }'
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks"
    payload = {
    "events": ["activities.removed"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "secret": "optional-secret"
    }
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.post(url, json=payload, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
"name": "Activities Removed",
"event": "activities.removed",
"data": {
"account": "017d9bdc-49cb-bcf6-9a99-f3ed32ddb2c2",
"user": "017d8fed-b702-7675-e9be-00d6b2d24614",
"removed_from": "2021-09-27T00:22:54Z",
"removed_to": "2021-09-27T00:22:54Z",
"removed_count": 1,
"removed_activities": [
"017d9f62-84e1-15ad-b269-624458d343c8"
],
"available_from": "2019-09-03T17:56:22Z",
"available_to": "2021-12-09T00:01:01Z",
"available_count": 1237
}
},
null,
2
  
```
