> ## 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.

# Webhooks

> Learn about the /webhooks endpoint.

Learn about the `/webhooks` endpoint.

* Webhooks provide a way for Argyle to communicate to your servers when specific events happen, such as when an account was successfully connected, new payouts were added, etc.
* To start receiving webhooks, you need to build a web application, with a publicly accessible URL. Use that URL to create a webhook subscription.
* After subscribing to a webhook, you receive a POST request with the event payload that contains information about the event that has been triggered.

For more information, refer to our [Webhooks Reference](/legacy/api-reference/webhooks-overview).

## The webhook object

### Attributes

* `id` (string (uuid), optional): Unique ID of the webhook.

```json theme={}

{
"id": "580dca76-c024-4458-bb10-a2111ad4063e",
"created_at": "2019-11-27T15:54:59.440Z",
"updated_at": "2019-11-27T15:54:59.440Z",
"events": [
"*"
],
"name": "All webhooks",
"secret": null,
"url": "https://webhooks-backend.com/argyle",
"config": null
},
null,
2
  
```

<RefSubLayout.Divider />

## Create a webhook

**POST** `/v1/webhooks`

* Create a new webhook.
* This request returns the created webhook object.

### Request body

* `name` (string, required): An arbitrary name that is sent back to your system in the webhook payload.
* `events` (array of strings, required): An array of Argyle webhook event types. Specify \['\*'] to subscribe to all webhook events.
* `url` (string, required): The backend website where you want to receive the webhook.

<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": ["accounts.connected", "accounts.updated"],
    "name": "name-for-the-webhook-subscription",
    "url": "https://your-webhook-backend.com",
    "config": { "include_resource": true },
    "secret": "optional-secret"
    }'
    ```
  </Tab>

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

```json theme={}

{
  "id": "018050ec-522f-1725-0906-320116f36aa6",
  "name": "name-for-the-webhook-subscription",
  "events": ["accounts.connected", "accounts.updated"],
  "config": {},
  "secret": null,
  "url": "https://your-webhook-backend.com",
  "created_at": "2022-04-22T10:58:26.480Z",
  "updated_at": "2022-04-22T10:58:26.480Z"
},
null,
2
  
```

<RefSubLayout.Divider />

## Retrieve a webhook

**GET** `/v1/webhooks/{id}`

* Retrieve a webhook object with the supplied ID.
* This request returns a webhook object if you provided a valid identifier.

### Path parameters

* `id` (string (uuid), required): ID of the webhook.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request GET \\
    --url https://api.argyle.com/v1/webhooks/{id} \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json'
      
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks/{id}"
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.get(url, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

{
  "id": "018050c5-9af3-4009-14d1-745fd94049c3",
  "name": "Account added",
  "events": [
"accounts.added"
  ],
  "config": {
"include_resource": true
  },
  "secret": null,
  "url": "https://webhook.site/#!/251acbda-9bd7-445d-9ae3-17c8d2f0f238",
  "created_at": "2022-04-22T10:16:09.204Z",
  "updated_at": "2022-04-22T10:54:17.524Z"
},
null,
2
  
```

<RefSubLayout.Divider />

<RefSubLayout.Divider />

## List webhooks

**GET** `/v1/webhooks`

* List all webhooks.
* This request returns an object with a `results` property that contains an array of up to `limit` webhook objects.

### Query parameters

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request GET \\
    --url https://api.argyle.com/v1/webhooks?limit=2 \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json'
      
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks?limit=2"
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.get(url, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

[
  {
"id": "018050c5-9af3-4009-14d1-745fd94049c3",
"name": "Account added",
"events": [
  "accounts.added"
],
"config": {
  "include_resource": true
},
"secret": null,
"url": "https://webhook.site/#!/251acbda-9bd7-445d-9ae3-17c8d2f0f238",
"created_at": "2022-04-22T10:16:09.204Z",
"updated_at": "2022-04-22T10:54:17.524Z"
  },
  {
"id": "017efe13-4336-be71-0f32-529ba362f787",
"name": "Account updated",
"events": [
  "accounts.updated"
],
"config": {
  "include_resource": true
},
"secret": "8500588670cf4e4d83a9a68259429733",
"url": "https://eo7fvts7a5ivh78.m.pipedream.net",
"created_at": "2022-02-15T15:49:42.327Z",
"updated_at": "2022-04-19T22:49:13.761Z"
  }
],
null,
2
  
```

<RefSubLayout.Divider />

## Delete a webhook

**DELETE** `/v1/webhooks/{id}`

* Remove a webhook and unsubscribe your system from the events in the deleted webhook.
* This request returns an empty response body.

### Path parameters

* `id` (string (uuid), required): ID of the webhook to be deleted.

<Tabs>
  <Tab title="curl">
    ```bash theme={}
    curl --request DELETE \\
    --url https://api.argyle.com/v1/webhooks/{id} \\
    --header 'accept: application/json' \\
    --header 'content-type: application/json'
      
    ```
  </Tab>

  <Tab title="python">
    ```python theme={}
    import requests
    url = "https://api.argyle.com/v1/webhooks/{id}"
    headers = {
    "accept": "application/json",
    "content-type": "application/json"
    }
    response = requests.delete(url, headers=headers)
    ```
  </Tab>
</Tabs>

```json theme={}

"204 status code: No content.",
null,
2
  
```
