---
title: "Sending Events"
description: "Learn how Sentry's command line interface can be used for sending events."
url: https://docs.sentry.io/cli/send-event/
---

# Sending Events

The `sentry-cli` tool can also be used for sending events. If you want to use it, you need to export the `SENTRY_DSN` environment variable and point it to the DSN of a project of yours:

```bash
export SENTRY_DSN='___PUBLIC_DSN___'
```

Once that is done, you can start using the `sentry-cli send-event` command.

## [Basic Events](https://docs.sentry.io/cli/send-event.md#basic-events)

For basic message events, you just need to provide the `--message` or `-m` parameter to send a message:

```bash
sentry-cli send-event -m "Hello from Sentry"
```

This will send a single message to Sentry and record it as an event. Along with that event, it sends basic information about the machine you are running `sentry-cli` on. You can provide `-m` multiple times to send multiple lines:

```bash
sentry-cli send-event -m "Hello from Sentry" -m "This is more text"
```

## [Events with Parameters](https://docs.sentry.io/cli/send-event.md#events-with-parameters)

In addition you can use `%s` as placeholder in a message and fill it in with the `-a` parameter. This helps reviewing them, as all messages will be grouped together automatically:

```bash
sentry-cli send-event -m "Hello %s!" -a "Joe"
sentry-cli send-event -m "Hello %s!" -a "Peter"
```

## [Sending Breadcrumbs](https://docs.sentry.io/cli/send-event.md#sending-breadcrumbs)

You can also pass a logfile to the `send-event` command which will be parsed and sent along as breadcrumbs. The last 100 items will be sent:

```bash
sentry-cli send-event -m “task failed” –-logfile error.log
```

The logfile can be in various formats. If you want to create one yourself you can do something along those lines:

```bash
echo "$(date +%c) This is a log record" >> output.log
echo "$(date +%c) This is another record" >> output.log
sentry-cli send-event -m "Demo Event" --logfile output.log
rm output.log
```

## [Extra Data](https://docs.sentry.io/cli/send-event.md#extra-data)

Extra data can be attached with the `-e` parameter as `KEY:VALUE`. For instance, you can send some key value pairs like this:

```bash
sentry-cli send-event -m "a failure" -e task:create-user -e object:42
```

Likewise, tags can be sent with `-t` using the same format:

```bash
sentry-cli send-event -m "a failure" -t task:create-user
```

## [Stored Events](https://docs.sentry.io/cli/send-event.md#stored-events)

As of version `1.71`, the `send-event` command can accept an optional argument that specifies a path to the stored JSON representation of an [event payload](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/). When used, it will load the file, validate the event and send it to Sentry.

```bash
sentry-cli send-event ./events/20211029150006.json
```

This argument can be also provided in the form of a glob, which will cause it to process all matched events.

```bash
sentry-cli send-event "./events/*.json"
```

If `send-event` is called with the `--raw` flag, the event will not be validated before being sent.

```bash
sentry-cli send-event --raw ./events/20211029150006.json
```

## [Specifying Releases](https://docs.sentry.io/cli/send-event.md#specifying-releases)

Releases can be sent with the `--release` parameter. A default release is picked up automatically if you are using sentry-cli from within a git repository.

## [Bash Hook](https://docs.sentry.io/cli/send-event.md#bash-hook)

For bash scripts you can also enable automatic error sending by using the sentry-cli bash hook. That enables `set -e` and will send a Sentry event for unhandled errors.

The limitations for this are:

* sentry-cli really only works if `set -e` is enabled (which it will by default enable for you).
* sentry-cli registers an `EXIT` and `ERR` trap.

Usage:

```bash
#!/bin/bash
export SENTRY_DSN='___PUBLIC_DSN___'
eval "$(sentry-cli bash-hook)"
# rest of the script goes here
```

Alternatively you can use other mechanisms like [a `.sentryclirc` file](https://docs.sentry.io/cli/configuration.md#configuration-file) to configure the DSN.
