# Claiming a domain

> Take over a domain that another account has already verified by proving DNS control through the claim flow.

When you try to add a domain that **another account** has already verified, SendPing blocks the creation and tells you the domain can be **claimed**. Claiming lets you prove control of the domain over DNS and transfer it to your account — entirely over the API.

## How it works

1. **Start a claim** — Call [Claim domain](https://www.sendping.co/docs/domains/claim) with the domain name. SendPing creates a placeholder domain on your account and returns a `domain_claim` containing a TXT `record` to add to your DNS.
2. **Add the TXT record** — Publish the returned TXT record at your DNS provider. It proves you control the domain.
3. **Verify the claim** — Call [Verify domain claim](https://www.sendping.co/docs/domains/claim). SendPing checks the TXT record and, once it resolves, transfers the domain to your account.
4. **Track the status** — Poll [Get domain claim](https://www.sendping.co/docs/domains/claim) until the claim reaches `completed`.

## Claim statuses

| Status | Meaning |
| --- | --- |
| `pending` | Waiting for DNS verification. |
| `verified` | DNS proof accepted; the transfer is in progress. |
| `completed` | The domain now belongs to your account. |
| `failed` | The claim could not be completed. |
| `expired` | The claim window passed before it completed. |

## Start a claim

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.domains.claim({ "name": "example.com" });
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Domains.claim({
  "name": "example.com"
})
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->domains->claim([
  'name' => "example.com"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Domains.claim({
  "name": "example.com"
})
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

claim, err := client.Domains.Claim(&sendping.ClaimDomainRequest{
    Name: "example.com",
})
```

**Rust**

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

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

let _claim = mb.domains.claim(ClaimDomainOptions::new("example.com")).await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.domains().claim(ClaimDomainRequest.builder().name("example.com").build());
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.DomainClaimAsync(new DomainClaimOptions { Name = "example.com" });
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/domains/claim' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "example.com" }'
```

**CLI**

```bash
sendping domains claim start example.com
```

## Canceling a claim

Cancel a pending claim by deleting its placeholder domain with [Delete domain](https://www.sendping.co/docs/api/domains-delete), using the `domain_id` from the `domain_claim` object.

> **Note:** The claim flow only ever transfers a domain after DNS ownership has been proven by the TXT record, so a domain can only be claimed by someone who controls its DNS.
