# Webhook Subscriptions

## Create a new webhook subscription

`client.WebhookSubscriptions.New(ctx, body) (*WebhookSubscriptionNewResponse, error)`

**post** `/v3/webhook-subscriptions`

Create a new webhook subscription to receive events at a target URL.
Upon creation, a signing secret is generated for verifying webhook
authenticity. **Store this secret securely — it cannot be retrieved later.**

**Phone Number Filtering:**

- Optionally specify `phone_numbers` to only receive events for specific lines
- If omitted, events from all phone numbers are delivered (default behavior)
- Use multiple subscriptions with different `phone_numbers` to route different lines to different endpoints
- Each `target_url` can only be used once per account. To route different
  lines to different destinations, use a unique URL per subscription
  (e.g., append a query parameter: `https://example.com/webhook?line=1`)

**Webhook Delivery:**

- Events are sent via HTTP POST to the target URL
- Each request includes [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks) headers (`webhook-id`, `webhook-timestamp`, `webhook-signature`) for signature verification
- Legacy `X-Webhook-*` headers are also sent for backwards compatibility (deprecated)
- See [Verifying Webhook Signatures](https://docs.linqapp.com/channel/imessage/guides/webhooks#verifying-webhook-signatures) for verification details
- Failed deliveries (5xx, 429, network errors) are retried with exponential backoff for up to 30 minutes
- Client errors (4xx except 429) are not retried

### Parameters

- `body WebhookSubscriptionNewParams`

  - `SubscribedEvents param.Field[[]WebhookEventType]`

    List of event types to subscribe to

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL param.Field[string]`

    URL where webhook events will be sent. Must be HTTPS.

  - `PhoneNumbers param.Field[[]string]`

    Optional list of phone numbers to filter events for. Only events originating from these phone numbers will be delivered to this subscription. If omitted or empty, events from all phone numbers are delivered. Phone numbers must be in E.164 format.

  - `RoutingIDHeader param.Field[string]`

    Name of the header carrying the chat id, used to hash-route before a token is learned. Defaults to `Linq-Chat-Id`. Ignored without `routing_key_header`.

  - `RoutingKeyHeader param.Field[string]`

    Enables delivery affinity. Name of the header carrying an opaque routing token: we send it on each webhook for a chat and read it back from your 2xx response, so your edge can route to the cluster holding that chat. Omit to disable.

### Returns

- `type WebhookSubscriptionNewResponse struct{…}`

  Response returned when creating a webhook subscription. Includes the signing secret which is only shown once.

  - `ID string`

    Unique identifier for the webhook subscription

  - `CreatedAt Time`

    When the subscription was created

  - `IsActive bool`

    Whether this subscription is currently active

  - `SigningSecret string`

    Secret for verifying webhook signatures. Store this securely - it cannot be retrieved again.

  - `SubscribedEvents []WebhookEventType`

    List of event types this subscription receives

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL string`

    URL where webhook events will be sent

  - `UpdatedAt Time`

    When the subscription was last updated

  - `PhoneNumbers []string`

    Phone numbers this subscription filters for. If null or empty, events from all phone numbers are delivered.

  - `RoutingIDHeader string`

    Header carrying the chat id. Defaults to `Linq-Chat-Id` when affinity is on.

  - `RoutingKeyHeader string`

    Header carrying the routing token. Null disables delivery affinity.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  webhookSubscription, err := client.WebhookSubscriptions.New(context.TODO(), linqgo.WebhookSubscriptionNewParams{
    SubscribedEvents: []linqgo.WebhookEventType{linqgo.WebhookEventTypeMessageSent, linqgo.WebhookEventTypeMessageDelivered, linqgo.WebhookEventTypeMessageRead},
    TargetURL: "https://webhooks.example.com/linq/events",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookSubscription.ID)
}
```

#### Response

```json
{
  "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
  "created_at": "2024-01-15T10:30:00Z",
  "is_active": true,
  "signing_secret": "whsec_abc123def456",
  "subscribed_events": [
    "message.sent",
    "message.delivered",
    "message.read"
  ],
  "target_url": "https://webhooks.example.com/linq/events",
  "updated_at": "2024-01-15T10:30:00Z",
  "phone_numbers": [
    "string"
  ],
  "routing_id_header": "X-Chat-Id",
  "routing_key_header": "X-Route-Token"
}
```

## List all webhook subscriptions

`client.WebhookSubscriptions.List(ctx) (*WebhookSubscriptionListResponse, error)`

**get** `/v3/webhook-subscriptions`

Retrieve all webhook subscriptions for the authenticated partner.
Returns a list of active and inactive subscriptions with their
configuration and status.

### Returns

- `type WebhookSubscriptionListResponse struct{…}`

  - `Subscriptions []WebhookSubscription`

    List of webhook subscriptions

    - `ID string`

      Unique identifier for the webhook subscription

    - `CreatedAt Time`

      When the subscription was created

    - `IsActive bool`

      Whether this subscription is currently active

    - `SubscribedEvents []WebhookEventType`

      List of event types this subscription receives

      - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

      - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

      - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

      - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

      - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

      - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

      - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

      - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

      - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

      - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

      - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

      - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

      - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

      - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

      - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

      - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

      - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

      - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

      - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

      - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

      - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

      - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

      - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

      - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

      - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

      - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

      - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

      - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

      - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

      - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

      - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

      - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

      - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

      - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

      - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

      - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

      - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

      - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

      - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

      - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

      - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

      - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

      - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

      - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

      - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

      - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

      - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

      - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

      - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

      - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

      - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

      - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

      - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

      - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

      - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

      - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

      - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

      - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

      - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

      - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

      - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

      - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

      - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

      - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

      - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

      - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

      - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

      - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

      - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

      - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

      - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

      - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

      - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

      - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

      - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

    - `TargetURL string`

      URL where webhook events will be sent

    - `UpdatedAt Time`

      When the subscription was last updated

    - `PhoneNumbers []string`

      Phone numbers this subscription filters for. If null or empty, events from all phone numbers are delivered.

    - `RoutingIDHeader string`

      Header carrying the chat id. Defaults to `Linq-Chat-Id` when affinity is on.

    - `RoutingKeyHeader string`

      Header carrying the routing token. Null disables delivery affinity.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  webhookSubscriptions, err := client.WebhookSubscriptions.List(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookSubscriptions.Subscriptions)
}
```

#### Response

```json
{
  "subscriptions": [
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
      "created_at": "2024-01-15T10:30:00Z",
      "is_active": true,
      "subscribed_events": [
        "message.sent",
        "message.delivered",
        "message.read"
      ],
      "target_url": "https://webhooks.example.com/linq/events",
      "updated_at": "2024-01-15T10:30:00Z",
      "phone_numbers": [
        "string"
      ],
      "routing_id_header": "X-Chat-Id",
      "routing_key_header": "X-Route-Token"
    }
  ]
}
```

## Get a webhook subscription by ID

`client.WebhookSubscriptions.Get(ctx, subscriptionID) (*WebhookSubscription, error)`

**get** `/v3/webhook-subscriptions/{subscriptionId}`

Retrieve details for a specific webhook subscription including its
target URL, subscribed events, and current status.

### Parameters

- `subscriptionID string`

### Returns

- `type WebhookSubscription struct{…}`

  - `ID string`

    Unique identifier for the webhook subscription

  - `CreatedAt Time`

    When the subscription was created

  - `IsActive bool`

    Whether this subscription is currently active

  - `SubscribedEvents []WebhookEventType`

    List of event types this subscription receives

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL string`

    URL where webhook events will be sent

  - `UpdatedAt Time`

    When the subscription was last updated

  - `PhoneNumbers []string`

    Phone numbers this subscription filters for. If null or empty, events from all phone numbers are delivered.

  - `RoutingIDHeader string`

    Header carrying the chat id. Defaults to `Linq-Chat-Id` when affinity is on.

  - `RoutingKeyHeader string`

    Header carrying the routing token. Null disables delivery affinity.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  webhookSubscription, err := client.WebhookSubscriptions.Get(context.TODO(), "b2c3d4e5-f6a7-8901-bcde-f23456789012")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookSubscription.ID)
}
```

#### Response

```json
{
  "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
  "created_at": "2024-01-15T10:30:00Z",
  "is_active": true,
  "subscribed_events": [
    "message.sent",
    "message.delivered",
    "message.read"
  ],
  "target_url": "https://webhooks.example.com/linq/events",
  "updated_at": "2024-01-15T10:30:00Z",
  "phone_numbers": [
    "string"
  ],
  "routing_id_header": "X-Chat-Id",
  "routing_key_header": "X-Route-Token"
}
```

## Update a webhook subscription

`client.WebhookSubscriptions.Update(ctx, subscriptionID, body) (*WebhookSubscription, error)`

**put** `/v3/webhook-subscriptions/{subscriptionId}`

Update an existing webhook subscription. You can modify the target URL,
subscribed events, or activate/deactivate the subscription.

**Note:** The signing secret cannot be changed via this endpoint.

### Parameters

- `subscriptionID string`

- `body WebhookSubscriptionUpdateParams`

  - `IsActive param.Field[bool]`

    Activate or deactivate the subscription

  - `PhoneNumbers param.Field[[]string]`

    Updated list of phone numbers to filter events for. Set to a non-empty array to filter events to specific phone numbers. Set to an empty array or null to remove the filter and receive events from all phone numbers. Phone numbers must be in E.164 format.

  - `RoutingIDHeader param.Field[string]`

    Updated header name for the chat id. Set to null or an empty string to fall back to `Linq-Chat-Id`.

  - `RoutingKeyHeader param.Field[string]`

    Updated header name for the routing token. Set to null or an empty string to disable delivery affinity and drop the stored tokens.

  - `SubscribedEvents param.Field[[]WebhookEventType]`

    Updated list of event types to subscribe to

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL param.Field[string]`

    New target URL for webhook events

### Returns

- `type WebhookSubscription struct{…}`

  - `ID string`

    Unique identifier for the webhook subscription

  - `CreatedAt Time`

    When the subscription was created

  - `IsActive bool`

    Whether this subscription is currently active

  - `SubscribedEvents []WebhookEventType`

    List of event types this subscription receives

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL string`

    URL where webhook events will be sent

  - `UpdatedAt Time`

    When the subscription was last updated

  - `PhoneNumbers []string`

    Phone numbers this subscription filters for. If null or empty, events from all phone numbers are delivered.

  - `RoutingIDHeader string`

    Header carrying the chat id. Defaults to `Linq-Chat-Id` when affinity is on.

  - `RoutingKeyHeader string`

    Header carrying the routing token. Null disables delivery affinity.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  webhookSubscription, err := client.WebhookSubscriptions.Update(
    context.TODO(),
    "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    linqgo.WebhookSubscriptionUpdateParams{
      TargetURL: linqgo.String("https://webhooks.example.com/linq/events"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookSubscription.ID)
}
```

#### Response

```json
{
  "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
  "created_at": "2024-01-15T10:30:00Z",
  "is_active": true,
  "subscribed_events": [
    "message.sent",
    "message.delivered",
    "message.read"
  ],
  "target_url": "https://webhooks.example.com/linq/events",
  "updated_at": "2024-01-15T10:30:00Z",
  "phone_numbers": [
    "string"
  ],
  "routing_id_header": "X-Chat-Id",
  "routing_key_header": "X-Route-Token"
}
```

## Delete a webhook subscription

`client.WebhookSubscriptions.Delete(ctx, subscriptionID) error`

**delete** `/v3/webhook-subscriptions/{subscriptionId}`

Delete a webhook subscription.

### Parameters

- `subscriptionID string`

### Example

```go
package main

import (
  "context"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.WebhookSubscriptions.Delete(context.TODO(), "b2c3d4e5-f6a7-8901-bcde-f23456789012")
  if err != nil {
    panic(err.Error())
  }
}
```

#### Response

```json
{
  "error": {
    "status": 401,
    "code": 2004,
    "message": "Unauthorized - missing or invalid authentication token",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2004/"
  },
  "success": false
}
```

## Domain Types

### Webhook Subscription

- `type WebhookSubscription struct{…}`

  - `ID string`

    Unique identifier for the webhook subscription

  - `CreatedAt Time`

    When the subscription was created

  - `IsActive bool`

    Whether this subscription is currently active

  - `SubscribedEvents []WebhookEventType`

    List of event types this subscription receives

    - `const WebhookEventTypeMessageSent WebhookEventType = "message.sent"`

    - `const WebhookEventTypeMessageReceived WebhookEventType = "message.received"`

    - `const WebhookEventTypeMessageRead WebhookEventType = "message.read"`

    - `const WebhookEventTypeMessageDelivered WebhookEventType = "message.delivered"`

    - `const WebhookEventTypeMessageFailed WebhookEventType = "message.failed"`

    - `const WebhookEventTypeMessageEdited WebhookEventType = "message.edited"`

    - `const WebhookEventTypeReactionAdded WebhookEventType = "reaction.added"`

    - `const WebhookEventTypeReactionRemoved WebhookEventType = "reaction.removed"`

    - `const WebhookEventTypePollReceived WebhookEventType = "poll.received"`

    - `const WebhookEventTypePollFailed WebhookEventType = "poll.failed"`

    - `const WebhookEventTypePollSent WebhookEventType = "poll.sent"`

    - `const WebhookEventTypePollDelivered WebhookEventType = "poll.delivered"`

    - `const WebhookEventTypePollRead WebhookEventType = "poll.read"`

    - `const WebhookEventTypePollUpdated WebhookEventType = "poll.updated"`

    - `const WebhookEventTypePollVoteAdded WebhookEventType = "poll.vote.added"`

    - `const WebhookEventTypePollVoteRemoved WebhookEventType = "poll.vote.removed"`

    - `const WebhookEventTypePollReactionAdded WebhookEventType = "poll.reaction.added"`

    - `const WebhookEventTypeParticipantAdded WebhookEventType = "participant.added"`

    - `const WebhookEventTypeParticipantRemoved WebhookEventType = "participant.removed"`

    - `const WebhookEventTypeChatCreated WebhookEventType = "chat.created"`

    - `const WebhookEventTypeChatGroupNameUpdated WebhookEventType = "chat.group_name_updated"`

    - `const WebhookEventTypeChatGroupIconUpdated WebhookEventType = "chat.group_icon_updated"`

    - `const WebhookEventTypeChatGroupNameUpdateFailed WebhookEventType = "chat.group_name_update_failed"`

    - `const WebhookEventTypeChatGroupIconUpdateFailed WebhookEventType = "chat.group_icon_update_failed"`

    - `const WebhookEventTypeChatBackgroundUpdated WebhookEventType = "chat.background_updated"`

    - `const WebhookEventTypeChatBackgroundUpdateFailed WebhookEventType = "chat.background_update_failed"`

    - `const WebhookEventTypeChatTypingIndicatorStarted WebhookEventType = "chat.typing_indicator.started"`

    - `const WebhookEventTypeChatTypingIndicatorStopped WebhookEventType = "chat.typing_indicator.stopped"`

    - `const WebhookEventTypePhoneNumberStatusUpdated WebhookEventType = "phone_number.status_updated"`

    - `const WebhookEventTypePhoneNumberAssigned WebhookEventType = "phone_number.assigned"`

    - `const WebhookEventTypePhoneNumberReleased WebhookEventType = "phone_number.released"`

    - `const WebhookEventTypeContactCardReceived WebhookEventType = "contact_card.received"`

    - `const WebhookEventTypeCallInitiated WebhookEventType = "call.initiated"`

    - `const WebhookEventTypeCallRinging WebhookEventType = "call.ringing"`

    - `const WebhookEventTypeCallAnswered WebhookEventType = "call.answered"`

    - `const WebhookEventTypeCallEnded WebhookEventType = "call.ended"`

    - `const WebhookEventTypeCallFailed WebhookEventType = "call.failed"`

    - `const WebhookEventTypeCallDeclined WebhookEventType = "call.declined"`

    - `const WebhookEventTypeCallNoAnswer WebhookEventType = "call.no_answer"`

    - `const WebhookEventTypeLocationSharingStarted WebhookEventType = "location.sharing.started"`

    - `const WebhookEventTypeLocationSharingStopped WebhookEventType = "location.sharing.stopped"`

    - `const WebhookEventTypePaymentSucceeded WebhookEventType = "payment.succeeded"`

    - `const WebhookEventTypePaymentCanceled WebhookEventType = "payment.canceled"`

    - `const WebhookEventTypePaymentExpired WebhookEventType = "payment.expired"`

    - `const WebhookEventTypePaymentDeclined WebhookEventType = "payment.declined"`

    - `const WebhookEventTypePaymentAuthorized WebhookEventType = "payment.authorized"`

    - `const WebhookEventTypeConnectionCreated WebhookEventType = "connection.created"`

    - `const WebhookEventTypeConnectionRevoked WebhookEventType = "connection.revoked"`

    - `const WebhookEventTypeZeroDayRetentionUpdated WebhookEventType = "zero_day_retention.updated"`

    - `const WebhookEventTypePhoneNumberForwardingUpdated WebhookEventType = "phone_number.forwarding_updated"`

    - `const WebhookEventTypeEnvironmentLineMoved WebhookEventType = "environment.line_moved"`

    - `const WebhookEventTypeContactCardCreated WebhookEventType = "contact_card.created"`

    - `const WebhookEventTypeContactCardUpdated WebhookEventType = "contact_card.updated"`

    - `const WebhookEventTypeContactCardDeleted WebhookEventType = "contact_card.deleted"`

    - `const WebhookEventTypeAPITokenCreated WebhookEventType = "api_token.created"`

    - `const WebhookEventTypeAPITokenRenamed WebhookEventType = "api_token.renamed"`

    - `const WebhookEventTypeAPITokenExpiryScheduled WebhookEventType = "api_token.expiry_scheduled"`

    - `const WebhookEventTypeAPITokenExpired WebhookEventType = "api_token.expired"`

    - `const WebhookEventTypeAPITokenActivated WebhookEventType = "api_token.activated"`

    - `const WebhookEventTypeAPITokenDeleted WebhookEventType = "api_token.deleted"`

    - `const WebhookEventTypeEnvironmentCreated WebhookEventType = "environment.created"`

    - `const WebhookEventTypeEnvironmentRenamed WebhookEventType = "environment.renamed"`

    - `const WebhookEventTypeEnvironmentDeleted WebhookEventType = "environment.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionCreated WebhookEventType = "webhook_subscription.created"`

    - `const WebhookEventTypeWebhookSubscriptionDeleted WebhookEventType = "webhook_subscription.deleted"`

    - `const WebhookEventTypeWebhookSubscriptionTargetURLChanged WebhookEventType = "webhook_subscription.target_url_changed"`

    - `const WebhookEventTypeWebhookSubscriptionEnabled WebhookEventType = "webhook_subscription.enabled"`

    - `const WebhookEventTypeWebhookSubscriptionDisabled WebhookEventType = "webhook_subscription.disabled"`

    - `const WebhookEventTypeWebhookSubscriptionEventsUpdated WebhookEventType = "webhook_subscription.events.updated"`

    - `const WebhookEventTypeWebhookSubscriptionPhoneNumbersUpdated WebhookEventType = "webhook_subscription.phone_numbers.updated"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersSet WebhookEventType = "webhook_subscription.routing_headers_set"`

    - `const WebhookEventTypeWebhookSubscriptionRoutingHeadersCleared WebhookEventType = "webhook_subscription.routing_headers_cleared"`

    - `const WebhookEventTypeTeamMemberAdded WebhookEventType = "team_member.added"`

    - `const WebhookEventTypeTeamMemberSignedIn WebhookEventType = "team_member.signed_in"`

    - `const WebhookEventTypeTeamMemberSignedOut WebhookEventType = "team_member.signed_out"`

  - `TargetURL string`

    URL where webhook events will be sent

  - `UpdatedAt Time`

    When the subscription was last updated

  - `PhoneNumbers []string`

    Phone numbers this subscription filters for. If null or empty, events from all phone numbers are delivered.

  - `RoutingIDHeader string`

    Header carrying the chat id. Defaults to `Linq-Chat-Id` when affinity is on.

  - `RoutingKeyHeader string`

    Header carrying the routing token. Null disables delivery affinity.
