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

# Send Event

> This API allows you to send messages

### Parameters

<Param path="app_id" type="string" required>
  The `id` of the app
</Param>

### Body

<Param body="event" type="string" required>
  The name of the event
</Param>

<Param body="data" type="object">
  Example: `{ "param1" : "value1", "param2" : "value2", "param3" : "object or array" }`
</Param>

<Param body="user" type="object">
  <Expandable>
    <Param body="user_id" type="string">
      User's id to send the notifications to. This is your own user identifier which
      you have used to [create user on Raven](/api-reference/create-user)
    </Param>

    <Param body="email" type="string">
      User's email
    </Param>

    <Param body="mobile" type="string">
      Mobile with country code prefix (e.g +91)
    </Param>

    <Param body="whatsapp_mobile" type="string">
      Mobile with country code prefix (e.g +91)
    </Param>

    <Param body="onesignal_external_id" type="string">
      [OneSignal External User
      Ids](https://documentation.onesignal.com/docs/external-user-ids)
    </Param>

    <Param body="fcm_tokens" type="string[]">
      List of fcm tokens.

      eg. `["<fcmtoken1", "<fcmtoken2>"]`
    </Param>
  </Expandable>
</Param>

### Additional Body Parameters

<Param body="override" type="object">
  Overriding messages / integration configurations

  <Expandable>
    <Param body="email" type="object">
      <Expandable>
        <Param body="from" type="object">
          <Expandable>
            <Param body="name" type="string">
              Sender's name
            </Param>

            <Param body="address" type="string">
              Sender's email address
            </Param>
          </Expandable>
        </Param>

        <Param body="cc" type="object[]">
          <Expandable>
            <Param body="name" type="string">
              Sender's name
            </Param>

            <Param body="address" type="string">
              Sender's email address
            </Param>
          </Expandable>
        </Param>

        <Param body="bcc" type="object[]">
          <Expandable>
            <Param body="name" type="string">
              Sender's name
            </Param>

            <Param body="address" type="string">
              Sender's email address
            </Param>
          </Expandable>
        </Param>

        <Param body="attachments" type="object[]">
          <Expandable>
            <Param body="file_name" type="string">
              Attachment file name
            </Param>

            <Param body="content" type="string">
              base64 encoded value of the attachment
            </Param>

            <Param body="url" type="string">
              Public URL of the file
            </Param>
          </Expandable>
        </Param>

        <Param body="message" type="object">
          <Expandable>
            <Param body="text" type="string">
              Email Text Body
            </Param>

            <Param body="html_body" type="string">
              Email HTML Body
            </Param>

            <Param body="subject" type="string">
              Email Subject
            </Param>
          </Expandable>
        </Param>
      </Expandable>
    </Param>

    <Param body="sms" type="object">
      <Expandable>
        <Param body="message" type="object">
          Message

          <Param body="sender" type="string">
            Sender
          </Param>

          <Param body="text" type="string">
            SMS text
          </Param>
        </Param>
      </Expandable>
    </Param>

    <Param body="whatsapp" type="object">
      <Expandable>
        <Param body="message" type="object">
          Message

          <Param body="text" type="string">
            Whatsapp text
          </Param>
        </Param>
      </Expandable>
    </Param>

    <Param body="slack" type="object">
      <Expandable>
        <Param body="message" type="object">
          Message

          <Param body="text" type="string">
            Sender
          </Param>

          <Param body="blocks" type="object">
            Slack blocks object
          </Param>
        </Param>
      </Expandable>
    </Param>
  </Expandable>
</Param>

<RequestExample>
  ```json curl theme={null}
  curl 'https://api.ravenapp.dev/v1/apps/{{APP_ID}}/events/send' \
  -H 'Authorization: AuthKey {{API_KEY}}' \
  -H 'Content-Type: application/json' \
  -d '{
      "event": "sample_event_1",
      "user": {
          "mobile": "+919876543210",
          "email": "x@ravenapp.dev",
          "whatsapp_mobile": "+919876543210", // if empty, `mobile` is considered for whatsapp
      },
      "data": {
          "name": "John Doe",
          "date": "01 December 2020"
      }
  }'
  ```

  ```java java  theme={null}
  RavenApiClient client = new RavenApiClient(Authorization.of("AuthKey <API_KEY>"));
  try {
      var response = client.send(Send.Request.builder()
                  .appId("<APP_ID>")
                  .body(SendEventRequest.builder()
                      .event("payment_alert")
                      .data(Map.of("name", "Adam"))
                      .user(User.builder().mobile("+1234567890").build())
                      .build())
                  .build());
      
      System.out.println(response.getId());
  } catch (SendException e) {
     System.out.println("Failed to send request" + e.getMessage());
  }
  ```

  ```javascript node theme={null}
  const client = new RavenApi.Client({
    authorization: `AuthKey ${API_KEY}`,
  });

  const sendEventResponse = await raven.send({
    appId: "<APP_ID>",
    _body: {
      event: "sample_event_1",
      user: {
        mobile: "+919876543210",
        email: "x@ravenapp.dev",
        whatsapp_mobile: "+919876543210"
      },
      data: {
        name: "John Doe",
        date: "01 December 2020",
      }
    },
  });

  if (sendEventResponse.ok) {
    console.log(`The id of the event is ${sendEventResponse.body.id}`);
  } else {
    console.error("Failed to send event", sendEventResponse.error);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Response theme={null}
  {
    "request_id": "1d1ed73c-96e6-4aa3-abc2-2e9a926f773a",
    "success": true
  }
  ```

  ```json 404 Response theme={null}
  {
    "success": false,
    "error": "event not found"
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.