[Yandex Cloud documentation](../../../../index.md) > [Yandex Serverless Integrations](../../../index.md) > [Step-by-step guides](../../index.md) > EventRouter > Sending events to a bus > Sending events directly

# Sending events directly to a bus

{% note info %}

You can send events to a bus directly only if there is at least one [rule](../../../concepts/eventrouter/rule.md) attached to it.

{% endnote %}

To [send](../../../concepts/eventrouter/sending-events.md) events directly to a [bus](../../../concepts/eventrouter/bus.md):

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the [folder](../../../../resource-manager/concepts/resources-hierarchy.md#folder) with the bus you need.
  1. Navigate to **Serverless Integrations**.
  1. In the left-hand panel, select ![object-align-center-vertical](../../../../_assets/console-icons/object-align-center-vertical.svg) **EventRouter**.
  1. Select the [bus](../../../concepts/eventrouter/bus.md) you need.
  1. In the top panel, click ![comment-plus](../../../../_assets/console-icons/comment-plus.svg) **Send event**.
  1. In the window that opens, enter the event you need to send to the bus in [JSON](https://en.wikipedia.org/wiki/JSON) format, e.g., `{"name": "value"}`.
  1. Click **Send**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. View the description of the [CLI command](../../../../cli/cli-ref/serverless/cli-ref/eventrouter/put-event.md) to send events directly to a bus:

      ```bash
      yc serverless eventrouter put-event --help
      ```
  1. Get a list of buses:
     
     ```bash
     yc serverless eventrouter bus list
     ```
     
     Result:
     
     ```text
     +----------------------+------------------+----------------------+--------+---------------------+
     |          ID          |       NAME       |      FOLDER ID       | STATUS | DELETION PROTECTION |
     +----------------------+------------------+----------------------+--------+---------------------+
     | f6676a9ti657******** | my-new-bus-17    | b1g681qpemb4******** | ACTIVE | false               |
     | f66aevm4ithv******** | my-favourite-bus | b1g681qpemb4******** | ACTIVE | true                |
     | f66m2q222n92******** | my-bus-42        | b1g681qpemb4******** | ACTIVE | false               |
     +----------------------+------------------+----------------------+--------+---------------------+
     ```
  1. Send the event to the bus you selected:

      ```bash
      yc serverless eventrouter put-event \
        --name <bus_name> \
        --event '<event>' \
        --file <file_path>
      ```

      Where:
      * `--name`: Name of the bus you are sending the event to.
      
          Instead of the bus name, you can provide its ID in the `--id` parameter.
      * `--event`: Event in [JSON](https://en.wikipedia.org/wiki/JSON) format, e.g., `{"name": "value"}`.

      * `--file`: Path to the file containing the event you are sending to the bus in JSON format.

      The `--event` and `--file` parameters are mutually exclusive: you can use only one of them.

- API {#api}

  Use the [EventService/Put](../../../eventrouter/api-ref/grpc/Event/put.md) gRPC API call to send the event directly to a bus:

  1. If you do not have the gRPCurl utility installed, [install](https://github.com/fullstorydev/grpcurl) it.
  1. If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../../cli/quickstart.md#install).
  1. Get an [IAM token](../../../../iam/concepts/authorization/iam-token.md) used for [authentication](../../../api-ref/eventrouter/authentication.md) in the API.

      ```bash
      IAM_TOKEN=$(yc iam create-token)
      ```

      The command will save the IAM token to the `IAM_TOKEN` variable.
  1. Get a list of buses:
     
     ```bash
     yc serverless eventrouter bus list
     ```
     
     Result:
     
     ```text
     +----------------------+------------------+----------------------+--------+---------------------+
     |          ID          |       NAME       |      FOLDER ID       | STATUS | DELETION PROTECTION |
     +----------------------+------------------+----------------------+--------+---------------------+
     | f6676a9ti657******** | my-new-bus-17    | b1g681qpemb4******** | ACTIVE | false               |
     | f66aevm4ithv******** | my-favourite-bus | b1g681qpemb4******** | ACTIVE | true                |
     | f66m2q222n92******** | my-bus-42        | b1g681qpemb4******** | ACTIVE | false               |
     +----------------------+------------------+----------------------+--------+---------------------+
     ```
  1. Create a file with the request body, e.g., `body.json`:

      ```json
      {
        "bus_id": "<bus_ID>",
        "body": "<event>"
      }
      ```

      Where:
      * `bus_id`: ID of the bus you are sending the event to.
      * `body`: Event in [JSON](https://en.wikipedia.org/wiki/JSON) format, e.g., `{'name': 'value'}`.
  1. Run a gRPC call by specifying the path to the `body.json` file you created earlier:

      ```bash
      grpcurl \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d @ < body.json \
        events.eventrouter.serverless.yandexcloud.net:443 yandex.cloud.serverless.eventrouter.v1.EventService/Put
      ```

{% endlist %}