> 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/it/api-pubblica-di-exoclick/api-manual-curl-examples.md).

# Esempi cURL

## Panoramica

Questa guida fornisce comandi cURL pronti all'uso per l'autenticazione e la creazione di campagne tramite l'API di ExoClick. Tutti gli esempi utilizzano formati JSON standard o Form-Data a seconda dei requisiti dell'endpoint.

## Autenticazione (Login)

Puoi autenticarti usando le credenziali del tuo account o un API Token permanente. Entrambi restituiscono un Bearer Token temporaneo utilizzato per tutte le richieste successive.

{% tabs %}
{% tab title="Login con nome utente e password" %}

```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="Login con API Token" %}
Usa questo se hai generato un token nel tuo ExoClick Dashboard ([Profilo](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 %}

## Flusso di creazione di una campagna banner 300x250

Segui questi passaggi nell'ordine esatto. Nota la transizione da JSON a Form-Data negli ultimi passaggi.

{% stepper %}
{% step %}

### Crea URL della landing page (Libreria)

Registra l'URL di destinazione.

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

**Risultato:** Salva l' `"id"` restituito (ad es., `6512406`).
{% endstep %}

{% step %}

### Carica immagine (Libreria)

Registra il tuo asset creativo. L'immagine deve essere esattamente 300x250.

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

**Risultato:** Salva l' `"id"` restituito (ad es., `6884966`).
{% endstep %}

{% step %}

### Crea il contenitore della campagna

Imposta targeting, budget e il `img_banner` modello.

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

**Risultato:** Salva l' `"id"` restituito (ad es., `8140060`).
{% endstep %}

{% step %}

### Aggiungi la variazione

Collega l'URL (Passaggio 1) e l'immagine (Passaggio 2) alla campagna (Passaggio 3).

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

Tutti gli ID restituiti in ogni passaggio devono essere salvati e usati nelle richieste successive. Ricorda di sostituire `YOUR_TOKEN`, i percorsi dei file e gli ID con i tuoi valori reali.


---

# 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/it/api-pubblica-di-exoclick/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.
