# Introduction

This API module exposes an interface that allows to send SMSes, Emails and Push messages to Loyalty Club members, MPC users and to any arbitrary recipients.

# Services

The core of the Messaging API is scoped by Services that allow to distinguish [Messages](doc-354471) by specific MPC features or custom/external uses.

A `/:service/` URL segment is used for this. For example, listing messages is done via `GET /v1/messages/:service_name` and creating via `POST /v1/messages/:service_name`.

Each service requires the API client to have a dedicated permit - permits for services available for specific API integration must be configured by Placewise staff according to the scope and purpose of the integration.

The list of services available to the API client may be consulted [here](api-3927095). 

# Models overview

## Entity Relationship Diagram

<div style="text-align:center">
```mermaid
erDiagram
Message ||..|{ MessageChannel : ""
MessageChannel ||..|| MessageTemplate : ""
Message ||..o{ Sending : ""
Sending ||..o{ SendingRecipient : ""
SendingRecipient |o..o| Dispatch : ""
Sending ||..o{ Dispatch : ""
```
</div>

## Message

[Message](doc-354471) is a content to send. Defines channels that should be used for transport and how it should look and/or behave.

For example, depending on a use case, a Message may be:
  * SMS with content and sender
  * e-mail with subject, body and sender (from)
  * push notification with text and image
  * a set of SMS, email and push where the actual channel is based on recipient preferences

See: [Message](doc-354471) for more details.

## Sending
 
Message is always sent through a specific [Sending](doc-354473) - depending on its [service](doc-354677#Services) once or more.

Sending may be treated as an "occurrence" of the Message. It **happens** on specific time and targets the recipients that should receive it at that time.

[Message](doc-354471) may be created along with the first (and potentially only) Sending at once. It can be also pre-created without scheduling any Sending.

Nevertheless, subsequent Sendings may be scheduled for the Message at any time. Also, there are [Services](doc-354677#Services) that have Sendings automatically scheduled by the system.

See: [Sending](doc-354473) for more details.

## Template

[Template](doc-354486#template-model) model manifests itself in two forms:

* as a content of the specific Message - see: [Message](doc-354471)
* as a Standalone Template, record that holds data reusable in Messages - see: [Templates (Standalone)](doc-354680)
