---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.ru/dev/webmaster/doc/en/reference/hosts-add-site.md
  - https://yandex.ru/dev/webmaster/doc/ru/reference/hosts-add-site.md
keywords:
  - s
  - i
  - t
  - e
  - ' '
  - l
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/webmaster/doc/en/llms.txt


# Adding a site

Adds the site to the user's site list.

## Request format

```
POST https://api.webmaster.yandex.net/v4/user/{[user-id](*user-id)}/hosts
```

#|
||
`user-id`
|
<!-- source: en/_includes/popups.md -->
Type: `int64`. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the [GET /v4/user](https://yandex.ru/dev/webmaster/doc/en/reference/user.md) method.
<!-- endsource: en/_includes/popups.md -->
||
|#


In the request body, specify the new site name and the desired data type in the `Content-type` header (`application/json` or `application/xml`):

### Example


{% list tabs %}

- JSON

  
  ```javascript
  {
    "host_url": "http://example.com"
  }
  ```
  

- XML

  
  ```xml
  <Data>
      <[host_url](*host_url)>http://example.com</host_url>
  </Data>
  ```

{% endlist %}

#|
|| **Parameter** | **Description** ||
|| `host_url` | URI of the site to add. ||
|#

## Response format

### Example


{% list tabs %}

- JSON

  
  ```javascript
  {
    "host_id": "http:example.com:80"
  }
  ```
  

- XML

  
  ```xml
  <Data>
      <[host_id](*host_id_2)>http:example.com:80</host_id>
  </Data>
  ```

{% endlist %}

#|
|| **Parameter** | **Required** | **Type** | **Description** ||
|| `host_id` | Yes | `host id` (`string`) | ID of the added site. ||
|#

## Response codes

To view the response structure in detail, click the reason.

#|
||
**Code** | **Reason** | **Description**
||
||
201 | CREATED | The site was added to the user's list.
||
||
403
|
[HOSTS_LIMIT_EXCEEDED](https://yandex.ru/dev/webmaster/doc/en/reference/errors.md#hosts-limit-exceeded)
|
The number of sites in the user's site list exceeded the limit (the current limit is 1703).

{% list tabs %}

- JSON

  ```json 
  {  
      "error_code": "HOSTS_LIMIT_EXCEEDED",  
      "limit": 1,  
      "error_message": "explicit error message"
  }
  ```

- XML

  ```xml 
  <Data>   
      <[error_code](*error_code)>HOSTS_LIMIT_EXCEEDED</error_code>    
      <[limit](*limit)>1</limit>    
      <[error_message](*error_message)>explicit error message</error_message>
  </Data>
  ```

{% endlist %}
||
||
403
|
[INVALID_USER_ID](https://yandex.ru/dev/webmaster/doc/en/reference/errors.md#invalid-user-id)
|
The ID of the user who issued the token differs from the one specified in the request. In the examples below, `{user_id}` shows the correct `uid` of the OAuth token owner.

{% list tabs %}

- JSON

  ```json 
  {   
      "error_code": "INVALID_USER_ID",   
      "available_user_id": 1,   
      "error_message": "Invalid user id. {user_id} should be used." 
  }
  ```

- XML

  ```xml 
  <Data>     
      <[error_code](*error_code)>INVALID_USER_ID</error_code>     
      <[available_user_id](*available_user_id)>1</available_user_id>     
      <[error_message](*error_message)>Invalid user id. {user_id} should be used.</error_message> 
  </Data>
  ```

{% endlist %}
||
||
409
|
[HOST_ALREADY_ADDED](https://yandex.ru/dev/webmaster/doc/en/reference/errors.md#host-already-added)
|
A site with this name was already added to the user's site list.

{% list tabs %}

- JSON

  ```json 
  {   
      "error_code": "HOST_ALREADY_ADDED",   
      "host_id": "http:ya.ru:80",   
      "verified": false,   
      "error_message": "some string"
  }
  ```

- XML

  ```xml 
  <Data>   
      <error_code>HOST_ALREADY_ADDED</error_code>    
      <host_id>http:ya.ru:80</host_id>    
      <verified>false</verified>    
      <error_message>some string</error_message>
  </Data>
  ```

{% endlist %}
||
|#

### Related information

- [Error codes and statuses](https://yandex.ru/dev/webmaster/doc/en/reference/errors.md)




[*user-id]: Type: `int64`. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the [GET /v4/user](https://yandex.ru/dev/webmaster/doc/en/reference/user.md) method.

[*host_url]: **Description**

URI of the site to add.

[*host_id_2]: **Required**

Yes

**Type**

`host id` (`string`)

**Description**

ID of the added site.

[*error_code]: **Description**

Error code.

[*available_user_id]: **Description**

ID of the user who allowed access.

[*limit]: **Description**

The limit on the number of added sites.

[*error_message]: **Description**

Error message.