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

Name Required Type Default value Description
user-id Yes int64 The user ID.

Example

{
  "host_url": "http://example.com"
}
Parameter Description
host_url URI 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"
}
Parameter Description
host_id ID 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"
    }
    Parameter Description
    error_code Error code.
    Limit The limit on the number of added sites.
    error_message Error 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."
    }
    Parameter Description
    error_code Error code.
    available_user_id ID of the user who allowed access.
    error_message Error 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"
}
Parameter Description
error_code Error code.
host_id The ID of the site that has already been added.
verified Whether the added site has been verified.
error_message Error message.