> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/api/ru/publichnyi-api-exoclick/api-manual-curl-examples.md).

# Примеры cURL

## Обзор

Это руководство содержит готовые к использованию команды cURL для аутентификации и создания кампаний через API ExoClick. Все примеры используют стандартные форматы JSON или Form-Data в зависимости от требований конечной точки.

## Аутентификация (вход)

Вы можете аутентифицироваться, используя учетные данные своей учетной записи или постоянный API Token. Оба варианта возвращают временный Bearer Token, используемый для всех последующих запросов.

{% tabs %}
{% tab title="Вход с именем пользователя и паролем" %}

```bash
curl -X POST "https://api.exoclick.com/v2/login" \
     -H "Content-Type: application/json" \
     -d '{
       "username": "YOUR_USERNAME",
       "password": "YOUR_PASSWORD"
     }'
```

{% endtab %}

{% tab title="Вход с API Token" %}
Используйте это, если вы сгенерировали токен в своей панели ExoClick ([Профиль](https://docs.exoclick.com/docs/general/my-profile/) > API Tokens).

```bash
curl -X POST "https://api.exoclick.com/v2/login" \
     -H "Content-Type: application/json" \
     -d '{
       "api_token": "YOUR_API_TOKEN"
     }'
```

{% endtab %}
{% endtabs %}

## Процесс создания кампании баннера 300x250

Выполните эти шаги строго в указанном порядке. Обратите внимание на переход с JSON на Form-Data на заключительных шагах.

{% stepper %}
{% step %}

### Создать URL целевой страницы (Библиотека)

Регистрирует ваш URL назначения.

**Формат:** JSON

```bash
curl -X POST "https://api.exoclick.com/v2/library/url" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "url": "https://your-landing-page.com"
     }'
```

**Результат:** Сохраните возвращенный `"id"` (например, `6512406`).
{% endstep %}

{% step %}

### Загрузить изображение (Библиотека)

Регистрирует ваш креативный ресурс. Изображение должно быть точно 300x250.

**Формат:** Form-Data

```bash
curl -X POST "https://api.exoclick.com/v2/library/file" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -F "file=@/path/to/your/image_300x250.jpg" \
     -F "type=image"
```

**Результат:** Сохраните возвращенный `"id"` (например, `6884966`).
{% endstep %}

{% step %}

### Создать каркас кампании

Задает таргетинг, бюджет и `img_banner` шаблон.

**Формат:** JSON

```bash
curl -X POST "https://api.exoclick.com/v2/campaigns" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
  "name": "Banner 300x250",
  "status": 0,
  "advertiser_ad_type": 0,
  "media_storage_template": "img_banner",
  "size": "300x250",
  "categories": { "type": "targeted", "elements": [97, 98, 99] },
  "countries": {
    "type": "targeted",
    "elements": [{ "country": "USA", "regions": [0] }]
  },
  "pricing": { "model": 4, "price": 300 },
  "start_date": "2026-03-02",
  "daily_limit_type": 1,
  "max_daily_budget": 2000,
  "budget_delivery_mode": 1,
  "run_on_responsive_zones": 1
}'
```

**Результат:** Сохраните возвращенный `"id"` (например, `8140060`).
{% endstep %}

{% step %}

### Добавить вариацию

Связывает URL (Шаг 1) и изображение (Шаг 2) с кампанией (Шаг 3).

**Формат:** Form-Data

```bash
curl -X POST "https://api.exoclick.com/v2/campaigns/8140060/variation" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -F "id_library_url=6512406" \
     -F "id_library_file=6884966" \
     -F "active=1"
```

{% endstep %}
{% endstepper %}

Все ID, возвращенные на каждом шаге, должны быть сохранены и использованы в последующих запросах. Не забудьте заменить `YOUR_TOKEN`, пути к файлам и ID на ваши фактические значения.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.exoclick.com/api/ru/publichnyi-api-exoclick/api-manual-curl-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
