# API/Manual Execution Event Source

Trigger Flux app actions through an API or manual execution.

When you select **API/Manual Execution** as the [Event Source](https://docs.soracom.io/en/services/flux/channels-and-event-sources#create-a-channel-and-select-an-event-source) for the Flux App, the App is triggered when the API endpoint receives a request.

## Sending Data to a Channel

With the API/Manual Execution event source, you can send data over the Soracom API to your Flux App channel. For more information on sending a request to the Soracom API, refer to the [Soracom API Usage Guide](https://docs.soracom.io/en/developers/soracom-api).

### Locating the Channel API Endpoint URL

The API endpoint can be found under the **Event Source** tab of the channel.

> [!WARNING]
>
> ![Viewing the API endpoint URL of a channel](https://docs.soracom.io/_astro/flux-channel-api01.BBlHPVwk_1ix6hg.webp)

Here is the format of the API endpoint URL:

```
https://g.api.soracom.io/v1/flux/apps/{app_id}/channels/{channel_id}/messages
```

This includes the following variables:

| Variable | Description |
| - | - |
| `app_id` | Replace with the ID of the Flux App. |
| `channel_id` | Replace with the ID of the channel. |

> [!NOTE]
>
> `g.api.soracom.io` is the domain for Global coverage. Use `api.soracom.io` for Japan coverage. For more details, refer to the [Soracom API Usage Guide](https://docs.soracom.io/en/developers/soracom-api).

### Sending an Example Request

Below you can find an example of sending `{"temperature": 25}` to the API endpoint of a channel:

```bash
curl -X POST "https://g.api.soracom.io/v1/flux/apps/01ABCDEFGHIJKLMNOPQRSTU/channels/01VWXYZABCDEFGHIJKLM/messages" \
    -H "X-Soracom-API-Key: $X_Soracom_API_KEY" \
    -H "X-Soracom-Token: $X_Soracom_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"temperature": 25}'
```

> [!WARNING]
>
> To reference the event source's **Message** in an action, you can use `${event.payload.<MESSAGE_ATTRIBUTE>}` or `event.payload.<MESSAGE_ATTRIBUTE> == 1`.

> [!NOTE]
>
> Limitations of the API/Manual Execution Event Source:
>
> The maximum payload that can be sent on a channel is 32,768 bytes;. Payloads exceeding this limit cannot be sent.

## Data Format

The data sent to a channel configured with the API/Manual Execution event source consists of **Message** and **Context**.

> [!WARNING]
>
> You can check the data received by the event to the Flux App in the **History** tab of Soracom Flux Studio. For more details, refer to [View Logs](https://docs.soracom.io/en/services/flux/logs).

### Message

For this event source, the message is the data sent to the API endpoint. Here's an example:

```json
{
  "temperature": 25
}
```

### Context

This contains the information about the event source.

```json
{
  "eventType": "api"
}
```

The attributes are as follows:

| Attribute | Description |
| - | - |
| `eventType` | The type of event. When the data sent via the API triggers the Flux App, the value is `api`. |
