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

# Exemplos cURL

## Visão geral

Este guia fornece comandos cURL prontos para uso para autenticação e criação de campanhas via a API da ExoClick. Todos os exemplos usam formatos padrão JSON ou Form-Data, dependendo dos requisitos do endpoint.

## Autenticação (Login)

Você pode autenticar-se usando as credenciais da sua conta ou um Token de API permanente. Ambos retornam um Bearer Token temporário usado em todos os pedidos subsequentes.

{% tabs %}
{% tab title="Login com Nome de Utilizador e Palavra-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="Login com Token de API" %}
Use isto se gerou um token no seu Painel da 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 %}

## Fluxo de criação de campanha de banner 300x250

Siga estes passos pela ordem exata. Note a transição de JSON para Form-Data nas etapas finais.

{% stepper %}
{% step %}

### Criar URL da página de destino (Biblioteca)

Regista o 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:** Guarde o `"id"` (por ex., `6512406`).
{% endstep %}

{% step %}

### Carregar imagem (Biblioteca)

Regista o seu criativo. A imagem deve ter exatamente 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:** Guarde o `"id"` (por ex., `6884966`).
{% endstep %}

{% step %}

### Criar estrutura da campanha

Define a segmentação, o orçamento e o `img_banner` modelo.

**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:** Guarde o `"id"` (por ex., `8140060`).
{% endstep %}

{% step %}

### Adicionar a variação

Associa o URL (Passo 1) e a imagem (Passo 2) à campanha (Passo 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 os IDs devolvidos em cada etapa devem ser guardados e usados nos pedidos subsequentes. Lembre-se de substituir `YOUR_TOKEN`, os caminhos dos ficheiros e os IDs pelos seus valores reais.


---

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