Adding a site

Description

Adds a site to the list of the user's sites.

Request format

Send a POST request to the resource address for the list of the user's sites. In the request body, specify the name of the new site and the desired data path in the Content-type header (application/json or application/xml):

POST https://api.webmaster.yandex.net/v3/user/{user-id}/hosts/
Content-type: application/xml

Path parameters

NameRequiredTypeDefault valueDescription
user-idYesint64The user ID.

Example

{
  "host_url": "http://example.com"
}
ParameterDescription
host_urlURI of the site to add.

Response format

If the site is added successfully, the server returns 201 Created and the URI of the site resource.

Example

{
  "host_id": "http:example.com:80"
}
ParameterDescription
host_idID of the added site.

Errors

403 Forbidden

  • HOSTS_LIMIT_EXCEEDED error

    Exceeded the limit on the number of sites in the list (the current limit is 1703).

    {
     "error_code": "HOSTS_LIMIT_EXCEEDED",
     "limit": 1,
     "error_message": "explicit error message"
    }
    ParameterDescription
    error_codeError code.
    LimitThe limit on the number of added sites.
    error_messageError message.
  • INVALID_USER_ID error

    The user ID for the token doesn't match the one specified in the request. In the examples below, {user_id} is the correct uid for the owner of the OAuth token.

    {
      "error_code": "INVALID_USER_ID",
      "available_user_id": 1,
      "error_message": "Invalid user id. {user_id} should be used."
    }
    ParameterDescription
    error_codeError code.
    available_user_idID of the user who allowed access.
    error_messageError message.

409 Conflict

A site with the same name has already been added to the list of the user's sites.

{
  "error_code": "HOST_ALREADY_ADDED",
  "host_id": "http:ya.ru:80",
  "verified": false,
  "error_message": "explicit error message"
}
ParameterDescription
error_codeError code.
host_idThe ID of the site that has already been added.
verifiedWhether the added site has been verified.
error_messageError message.