---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.1
alternate:
  - https://yandex.com/dev/adfox/doc/en/rest-statistics/authorization.md
  - https://yandex.com/dev/adfox/doc/ru/rest-statistics/authorization.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/adfox/doc/en/llms.txt

# Authorization

{% note info %}

If a user account already has an active Adfox API token for managing objects, there's no need to obtain another one to access statistics. They can use a single OAuth token for all API sections.

{% endnote %}

## Getting a token {#token}

To get a token:

1. Go to the [Create app](https://oauth.yandex.com/client/new) page.

2. Fill in the fields:

    - **Your service's name**.

    - **Service icon** — optional.

    - **Platforms** — add one or more app platforms.

    - **Redirect URL** — specify `https://oauth.yandex.ru/verification_code`.

    - **Data access** — specify `adfox:api`.

    - **Email address** — optional.
    
3. Click **Create app** and copy its ClientID ![](../v.1/_images/copy-app.png).

4. Append the copied ClientID to a URL structured like this: [https://oauth.yandex.com/authorize?response_type=token&client_id=<app ID>](https://oauth.yandex.com/authorize?response_type=token&client_id=).

5. Click the link and copy the OAuth token from the page that opens.

## Authorization {#authorization}

Every API request requires authorization. You have to pass the OAuth token generated for your Yandex account in the `Authorization` HTTP header for each method.

```
Authorization: OAuth <token>
```

Example

```
curl -H 'Authorization: OAuth 05dd3dd84ff948fdae2bc4fb91f13e22bb1f289ceef0037' \
  https://adfox.yandex.ru/api/v2/reports/metadata
```

## Handling requests by user type

For admins and assistants, the `ownerId` parameter is optional.

If you're making requests from an advertiser or website owner account, be sure to include the `ownerId` parameter in every request. Use this parameter to specify the ID of the admin account for which the report is being generated.

#|
|| **Endpoint** | **User type** | **Required status of ownerId** ||
|| `/metadata` 
`/available-dates` | Admin / assistant | Not required. If you're passing this parameter, it must match your `ownerId`. ||
|| `/metadata` 
`/available-dates` | Advertiser / website owner | Required. ||
|| `/{taskId}` `/{taskId}/result` | Any | You can't use `ownerId` here: the system always looks for tasks belonging to the current user. ||
|#

In `GET` requests, pass `ownerId` as a query parameter:

```text id="f9a1ls"
?ownerId=12345
```

For `POST` requests, include `ownerId` in the request body as a positive integer.

