Authentication in API v2
Written by
Updated at November 20, 2024
Search API API v2 interface requires you to submit your authentication credentials in each request. The authentication method depends on the type of account used to send your request:
Yandex or federated account
Service account
-
Get an IAM token to authenticate your Yandex account or federated account. Provide the token in the
Authorization
header of each request in the following format:Authorization: Bearer <IAM_token>
-
Assign the user the
search-api.webSearch.user
role for the folder to use for 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
Authorization
header in the following format:Authorization: Bearer <IAM_token>
-
Create an API key. Provide the API key in the
Authorization
header in the following format:Authorization: Api-Key <API_key>
-
- Assign the service account the
search-api.webSearch.user
role for the folder where it was created and which will be used for Search API requests. Make sure to include the folder ID in thefolderId
(folder_id
) field in the body of each request.