Adding a site

Adds the site to the user's site list.

  1. Request format
  2. Response format
  3. Response codes

Request format

POST https://api.webmaster.yandex.net/v4/user/{user-id}/hosts
user-idType: int64. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the GET /v4/user method.
user-idType: int64. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the GET /v4/user method.

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

{
  "host_url": "http://example.com"
}
Parameter Description
host_url URI of the site to add.
Parameter Description
host_url URI of the site to add.

Response format

Example

{
  "host_id": "http:example.com:80"
}
Parameter Required Type Description
host_id Yes host id (string) ID of the added site.
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
The number of sites in the user's site list exceeded the limit (the current limit is 1703).
{
 "error_code": "HOSTS_LIMIT_EXCEEDED",
 "limit": 1,
 "error_message": "explicit error message"
}

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.

{
  "error_code": "INVALID_USER_ID",
  "available_user_id": 1,
  "error_message": "Invalid user id. {user_id} should be used."
}
409 HOST_ALREADY_ADDED
A site with this name was already added to the user's site list.
{
  "error_code": "HOST_ALREADY_ADDED",
  "host_id": "http:ya.ru:80",
  "verified": false,
  "error_message": "some string"
}
Code Reason Description
201 CREATED The site was added to the user's list.
403 HOSTS_LIMIT_EXCEEDED
The number of sites in the user's site list exceeded the limit (the current limit is 1703).
{
 "error_code": "HOSTS_LIMIT_EXCEEDED",
 "limit": 1,
 "error_message": "explicit error message"
}

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.

{
  "error_code": "INVALID_USER_ID",
  "available_user_id": 1,
  "error_message": "Invalid user id. {user_id} should be used."
}
409 HOST_ALREADY_ADDED
A site with this name was already added to the user's site list.
{
  "error_code": "HOST_ALREADY_ADDED",
  "host_id": "http:ya.ru:80",
  "verified": false,
  "error_message": "some string"
}