# Transfer

## Transfer Device

<mark style="color:green;">`POST`</mark> `https://{server_address}/api/v1/organization/device/transfer`

**Note:** either `newUserId` or `newOrgId` should be specified. If `newUserId` is specified - `newOrgId` is ignored and vise versa.\
You must have access to destination organization. If destination organization is not specified - new owner's organization is being used.\
New device owner's account must be activated.

#### Headers

| Name                                            | Type                   | Description |
| ----------------------------------------------- | ---------------------- | ----------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer {access\_token} |             |
| Content-Type<mark style="color:red;">\*</mark>  | application/json       |             |

#### Request Body

| Name                                       | Type | Description                        |
| ------------------------------------------ | ---- | ---------------------------------- |
| deviceId<mark style="color:red;">\*</mark> | 1    | Device identifier.                 |
| newUserId                                  | 1    | New device owner identifier.       |
| newOrgId                                   | 1    | New organization owner identifier. |

{% tabs %}
{% tab title="404: Not Found Device is not found" %}

```json
{
    "error": {
        "message": "Device with identifier 1 is not found or belong to another organization."
    }
}
```

{% endtab %}

{% tab title="204: No Content Device transfered" %}

{% endtab %}

{% tab title="404: Not Found Destination organization is not found" %}

```json
{
    "error": {
        "message": "Destination organization is not found or you don't have access to it."
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Same owner transfer error" %}

```json
{
    "error": {
        "message": "Can't transfer to the same owner"
    }
}
```

{% endtab %}
{% endtabs %}

Request examples:

```bash
# curl command example:
$ curl -X POST -H "Content-Type: application/json" \
      -H "Authorization: Bearer {accessToken}" \
      -d '{"deviceId":1,"newUserId":1}' \
      https://fra1.blynk.cloud/api/v1/organization/device/transfer

$ curl -X POST -H "Content-Type: application/json" \
      -H "Authorization: Bearer eIdWHQqRfFmvP5LDDh-IGxPUzi7I27HthzCPAVmS" \
      -d '{"deviceId":1,"newUserId":1}' \
      https://fra1.blynk.cloud/api/v1/organization/device/transfer
```
