# Remove Contact from Segment

> DELETE /contacts/:id/segments/:segment_id — remove an existing contact from a segment.

`DELETE /contacts/:id/segments/:segment_id`

Remove an existing contact from a segment. The contact is identified in the path by either its ID or its email address.

Either `id` or `email` must be provided.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | No | The Contact ID. |
| `email` | string | No | The Contact Email. |
| `segment_id` | string | Yes | The Segment ID. |

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.contacts.removeFromSegment('e169aa45-1ecf-4183-9955-b1499d5701d3', '78261eea-8f8b-4381-83c6-79fa7120f1cf');
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Contacts.remove_from_segment("e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->contacts->removeFromSegment('e169aa45-1ecf-4183-9955-b1499d5701d3', '78261eea-8f8b-4381-83c6-79fa7120f1cf');
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Contacts.remove_from_segment("e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf")
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

removed, err := client.Contacts.RemoveFromSegment("e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf")
```

**Rust**

```rust
use sendping::SendPing;

let mb = SendPing::new("mb_xxxxxxxxx");

let _removed = mb.contacts.remove_from_segment("e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf").await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.contacts().removeFromSegment(
        "e169aa45-1ecf-4183-9955-b1499d5701d3",
        "78261eea-8f8b-4381-83c6-79fa7120f1cf");
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.ContactRemoveFromSegmentAsync(
    "e169aa45-1ecf-4183-9955-b1499d5701d3",
    "78261eea-8f8b-4381-83c6-79fa7120f1cf");
```

**cURL**

```bash
curl -X DELETE 'https://www.sendping.co/api/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
sendping contacts remove-from-segment e169aa45-1ecf-4183-9955-b1499d5701d3 78261eea-8f8b-4381-83c6-79fa7120f1cf
```

### Response

```json
{
  "id": "e169aa45-1ecf-4183-9955-b1499d5701d3",
  "audienceId": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
  "deleted": true
}
```
