# List Webhooks

{% hint style="success" %}
First, obtain an access token to get started [here](/getting-started/authentication.md).
{% endhint %}

Retrieve a list of all webhooks configured for your account, including their unique IDs, names, event types and endpoint configurations. This query enables you to inspect and verify your existing webhook settings, ensuring seamless integration with your applications and services. Use this query to fetch webhook details, troubleshoot issues or prepare for updates and modifications.

<details>

<summary>Schema</summary>

```graphql
"""
Enum representing the different types of events that can be tracked with a webhook.
"""
enum EventType {
  """
  Event type for floor occupancy updates.
  """
  FLOOR_OCCUPANCY

  """
  Event type for room occupancy updates.
  """
  ROOM_OCCUPANCY

  """
  Event type for zone occupancy updates.
  """
  ZONE_OCCUPANCY

  """
  Event type for detection coordinate updates.
  """
  DETECTIONS

  """
  Event type for traffic (enter/exits) updates.
  """
  TRAFFIC
}

"""
A type representing API credentials.
"""
type ApiKey {
  """
  This key represents the type of header key, often specifying the header name to be used in authentication, such as 'x-api-key'.
  """
  key: String!

  """
  The actual API key value used for authentication in requests.
  """
  value: String!
}

"""
A type representing basic authentication configuration.
"""
type BasicAuth {
  """
  The username for basic authentication.
  """
  username: String!

  """
  The password associated with the username for basic authentication.
  """
  password: String!
}

"""
Configuration settings for the endpoint where the webhook sends data.
"""
type EndpointConfig {
  """
  The URL of the webhook endpoint where events will be sent. Only HTTPS URLs are supported.
  """
  url: String!

  """
  The HTTP timeout in seconds for the request to complete. Acceptable values are between 1 and 15.
  """
  httpTimeout: Int!

  """
  Optional API key configuration for header-based authentication.
  """
  apiKey: ApiKey

  """
  Optional basic authentication configuration, including username and password.
  """
  basicAuth: BasicAuth
}

"""
Represents a webhook subscription, containing information on the events it tracks and the endpoint configuration.
"""
type Webhook {
  """
  A unique identifier for the webhook subscription.
  """
  id: ID!

  """
  A user-defined name for the webhook, useful for identifying the webhook purpose.
  """
  name: String!

  """
  A list of event types that the webhook subscribes to, such as FLOOR_OCCUPANCY, ROOM_OCCUPANCY, etc.
  """
  eventTypes: [EventType!]!

  """
  Configuration details for the endpoint, including URL, timeout, and authentication options.
  """
  endpointConfig: EndpointConfig!
  
  """
  Optional filters to apply to webhook events. Supports filtering by various IDs and MAC addresses.
  example: 
  {
    org_ids: ["org_1", "org_2"],
    site_ids: ["site_1", "site_2"],
    building_ids: ["building_1", "building_2"],
    floor_ids: ["space_1", "space_2"],
    room_ids: ["room_1", "room_2"],
    zone_ids: ["zone_1", "zone_2"],
    mac_addresses: ["01-23-45-67", "ab-cd-ef-gh"]
  }
  """
  filters: JSON
  
  """
  When true, webhooks will only be sent when the value of the event changes from the previous value.
  """
  send_on_value_change: Boolean!
}

# Type for webhooks response
type WebhooksResponse {
  # Array of webhooks
  data: [Webhook!]!
}
```

</details>

<details>

<summary>Query</summary>

```graphql
query {
    webhooks {
        id
        name
        event_types
        endpoint_config {
            url
            http_timeout
            api_key {
                key
                value
            }
            basic_auth {
                username
                password
            }
        }
    }
}
```

</details>

<details>

<summary>Response (Example)</summary>

```json
{
  "data": {
    "webhooks": {
      "data": [
        {
          "id": "webhook_2oXTcK8Gn53tURQUokTyLFmJyQr",
          "name": "My Webhook",
          "event_types": ["FLOOR_OCCUPANCY"],
          "endpoint_config": {
            "url": "https://customer.api.com/webhooks",
            "http_timeout": 10,
            "api_key": {
              "key": "x-api-key",
              "value": "akfsdl;jf;alksjdfiuhwiefhsks"
            },
            "basic_auth": {
              "username": "bob",
              "password": "letmein"
            }
          }
        },
        {
          "id": "webhook_2oXTcNHRxrA7hhPv2vSh1wWS6xc",
          "name": "Another Webhook",
          "event_types": ["ROOM_OCCUPANCY", "DETECTIONS"],
          "endpoint_config": {
            "url": "https://another.customer.api.com/webhooks",
            "http_timeout": 15,
            "api_key": null,
            "basic_auth": null
          }
        }
      ]
    }
  }
}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.butlr.io/real-time-occupancy/manage-webhooks/list-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
