# Transfer a domain

Order an inbound domain transfer with an EPP code, nameservers, contacts, and optional add-ons.

Order an inbound transfer of a domain registered elsewhere. Like registration, this creates an order, deducts your reseller credits, and provisions the domain once the account, order, and transfer complete.

`POST /order/domains/transfer`

The body is the same as [Register a domain](/api-reference/register) plus an `eppcode` field. Send it as `application/x-www-form-urlencoded` with PHP bracket notation for nested values. Authenticate with the `username` and `token` headers described in [Authentication](/guides/authentication).

<Note>
  A live transfer needs a domain held at another registrar and a valid EPP (authorization) code, so this flow was not exercised against the sandbox. The request shape below matches the register endpoint, and a successful order returns the same `"success"` response.
</Note>

## Parameters

<ParamField body="domain" type="text" required>
  The full domain to transfer in, for example `example.com`.
</ParamField>

<ParamField body="eppcode" type="text">
  The EPP (authorization/transfer) code obtained from the losing registrar. Required by most TLDs to authorize the transfer.
</ParamField>

<ParamField body="regperiod" type="numeric" required>
  Number of years to add to the registration on transfer.
</ParamField>

<ParamField body="nameservers" type="object" required>
  The domain's nameservers, sent as `nameservers[ns1]`…`nameservers[ns5]`. `ns1` and `ns2` are required. See the [Nameservers model](/api-reference/models).
</ParamField>

<ParamField body="contacts" type="object" required>
  The registrant, tech, billing, and admin contacts, sent as `contacts[registrant][...]`, `contacts[tech][...]`, `contacts[billing][...]`, and `contacts[admin][...]`. See the [Contacts model](/api-reference/models).
</ParamField>

<ParamField body="domainfields" type="text">
  TLD-specific fields, sent as nested `domainfields[...]` values where the TLD requires them.
</ParamField>

<ParamField body="addons" type="object">
  Optional add-ons, sent as `addons[dnsmanagement]`, `addons[emailforwarding]`, and `addons[idprotection]`, each `1` or `0`. See the [Addons model](/api-reference/models).
</ParamField>

For the transfer price of a domain, see [Domain pricing](/api-reference/pricing) with the `transfer` type.

## Request

<CodeGroup>
```bash cURL
API_KEY="your-api-key"
EMAIL="you@example.com"
ENDPOINT="https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
TS=$(date -u +"%y-%m-%d %H")
TOKEN=$(printf '%s' "$API_KEY" \
  | openssl dgst -sha256 -hmac "$EMAIL:$TS" -hex \
  | sed 's/^.*= //' | tr -d '\n' | base64 -w0)

curl -s "$ENDPOINT/order/domains/transfer" \
  -H "username: $EMAIL" \
  -H "token: $TOKEN" \
  --data "domain=example.com" \
  --data "eppcode=EPP-AUTH-CODE" \
  --data "regperiod=1" \
  --data "nameservers[ns1]=ns1.hostraha.com" \
  --data "nameservers[ns2]=ns2.hostraha.com" \
  --data "addons[dnsmanagement]=1" \
  --data "addons[idprotection]=1" \
  --data "contacts[registrant][firstname]=Jane" \
  --data "contacts[registrant][lastname]=Doe" \
  --data "contacts[registrant][fullname]=Jane Doe" \
  --data "contacts[registrant][companyname]=Hostraha" \
  --data "contacts[registrant][email]=you@example.com" \
  --data "contacts[registrant][address1]=123 Example Street" \
  --data "contacts[registrant][city]=Nairobi" \
  --data "contacts[registrant][state]=Nairobi" \
  --data "contacts[registrant][postcode]=00100" \
  --data "contacts[registrant][country]=KE" \
  --data "contacts[registrant][phonenumber]=+15555550100" \
  --data "contacts[tech][firstname]=Jane" \
  --data "contacts[tech][lastname]=Doe" \
  --data "contacts[tech][fullname]=Jane Doe" \
  --data "contacts[tech][companyname]=Hostraha" \
  --data "contacts[tech][email]=you@example.com" \
  --data "contacts[tech][address1]=123 Example Street" \
  --data "contacts[tech][city]=Nairobi" \
  --data "contacts[tech][state]=Nairobi" \
  --data "contacts[tech][postcode]=00100" \
  --data "contacts[tech][country]=KE" \
  --data "contacts[tech][phonenumber]=+15555550100" \
  --data "contacts[billing][firstname]=Jane" \
  --data "contacts[billing][lastname]=Doe" \
  --data "contacts[billing][fullname]=Jane Doe" \
  --data "contacts[billing][companyname]=Hostraha" \
  --data "contacts[billing][email]=you@example.com" \
  --data "contacts[billing][address1]=123 Example Street" \
  --data "contacts[billing][city]=Nairobi" \
  --data "contacts[billing][state]=Nairobi" \
  --data "contacts[billing][postcode]=00100" \
  --data "contacts[billing][country]=KE" \
  --data "contacts[billing][phonenumber]=+15555550100" \
  --data "contacts[admin][firstname]=Jane" \
  --data "contacts[admin][lastname]=Doe" \
  --data "contacts[admin][fullname]=Jane Doe" \
  --data "contacts[admin][companyname]=Hostraha" \
  --data "contacts[admin][email]=you@example.com" \
  --data "contacts[admin][address1]=123 Example Street" \
  --data "contacts[admin][city]=Nairobi" \
  --data "contacts[admin][state]=Nairobi" \
  --data "contacts[admin][postcode]=00100" \
  --data "contacts[admin][country]=KE" \
  --data "contacts[admin][phonenumber]=+15555550100"
```

```php PHP
<?php
$apiKey   = "your-api-key";
$email    = "you@example.com";
$endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

$token = base64_encode(hash_hmac("sha256", $apiKey, "{$email}:" . gmdate("y-m-d H")));

$contact = [
    "firstname"   => "Jane",
    "lastname"    => "Doe",
    "fullname"    => "Jane Doe",
    "companyname" => "Hostraha",
    "email"       => "you@example.com",
    "address1"    => "123 Example Street",
    "city"        => "Nairobi",
    "state"       => "Nairobi",
    "postcode"    => "00100",
    "country"     => "KE",
    "phonenumber" => "+15555550100",
];

$fields = [
    "domain"      => "example.com",
    "eppcode"     => "EPP-AUTH-CODE",
    "regperiod"   => 1,
    "nameservers" => [
        "ns1" => "ns1.hostraha.com",
        "ns2" => "ns2.hostraha.com",
    ],
    "addons" => [
        "dnsmanagement" => 1,
        "idprotection"  => 1,
    ],
    "contacts" => [
        "registrant" => $contact,
        "tech"       => $contact,
        "billing"    => $contact,
        "admin"      => $contact,
    ],
];

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "{$endpoint}/order/domains/transfer");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
    "username: {$email}",
    "token: {$token}",
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

```python Python
from datetime import datetime, timezone

API_KEY  = "your-api-key"
EMAIL    = "you@example.com"
ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"

def token() -> str:
    ts = datetime.now(timezone.utc).strftime("%y-%m-%d %H")
    digest = hmac.new(f"{EMAIL}:{ts}".encode(), API_KEY.encode(), hashlib.sha256).hexdigest()
    return base64.b64encode(digest.encode()).decode()

contact = {
    "firstname": "Jane",
    "lastname": "Doe",
    "fullname": "Jane Doe",
    "companyname": "Hostraha",
    "email": "you@example.com",
    "address1": "123 Example Street",
    "city": "Nairobi",
    "state": "Nairobi",
    "postcode": "00100",
    "country": "KE",
    "phonenumber": "+15555550100",
}

data = {
    "domain": "example.com",
    "eppcode": "EPP-AUTH-CODE",
    "regperiod": 1,
    "nameservers[ns1]": "ns1.hostraha.com",
    "nameservers[ns2]": "ns2.hostraha.com",
    "addons[dnsmanagement]": 1,
    "addons[idprotection]": 1,
}
for role in ("registrant", "tech", "billing", "admin"):
    for key, value in contact.items():
        data[f"contacts[{role}][{key}]"] = value

resp = requests.post(
    f"{ENDPOINT}/order/domains/transfer",
    headers={"username": EMAIL, "token": token()},
    data=data,
)
print(resp.json())
```

```javascript Node.js

const API_KEY  = "your-api-key";
const EMAIL    = "you@example.com";
const ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

function token() {
  const ts = new Date().toISOString().slice(2, 13).replace("T", " "); // "yy-mm-dd HH" UTC
  const digest = crypto.createHmac("sha256", `${EMAIL}:${ts}`).update(API_KEY).digest("hex");
  return Buffer.from(digest, "utf8").toString("base64");
}

const contact = {
  firstname: "Jane",
  lastname: "Doe",
  fullname: "Jane Doe",
  companyname: "Hostraha",
  email: "you@example.com",
  address1: "123 Example Street",
  city: "Nairobi",
  state: "Nairobi",
  postcode: "00100",
  country: "KE",
  phonenumber: "+15555550100",
};

const body = new URLSearchParams();
body.append("domain", "example.com");
body.append("eppcode", "EPP-AUTH-CODE");
body.append("regperiod", "1");
body.append("nameservers[ns1]", "ns1.hostraha.com");
body.append("nameservers[ns2]", "ns2.hostraha.com");
body.append("addons[dnsmanagement]", "1");
body.append("addons[idprotection]", "1");
for (const role of ["registrant", "tech", "billing", "admin"]) {
  for (const [key, value] of Object.entries(contact)) {
    body.append(`contacts[${role}][${key}]`, value);
  }
}

const res = await fetch(`${ENDPOINT}/order/domains/transfer`, {
  method: "POST",
  headers: { username: EMAIL, token: token() },
  body,
});
console.log(await res.json());
```

```go Go
package main

	"crypto/hmac"
	"crypto/sha256"
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"strings"
	"time"
)

const (
	apiKey   = "your-api-key"
	email    = "you@example.com"
	endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
)

func token() string {
	ts := time.Now().UTC().Format("06-01-02 15") // yy-mm-dd HH
	mac := hmac.New(sha256.New, []byte(email+":"+ts))
	mac.Write([]byte(apiKey))
	return base64.StdEncoding.EncodeToString([]byte(hex.EncodeToString(mac.Sum(nil))))
}

func main() {
	contact := map[string]string{
		"firstname":   "Jane",
		"lastname":    "Doe",
		"fullname":    "Jane Doe",
		"companyname": "Hostraha",
		"email":       "you@example.com",
		"address1":    "123 Example Street",
		"city":        "Nairobi",
		"state":       "Nairobi",
		"postcode":    "00100",
		"country":     "KE",
		"phonenumber": "+15555550100",
	}

	form := url.Values{}
	form.Set("domain", "example.com")
	form.Set("eppcode", "EPP-AUTH-CODE")
	form.Set("regperiod", "1")
	form.Set("nameservers[ns1]", "ns1.hostraha.com")
	form.Set("nameservers[ns2]", "ns2.hostraha.com")
	form.Set("addons[dnsmanagement]", "1")
	form.Set("addons[idprotection]", "1")
	for _, role := range []string{"registrant", "tech", "billing", "admin"} {
		for key, value := range contact {
			form.Set(fmt.Sprintf("contacts[%s][%s]", role, key), value)
		}
	}

	req, _ := http.NewRequest("POST", endpoint+"/order/domains/transfer", strings.NewReader(form.Encode()))
	req.Header.Set("username", email)
	req.Header.Set("token", token())
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```
</CodeGroup>

## Response

A successful transfer order returns the bare JSON string `"success"`, matching [Register a domain](/api-reference/register).

```json
"success"
```

The order charges your reseller credits and starts the transfer. The domain provisions to your account once the account, order, and registry transfer complete. See [Credits and billing](/guides/credits-and-billing).
