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

DSNThe Data Source Name (DSN) key tells the Sentry SDK where to send events, ensuring they go to the right project.
of a
projectRepresents your service in Sentry and allows you to scope events to a distinct application.
of yours:

export SENTRY_DSN=''

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

Basic Events

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

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:

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

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:

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

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:

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:

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

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

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:

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

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. When used, it will load the file, validate the event and send it to Sentry.

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.

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

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

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

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

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.


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

Alternatively you can use other mechanisms like a .sentryclirc file to configure the

DSNThe Data Source Name (DSN) key tells the Sentry SDK where to send events, ensuring they go to the right project.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").