API authentication
Yandex Search API requires you to submit your authentication credentials in each request. The authentication method depends on the type of account you use to send requests:
Yandex account or federated account
Service account
-
Get an IAM token to authenticate your Yandex account or federated account. Provide the token in the
Authorizationheader of each request in the following format:Authorization: Bearer <IAM_token> -
Assign the user the
search-api.webSearch.userrole for the folder to use for Yandex Search API requests. Make sure to include the folder ID in thefolderId(folder_id) field in the body of each request.
- Choose one of the authentication methods:
-
Get an IAM token. Provide the IAM token in the
Authorizationheader in the following format:Authorization: Bearer <IAM_token> -
Create an API key. Include the API key in the
Authorizationheader, formatted as follows:Authorization: Api-Key <API_key>
-
- Assign to the service account the
search-api.webSearch.userrole for the folder in which it was created and which will be used for Yandex Search API requests. You may not provide the folder ID because Yandex Search API will run in the service account folder.