Get an IAM token for your account

To perform operations in Yandex.Cloud via the API, you need an IAM token.


The IAM token is valid for 12 hours. After that period expires, get a new IAM token.

Get an IAM token:

$ yc iam create-token


If you are the owner of the cloud and you use your own account to access the API, remember that the owner of the cloud can perform any operations with cloud resources.

We recommend using a service account to work with the API. This way, you can assign only the roles that are necessary.

  1. Log in to your Yandex or Yandex.Connect account.

  2. Get an OAuth token from Yandex.OAuth. To do this, follow the link, click Allow and copy the OAuth token that is issued.

  3. Exchange the OAuth token for an IAM token:

    • Using cURL in Bash or CMD:

      curl -d "{\"yandexPassportOauthToken\":\"<OAuth-token>\"}" ""
    • Using the built-in PowerShell function:

      (Invoke-RestMethod -Uri '' -Method 'POST' -Body (@{yandexPassportOauthToken="<OAuth-Token>";}|ConvertTo-Json) -ContentType "application/json").iamToken

Specify the received IAM token when accessing Yandex.Cloud resources via the API. Pass the IAM token in the Authorization header in the following format:

Authorization: Bearer <IAM-TOKEN>


Save the IAM token to a variable and use it in other requests from the command line:

$ export IAM_TOKEN=`yc iam create-token`
$ curl -H "Authorization: Bearer ${IAM_TOKEN}" \
$IAM_TOKEN=yc iam create-token
curl.exe -H "Authorization: Bearer $IAM_TOKEN"