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

# Exemples cURL

## Vue d'ensemble

Ce guide fournit des commandes cURL prêtes à l'emploi pour s'authentifier et créer des campagnes via l'API ExoClick. Tous les exemples utilisent les formats JSON standard ou Form-Data selon les exigences du point de terminaison.

## Authentification (Connexion)

Vous pouvez vous authentifier à l'aide des identifiants de votre compte ou d'un jeton API permanent. Les deux renvoient un jeton Bearer temporaire utilisé pour toutes les requêtes suivantes.

{% tabs %}
{% tab title="Connexion avec nom d'utilisateur et mot de passe" %}

```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="Connexion avec un jeton API" %}
Utilisez ceci si vous avez généré un jeton dans votre tableau de bord ExoClick ([Profil](https://docs.exoclick.com/docs/general/my-profile/) > Jetons API).

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

{% endtab %}
{% endtabs %}

## Flux de création de campagne bannière 300x250

Suivez ces étapes dans l'ordre exact. Notez la transition de JSON à Form-Data dans les dernières étapes.

{% stepper %}
{% step %}

### Créer l'URL de la page de destination (Bibliothèque)

Enregistre votre URL de destination.

**Format :** 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"
     }'
```

**Résultat :** Enregistrez le `"id"` (par ex., `6512406`).
{% endstep %}

{% step %}

### Téléverser l'image (Bibliothèque)

Enregistre votre ressource créative. L'image doit être exactement 300x250.

**Format :** 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"
```

**Résultat :** Enregistrez le `"id"` (par ex., `6884966`).
{% endstep %}

{% step %}

### Créer la structure de campagne

Définit le ciblage, le budget et le `img_banner` modèle.

**Format :** 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
}'
```

**Résultat :** Enregistrez le `"id"` (par ex., `8140060`).
{% endstep %}

{% step %}

### Ajouter la variation

Lie l'URL (Étape 1) et l'image (Étape 2) à la campagne (Étape 3).

**Format :** 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 %}

Tous les identifiants renvoyés à chaque étape doivent être enregistrés et utilisés dans les requêtes suivantes. N'oubliez pas de remplacer `YOUR_TOKEN`, les chemins de fichiers et les identifiants par vos valeurs réelles.


---

# 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/fr/api-publique-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.
