> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.laposta.org/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.laposta.org/_mcp/server.

# Sending a campaign via the API

> Create a campaign, fill it with your own html, send a testmail and schedule the delivery.

If your layout comes from another system, such as a CMS that already generates the newsletter, you can create, populate and send the campaign entirely via the API. There is no need to open the editor.

#### Create the campaign

The sender address must be approved within Laposta, otherwise you will receive an error message. Under `list_ids`, specify the lists and any segments that should receive the campaign.

**`curl`**

```bash title="curl"
curl https://api.laposta.nl/v2/campaign \
  -u YOUR_API_KEY: \
  -d type=regular \
  -d 'name=March newsletter' \
  -d 'subject=The March newsletter' \
  -d 'from[name]=Example Ltd' \
  -d from[email]=newsletter@example.net \
  -d reply_to=info@example.net \
  -d list_ids[]=BaImMu3JZA
```

**`PHP`**

```php title="PHP"
$laposta = new Laposta('YOUR_API_KEY');
$campaign = $laposta->campaignApi()->create([
    'type' => 'regular',
    'name' => 'March newsletter',
    'subject' => 'The March newsletter',
    'from' => ['name' => 'Example Ltd', 'email' => 'newsletter@example.net'],
    'reply_to' => 'info@example.net',
    'list_ids' => ['BaImMu3JZA'],
]);
```

#### Populate the campaign with HTML

Include the HTML in the request, or provide a URL where Laposta can fetch the code. Choose one of the two. If you provide both, Laposta will use the HTML included in the request.

**`curl`**

```bash title="curl"
curl https://api.laposta.nl/v2/campaign/njhgaf61ye/content \
  -u YOUR_API_KEY: \
  -d import_url=https://example.net/newsletter.html \
  -d inline_css=true
```

**`PHP`**

```php title="PHP"
$laposta->campaignApi()->updateContent('njhgaf61ye', [
    'import_url' => 'https://example.net/newsletter.html',
    'inline_css' => true,
]);
```

The response includes a `report` with details: a missing unsubscribe link, JavaScript that has been stripped out, or an image that could not be loaded. You can still send the campaign with these comments, but be sure to check them first.

#### Send a test email

This is only possible for a campaign that already has content and has not yet been sent.

**`curl`**

```bash title="curl"
curl https://api.laposta.nl/v2/campaign/njhgaf61ye/action/testmail \
  -u YOUR_API_KEY: \
  -d email=you@example.net
```

**`PHP`**

```php title="PHP"
$laposta->campaignApi()->sendTestMail('njhgaf61ye', 'you@example.net');
```

#### Send or schedule the campaign

Sending takes place in the background: you receive an immediate response while the delivery is still in progress. To schedule a campaign, specify a time in the future.

**`curl`**

```bash title="curl"
curl https://api.laposta.nl/v2/campaign/njhgaf61ye/action/schedule \
  -u YOUR_API_KEY: \
  -d 'delivery_requested=2026-05-18 09:00:00'
```

**`PHP`**

```php title="PHP"
$laposta->campaignApi()->schedule('njhgaf61ye', '2026-05-18 09:00:00');
```

> **Warning**
>
> Sending cannot be undone. A second call is not blocked and will trigger the delivery again. Make sure your own code prevents this: record that you have already sent a campaign, and do not allow the same action to be triggered twice by a repeated call or a double click. You can cancel a scheduled campaign by [deleting](/campagnes/campagne-verwijderen) it.

> **Note**
>
> A campaign created in the drag & drop editor cannot be populated or read via the API. Doing so will return the message "Wrong campaign type". Managing content via the API only works for campaigns that you have created or imported yourself.

## Retrieving results after sending

You can request the results immediately after sending. The figures will continue to rise as more recipients open the email and click on links.

| What                                        | Where                                                                   |
| ------------------------------------------- | ----------------------------------------------------------------------- |
| Numbers and ratios per campaign             | [Results of a campaign](/resultaten/campagneresultaten-opvragen)        |
| All campaigns in the account                | [Retrieving all results](/resultaten/alle-resultaten-opvragen)          |
| Individual events, such as opens and clicks | [Retrieving campaign history](/campagnes/campagnegeschiedenis-opvragen) |

## Related articles

#### [Creating a campaign](/campagnes/campagne-aanmaken)

All parameters of the campaign endpoint.

#### [Results of a campaign](/resultaten/campagneresultaten-opvragen)

What was delivered, opened and clicked.

#### [What are common mistakes with the API?](/veelgemaakte-fouten-met-de-api)

Pitfalls when integrating with the Laposta API, including the error message you get and…