# Detach Webhook

`POST /webhooks/detach`

Detach a webhook from one or more senders (phone numbers or RCS agent IDs) to stop receiving event notifications.

The webhook itself is not deleted and remains available for use with other senders. Works regardless of webhook status. Supports bulk operations with up to 50 senders per request.

## Authentication

Send your API key in the `PINNACLE-API-KEY` header.

## Request body

Required.

Content type: `application/json`.

### Fields

- `webhookId` — `string`, minimum length: 1. Webhook ID to detach (starts with `wh_`). Must be a webhook owned by your team.
- `senders` — `string[]`. Array of senders to detach the webhook from. Can be phone numbers in E.164 format or RCS agent IDs.

### Example

```json
{
  "webhookId": "webhook_01J8K3R7M9",
  "senders": [
    "+14155551234",
    "agent_abc123"
  ]
}
```

## Responses

### 200

Successfully detached webhook from the specified senders.

Senders that could not be found are returned in the `failed` array with error details.

Content type: `application/json`. Schema: `DetachWebhookResult`.

- `webhookId` — `string`. The webhook that was detached from the senders.
- `senders` — `string[]`. Senders that were successfully detached (phone numbers in E.164 format or RCS agent IDs).
- `failed` — `object[]`. Senders that could not be detached, with error details.
- `failed[].sender` — `string`. The sender that failed.
- `failed[].error` — `string`. Reason for the failure.

Example:

```json
{
  "webhookId": "wh_1234567890",
  "senders": [
    "+14155551234"
  ],
  "failed": []
}
```

### 400

Validation failed. The payload has missing required fields and/or invalid types.

See https://zod.dev/error-formatting for more information.

Content type: `application/json`. Schema: `object`.

- `description` — `string`. Human-readable summary of validation failures.
- `errors` — `object`. Structured dictionary of issues containing two main sections:
- `errors`: Array of global validation errors not tied to specific fields
- `properties`: Object mapping field names to their specific validation errors, where each field contains an `errors` array

Example:

```json
{
  "description": "✖ Invalid input: expected string, received number\n  → at example_field",
  "errors": {
    "errors": [
      "Unrecognized key: 'extraKey'"
    ],
    "properties": {
      "example_field": {
        "errors": [
          "Invalid input: expected string, received NaN"
        ]
      }
    }
  }
}
```

### 401

The request lacks valid authentication credentials or the provided credentials are invalid.

Ensure you're including a valid API key in the request headers and that your account has the necessary permissions to access this endpoint.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "Invalid API key."
}
```

### 404

The requested resource could not be found.

This may occur if the identifier is incorrect, the resource has been deleted, or you don't have permission to access it.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "The requested resource could not be found."
}
```

### 500

An unexpected error occurred on Pinnacle's servers while processing your request.

If this error persists, please contact support with the request details.

Content type: `application/json`. Schema: `object`.

- `error` — `string`. Human-readable description of the error that occurred, corresponding to the HTTP status code.

Example:

```json
{
  "error": "An unexpected error occurred while processing your request."
}
```

## SDK examples

### TypeScript

```typescript
import { PinnacleClient } from "rcs-js";

const client = new PinnacleClient({
  apiKey: process.env.PINNACLE_API_KEY!,
});

await client.webhooks.detach({
    webhookId: "webhookId",
    senders: ["+14155551234", "agent_abc123"]
});
```

### Python

```python
import os
from rcs import Pinnacle

client = Pinnacle(
    api_key=os.environ["PINNACLE_API_KEY"],
)

client.webhooks.detach(
    webhook_id="webhookId",
    senders=["+14155551234", "agent_abc123"],
)
```

### Ruby

```ruby
require "rcs"

client = Pinnacle::Client.new(
  api_key: ENV.fetch("PINNACLE_API_KEY")
)

client.webhooks.detach(
  webhook_id: "webhookId",
  senders: %w[+14155551234 agent_abc123]
)
```

## Machine-readable schema

[OpenAPI 3.1 JSON](https://docs.pinnacle.sh/openapi.json)
