# Detach Campaign

`DELETE /phone-numbers/detach-campaign`

Remove the association between a phone number and its attached campaign.

## Authentication

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

## Request body

Required.

Content type: `application/json`.

### Fields

- `phones` — `string[]`. List of phone numbers (E.164 format).

**Limit:** 1 to 10

### Example

```json
{
  "phones": [
    "+14155559876",
    "14155550111"
  ]
}
```

## Responses

### 200

Successfully detached the campaign.

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

- `phoneNumbers` — `object[]`. List of phone numbers.
- `phoneNumbers[].phoneNumber` — `string`. Phone number (E.164 format).
- `phoneNumbers[].campaign` — `object`. Campaign that the phone is now detached from.
- `phoneNumbers[].campaign.id` — `string`. Id of the campaign. For `TOLL_FREE` campaigns, it will begin with the prefix `tf_`, for example: `tf_1234567890`. For `10DLC` campaigns, it will begin with the prefix `dlc_`, for example: `dlc_1234567890`.
- `phoneNumbers[].campaign.name` — `string`. Campaign's name.
- `phoneNumbers[].campaign.type` — `MessagingProfileEnum`, values: `TOLL_FREE`, `10DLC`. Type of messaging profile associated with the phone number.
- `failed` — `object[]`. List of numbers that were not failed to be detached.
- `failed[].number` — `string`. Phone number (E.164 format).
- `failed[].error` — `string`. Error related to why the number was not detached.

Example:

```json
{
  "phoneNumbers": [
    {
      "phoneNumber": "+14155559876",
      "campaign": {
        "id": "dlc_1234567890",
        "name": "Summer Promo",
        "type": "10DLC"
      }
    }
  ],
  "failed": [
    {
      "number": "+14155550111",
      "error": "Number is not available. Make sure your team owns this number and it is not a sandbox number."
    }
  ]
}
```

### 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."
}
```

### 403

Your subscription does not include access to this feature.

This occurs when attempting to use functionality that requires a higher subscription tier.
Please upgrade your subscription to access this feature.

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": "Your subscription does not include access to this feature."
}
```

### 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."
}
```

### 501

The requested functionality is not implemented on the server.

This typically indicates that the feature or endpoint you attempted to access is unavailable or not yet supported.

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": "This feature has not been implemented yet."
}
```

## SDK examples

### TypeScript

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

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

await client.phoneNumbers.campaign.detach({
    phones: ["+14155559876", "14155550111"]
});
```

### Python

```python
import os
from rcs import Pinnacle

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

client.phone_numbers.campaign.detach(
    phones=["+14155559876", "14155550111"],
)
```

### Ruby

```ruby
require "rcs"

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

client.phone_numbers.campaign.detach(phones: %w[+14155559876 14155550111])
```

## Machine-readable schema

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