# Sender API

Start newsletter sendings from your own system and register webhooks for their events. Uses its own API key.

Sender API uses a separate api key. If you don’t have one, head over to our support section.

- Base URL: `https://sender.dialogapi.no`
- OpenAPI spec: https://apidocs.make.as/api-docs/public/sender

## Webhooks

### List all webhooks

`GET /public/v1/webhooks`

Webhooks get delivered as JSON, with current fields: ua_browser, ua_version, ua_platform, ua_device, ip, sending_id, external_id, subscriber_id, client_id, link_id

Responses:

- `200` Success

Request:

```bash
curl --request GET \
  --user 'user_id:api_key' \
  --header 'content-type: application/json' \
  --url 'https://sender.dialogapi.no/public/v1/webhooks'
```

Example response (200):

```json
[
  {
    "id": 1,
    "url": "url",
    "event": "event",
    "created_at": "created_at"
  }
]
```

### Create new webhook

`POST /public/v1/webhooks`

Webhooks get delivered as JSON, with current fields: ua_browser, ua_version, ua_platform, ua_device, ip, sending_id, external_id, subscriber_id, client_id, link_id

Parameters:

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | body | string | yes |  |
| `event` | body | string | yes |  |

Responses:

- `200` Success
- `422` Error

Request:

```bash
curl --request POST \
  --user 'user_id:api_key' \
  --header 'content-type: application/json' \
  --data '{ "url": "url", "event": "delivered" }' \
  --url 'https://sender.dialogapi.no/public/v1/webhooks'
```

Example response (200):

```json
{
  "id": 1,
  "url": "url",
  "event": "event",
  "created_at": "created_at"
}
```

### Delete webhook

`DELETE /public/v1/webhooks/{id}`

Parameters:

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes | Webhook ID |

Responses:

- `200` Success
- `404` Webhook not found

Request:

```bash
curl --request DELETE \
  --user 'user_id:api_key' \
  --header 'content-type: application/json' \
  --url 'https://sender.dialogapi.no/public/v1/webhooks/{id}'
```

## Sendings

### Create new sending

`POST /public/v1/sendings`

Use either recipient_pickup_url or list_ids or recipients(max 3000 recipients)
<a href="https://sender.dialogapi.no/sample.json" target=_blank>View sample file(max 1MB)</a>

Parameters:

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `recipient_pickup_url` | body | string | yes |  |
| `recipients` | body | object[] | yes |  |
| `recipients[].id` | body | string |  |  |
| `recipients[].email` | body | string |  |  |
| `recipients[].custom_fields` | body | object |  |  |
| `list_ids` | body | integer[] | yes |  |
| `tags` | body | string[] |  |  |
| `external_id` | body | string |  |  |
| `client_id` | body | string |  |  |
| `subject` | body | string | yes |  |
| `from_name` | body | string | yes |  |
| `from_email` | body | string | yes |  |
| `replyto_email` | body | string | yes |  |
| `mailbody_text` | body | string | yes |  |
| `mailbody` | body | string | yes |  |
| `tracking_mode` | body | string |  |  |
| `anonymize_after` | body | integer |  |  |

Responses:

- `200` Success, returns sending_id
- `422` Error

Request:

```bash
curl --request POST \
  --user 'user_id:api_key' \
  --header 'content-type: application/json' \
  --data '{ "recipient_pickup_url": "recipient_pickup_url", "recipients": [ { "id": "id", "email": "user@example.com", "custom_fields": {} } ], "list_ids": [ 1 ], "tags": [ "tags" ], "external_id": "external_id", "client_id": "client_id", "subject": "subject", "from_name": "from_name", "from_email": "user@example.com", "replyto_email": "user@example.com", "mailbody_text": "mailbody_text", "mailbody": "mailbody", "tracking_mode": "standard", "anonymize_after": 1 }' \
  --url 'https://sender.dialogapi.no/public/v1/sendings'
```

Example response (200):

```json
1
```

### Get sending stats

`GET /public/v1/sendings/{id}`

Parameters:

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes | Sending ID |

Responses:

- `200` Success
- `404` Sending not found

Request:

```bash
curl --request GET \
  --user 'user_id:api_key' \
  --header 'content-type: application/json' \
  --url 'https://sender.dialogapi.no/public/v1/sendings/{id}'
```

Example response (200):

```json
{
  "id": 1,
  "unique_clicks": 1,
  "clicks": 1,
  "opens": 1,
  "bounce": 1,
  "unsubscribes": 1,
  "sent": 1
}
```
