> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Messaging API

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/fusion-server/reference/api/messaging-api

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-server/reference/api/messaging-api

[old doc.lw link]: https://doc.lucidworks.com/fusion-server/4.2/306

The [Messaging Service](/docs/4/fusion-server/concepts/system/monitoring/messaging-services) provides implementations to support sending messages and alerts under a coherent REST API. Service instances can be added and removed via REST API. Messages can be scheduled or sent immediately.

<LwTemplate />

## Attributes

The Messaging API supports the generic concept of a message, and each implementation interprets attributes in context. For example, *"to:"* in the context of a Slack message references the intended channel, whereas *"to:"* in the context of an email(SMTP) references the intended email address of its recipient.

| Message Attribute      | Description                                                                                                         |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `id`                   | An application specific id for tracking the message. Must be unique.                                                |
| `type`                 | The type of message to send, one of the following: <br />● `log` <br />● `smtp` <br />● `slack` <br />● `pagerduty` |
| `to`                   | One or more destinations for the message, as a list                                                                 |
| `from`                 | Who/what the message is from                                                                                        |
| `subject`              | The subject of the message                                                                                          |
| `body`                 | The main body of the message                                                                                        |
| `schedule`             | Used to pass messages at a later time, or at a recurring basis.                                                     |
| `messageServiceParams` | Passes a map of any service-specific parameters, such as the user name and password                                 |

## Examples

*Display current messaging services*:

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:8764/api/messaging/service
```

**RESPONSE**

```json wrap  theme={"dark"}
[ {
"type": "logging-message-service-config",
"defaultLogLevel" : "info",
"template": "<to>:<from>:<subject>:<body>",
"serviceType": "log"
} ]
```

*Send a message using Slack*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X POST -H 'Content-Type: application/json' -d  '{"id": "myID", "type": "slack", "subject": "test", "body": "@recipient: this is a test", "to": ["recipient"], "from": "sender"}' https://FUSION_HOST:8764/api/messaging/send
```

**RESPONSE**

```json wrap  theme={"dark"}
[ {   "id": "myID",
    "type": "slack",
    "subject": "test",
    "body": "@recipient: this is a test",
        "to": "recipient",
    "from": "sender"
} ]
```

**Get all scheduled messages**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:8764/api/messaging/scheduled
```

**RESPONSE**

```json wrap  theme={"dark"}
[
 {
   "id": "myID",
   "type": "slack",
   "subject": "Updates",
   "body": "@recipient:here is the latest version",
   "to": ["updatechannel"],
   "from": "sender",
   "schedule":{"id":"slack", "creatorType":"human", "creatorId":"admin", "repeatUnit":"DAY", "interval":1, "startTime":"2015-05-21T06:44:00.000Z", "active":true}
 }
```

*Show the current status of messaging services:*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:8764/api/messaging/status
```

**RESPONSE**

```json wrap  theme={"dark"}
[ {
  "status" : "ok",
  "node" : "http://xxx.xx.xx.x:8764/api/messaging",
  "messages" : [ ]
} ]
```
