---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
  - property: og:type
    content: article
  - property: article:section
    content: API Reference
  - property: og:title
    content: API access
  - property: article:tag
    content: Technical instruction
alternate:
  - https://yandex.ru/support/wiki/en/api-ref/access.md
  - https://yandex.ru/support/wiki/ru/api-ref/access.md
  - href: en/api-ref/access.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/support/wiki/en/llms.txt


# API access

{% note tip "" %}

If the Wiki administrator has disabled API access, you won't be able to set up the integration.

{% endnote %}

When working with Yandex Wiki API, requests are made on behalf of a user. To perform actions through the API, the user on whose behalf the request is made must have the appropriate permissions in Wiki. For example, if the user does not have permission to edit a page, the corresponding API requests will be unavailable. For more information about user permissions, see [Roles](https://yandex.ru/support/wiki/roles).



To access the Yandex Wiki API, you can use one of these authorization methods:


* OAuth 2.0 protocol — can be used in both Yandex 360 for Business and Yandex Cloud Organization organizations. For more information, see [Getting access to the API using the OAuth protocol](#about_oauth).

* IAM token — can only be used in Yandex Cloud organizations. For more information, see [Getting access to the API with an IAM token](#iam-token).


{% note info "" %}

You cannot use a Yandex Cloud [service account](https://yandex.cloud/en/docs/iam/concepts/users/service-accounts) for authorization in the Yandex Wiki API. Send requests only from a user account.

{% endnote %}



## Headers {#headers}

In Yandex Wiki API requests, specify the following headers:

* `Host: api.wiki.yandex.net`

* Authorization header:

   - `Authorization: OAuth <OAuth token>` — when using the OAuth 2.0 protocol.

   - `Authorization: Bearer <IAM token>` — when using an IAM token.

* Organization ID:

   - `X-Org-Id` — for Yandex 360 for Business organizations.
   - `X-Cloud-Org-Id` — for Yandex Cloud Organization organizations.

   {% note tip "" %}

   To find your organization ID, open [Yandex Tracker](https://tracker.yandex.com/admin/orgs), go to **Administration** → [**Organizations**](https://tracker.yandex.com/admin/orgs), and copy the **ID** field value.

   {% endnote %}


> Example:
>
> ```
> Host: api.wiki.yandex.net
> Authorization: OAuth y0__xAbc******
> X-Org-Id: 1234******
> ```


## Getting access to the API using the OAuth protocol {#about_oauth}

{% note warning "" %}

If you are using a federated account, authorize using an [IAM token](#iam-token).

{% endnote %}


To get a token:



1. Click the link [https://oauth.yandex.com](https://oauth.yandex.com).

1. On the **Your apps** page, click ![](../_assets/svg/add-icon.svg)</svg> **Create**.


1. In the window that opens, select **For API access or debugging** and click **Create new token**.

1. Enter the app name and contact email.


1. Add permissions for accessing user data. To select a permission, start typing its name in the **Permission name** field:
   * **Write to Wiki (wiki:write)** — all data operations: creating, deleting, editing.
   * **Read from Wiki (wiki:read)** — only reading data.

1. Click **Create app**.


1. In your [Yandex OAuth](https://oauth.yandex.com) account, select the previously created application and copy its ID from the **ClientID** field.


1. Generate a link to request a token:

   ```
   https://oauth.yandex.com/authorize?response_type=token&client_id=<application_ID>
   ```
1. Log in to the account you will use to access the API, then follow the generated link. 


   A sequence of characters will appear on the page — that is your OAuth token. Copy and save it.


To check if you have access to the API, send any request. If access has not been granted, the request will return a `401 Unauthorized` response.

For example, you can request information about the `mypage` page using curl:


{% list tabs %}

- Unix

   ```bash
   curl -X GET 'https://api.wiki.yandex.net/v1/pages?slug=mypage' \
        -H 'Authorization: OAuth y0__xAbc******' \
        -H 'X-Org-Id: 1234******'
   ```

- Windows

   ```bash
   curl -X GET "https://api.wiki.yandex.net/v1/pages?slug=mypage" ^
        -H "Authorization: OAuth y0__xAbc******" ^
        -H "X-Org-Id: 1234******"
   ```

{% endlist %}


## Getting access to the API with an IAM token {#iam-token}

If you are using Wiki as part of a Yandex Cloud organization, you can authorize with the API using an IAM token.

An IAM token is a unique sequence of characters issued to a user after authentication. The user uses this token to authorize with the Yandex Wiki API and perform operations on resources. For more information about this authentication method, see the [documentation of the identity and access management service](https://yandex.cloud/en/docs/iam/concepts/authorization/iam-token).

* [How to get an IAM token for a Yandex account](https://yandex.cloud/en/docs/iam/operations/iam-token/create)

* [How to get an IAM token for a federated account](https://yandex.cloud/en/docs/iam/operations/iam-token/create-for-federation)

{% note info "" %}

The IAM token is valid for no more than 12 часов and is limited by the cookie lifetime for the [federation](https://yandex.cloud/en/docs/organization/concepts/add-federation). When the token expires, the `401 Unauthorized` error is returned.

{% endnote %}


<!-- source: en/_assets/style/image.md -->

<!-- endsource: en/_assets/style/image.md -->