> 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/es/api-publica-de-exoclick/api-manual-curl-examples.md).

# Ejemplos de cURL

## Resumen

Esta guía proporciona comandos cURL listos para usar para autenticarse y crear campañas a través de la API de ExoClick. Todos los ejemplos usan formatos estándar JSON o Form-Data, según los requisitos del endpoint.

## Autenticación (Inicio de sesión)

Puedes autenticarte usando las credenciales de tu cuenta o un Token de API permanente. Ambos devuelven un Bearer Token temporal que se usa para todas las solicitudes posteriores.

{% tabs %}
{% tab title="Iniciar sesión con nombre de usuario y contraseña" %}

```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="Iniciar sesión con Token de API" %}
Usa esto si generaste un token en tu Panel de ExoClick ([Perfil](https://docs.exoclick.com/docs/general/my-profile/) > Tokens de API).

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

{% endtab %}
{% endtabs %}

## Flujo de creación de campaña Banner 300x250

Sigue estos pasos en el orden exacto. Ten en cuenta la transición de JSON a Form-Data en los pasos finales.

{% stepper %}
{% step %}

### Crear URL de página de destino (Biblioteca)

Registra tu URL de destino.

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

**Resultado:** Guarda el `"id"` devuelto (por ejemplo, `6512406`).
{% endstep %}

{% step %}

### Subir imagen (Biblioteca)

Registra tu recurso creativo. La imagen debe ser exactamente 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"
```

**Resultado:** Guarda el `"id"` devuelto (por ejemplo, `6884966`).
{% endstep %}

{% step %}

### Crear estructura de campaña

Define la segmentación, el presupuesto y la `img_banner` plantilla.

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

**Resultado:** Guarda el `"id"` devuelto (por ejemplo, `8140060`).
{% endstep %}

{% step %}

### Añadir la variación

Vincula la URL (Paso 1) y la imagen (Paso 2) a la campaña (Paso 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 %}

Todos los IDs devueltos en cada paso deben guardarse y utilizarse en las solicitudes posteriores. Recuerda reemplazar `YOUR_TOKEN` , las rutas de archivos y los IDs por tus valores reales.


---

# 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/es/api-publica-de-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.
