> 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/ja/exoclick-paburikku-api/api-manual-curl-examples.md).

# cURL の例

## 概要

このガイドでは、ExoClick API を使用して認証し、キャンペーンを作成するための、そのまま使える cURL コマンドを提供します。各例では、エンドポイントの要件に応じて標準の JSON または Form-Data 形式を使用しています。

## 認証（ログイン）

アカウントの認証情報または永続的な API トークンを使用して認証できます。どちらも、その後のすべてのリクエストで使用される一時的な Bearer トークンを返します。

{% 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 トークンでログイン" %}
ExoClick ダッシュボード（[プロフィール](https://docs.exoclick.com/docs/general/my-profile/) > API トークン）でトークンを生成した場合に使用します。

```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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/api/ja/exoclick-paburikku-api/api-manual-curl-examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
