Update Webhooks

Update existing webhooks with new configurations.

First, obtain an access token to get started here.

Update existing webhooks to modify their configurations, such as changing the event types, endpoint URL or authentication details. Provide the updated WebhookInput object, including the webhook ID, to apply the changes. The mutation returns the updated webhook(s).

Schema
type Mutation {
  """
  Mutation to update one or more existing webhooks.
  """
  updateWebhooks(
    """
    A list of WebhookUpdateInput objects, each containing the ID of the webhook to update and the fields to modify.
    """
    input: [WebhookUpdateInput!]!
  ): [Webhook!]
}

"""
Input type for updating an existing webhook.
"""
input WebhookUpdateInput {
  """
  Unique identifier for the webhook to be updated.
  """
  id: ID!
  
  """
  Updated name for the webhook, chosen by the user.
  """
  name: String
  
  """
  Updated list of event types the webhook will subscribe to.
  """
  eventTypes: [EventType!]
  
  """
  Updated configuration settings for the endpoint.
  """
  endpointConfig: EndpointConfigInput
}

"""
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
}

"""
Input type for endpoint configuration, specifying the webhook destination and authentication settings.
"""
input EndpointConfigInput {
  """
  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 range from 1 to 15.
  """
  httpTimeout: Int!
  
  """
  Optional API key configuration for header-based authentication.
  """
  apiKey: ApiKeyInput
  
  """
  Optional basic authentication configuration, providing a username and password.
  """
  basicAuth: BasicAuthInput
}

"""
Input type for API key configuration, defining the API key and the header name to be used.
"""
input ApiKeyInput {
  """
  The header key name to be used for the API key, such as 'x-api-key'.
  """
  key: String!
  
  """
  The actual API key value for authentication.
  """
  value: String!
}

"""
Input type for basic authentication, specifying username and password credentials.
"""
input BasicAuthInput {
  """
  The username for basic authentication.
  """
  username: String!
  
  """
  The password for basic authentication, associated with the username.
  """
  password: String!
}

"""
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!
}
Mutation
mutation UpdateWebhooks ($input: [WebhookUpdateInput!]!) {
  udpateWebhooks(input: $input) {
    id
    name
    event_types
    endpoint_config {
      url
      http_timeout
      api_key {
        key
        value
      }
      basic_auth {
        username
        password
      }
    }
  }
}

#variables
{
  "input": [{
      "id": "webhook_2oqujQF2pRZO8BqPgT8dWkf4Swb",
      "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_2oqujRtbTdX1KTA0olXvAtftGWA"
      "name": "Another Webhook",
      "event_types": ["ROOM_OCCUPANCY", "DETECTIONS"],
      "endpoint_config": {
        "url": "https://another.customer.api.com/webhooks",
        "http_timeout": 15
      }
    }]
}
Response (Example)
{
  "data": {
    "updateWebhooks": [
      {
        "id": "webhook_2oqujQF2pRZO8BqPgT8dWkf4Swb",
        "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_2oqujRtbTdX1KTA0olXvAtftGWA",
        "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
        }
      }
    ]
  }
}

Last updated