# Delete contact

> DELETE /contacts/:id — remove a contact by id or email.

`DELETE /contacts/:id`

Remove a contact. The `:id` segment accepts either the contact `id` or its `email`. An id is exact; when addressing by **email**, append `?domain=` to say which of your sending domains the contact lives on.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The contact’s `id` *or* its `email` — either value is accepted in this path segment. |

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | string | No | The sending domain the contact belongs to. Needed only when addressing by email; an id is exact. |

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.contacts.remove({ id: '479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6' });
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Contacts.delete({
  "id": "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6"
})
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->contacts->remove([
  'id' => "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Contacts.remove({
  "id": "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6"
})
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

removed, err := client.Contacts.Remove(&sendping.RemoveContactRequest{
    Id: "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6",
})
```

**Rust**

```rust
use sendping::{ContactLookup, SendPing};

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

let params = ContactLookup::new("479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6");
let _removed = mb.contacts.remove(params).await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.contacts().remove("479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6");
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.ContactDeleteAsync("479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6");
```

**cURL**

```bash
curl -X DELETE 'https://www.sendping.co/api/contacts/479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
sendping contacts delete 479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6
```

**Response (200)**

```json
{
  "object": "contact",
  "id": "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6",
  "deleted": true
}
```

## Audience-scoped variant

The nested route `DELETE /audiences/:audience_id/contacts/:id` still works and scopes the delete to one audience:

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.contacts.remove({ audienceId: 'AUDIENCE_ID', id: 'steve@example.com' });
console.log({ data, error });
```

**Ruby**

```ruby
require 'net/http'
require 'uri'

uri = URI('https://www.sendping.co/api/audiences/AUDIENCE_ID/contacts/steve@example.com')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Delete.new(uri)
req['Authorization'] = 'Bearer mb_xxxxxxxxx'
res = http.request(req)
puts res.body
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->contacts->remove([
  'audienceId' => "AUDIENCE_ID",
  'id' => "steve@example.com"
]);
```

**Python**

```python
import requests

res = requests.delete(
    "https://www.sendping.co/api/audiences/AUDIENCE_ID/contacts/steve@example.com",
    headers={"Authorization": "Bearer mb_xxxxxxxxx"},
)
print(res.json())
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

removed, err := client.Contacts.Remove(&sendping.RemoveContactRequest{
    AudienceId: "AUDIENCE_ID",
    Id:         "steve@example.com",
})
```

**Rust**

```rust
use sendping::{ContactLookup, SendPing};

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

let params = ContactLookup::new("steve@example.com").with_audience_id("AUDIENCE_ID");
let _removed = mb.contacts.remove(params).await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.contacts().removeByAudience(
        "AUDIENCE_ID",
        "steve@example.com");
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.ContactDeleteAsync(
    audienceId: "AUDIENCE_ID",
    contactIdOrEmail: "steve@example.com");
```

**cURL**

```bash
curl -X DELETE 'https://www.sendping.co/api/audiences/AUDIENCE_ID/contacts/steve@example.com' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

An unknown contact (or audience) returns `404 not_found`. See [Errors](https://www.sendping.co/docs/api/errors).
