The notify setting in ~/.codex/config.toml tells the Codex CLI to run a program every time a turn completes. You give it a command as a list, for example notify = ["python3", "/Users/you/.codex/notify.py"], and Codex runs it with one extra argument: a JSON string describing the turn, with type set to agent-turn-complete. It is the quickest way to get a "Codex has finished" alert, a sound or a webhook, but it only reports finished turns and cannot answer or block anything.
01How notify works
# ~/.codex/config.toml
notify = ["python3", "/Users/you/.codex/notify.py"]
When a turn completes, Codex runs that command and appends the JSON as the last argument. The fields OpenAI documents are:
typeThe event. Currently always agent-turn-completethread-idThe session's idturn-idThe turn's idcwdThe working folderinput-messagesThe messages you sent that led to this turnlast-assistant-messageCodex's final message for the turnSome rules worth knowing:
- Put
notifyin your user file,~/.codex/config.toml. Codex ignores it in a project's.codex/config.tomland prints a warning, so a repository can't make your machine run a program. - Use the full path to your script, as OpenAI's example does, rather than relying on
~or your shell'sPATHtricks. - Check
typein your script and ignore anything else, in case Codex adds events later. notifyis a one-way signal: nothing it does can answer, approve or block anything in the session.
02A script that works on Mac, Windows and Linux
This Python script shows a desktop notification with the project name and the start of Codex's last message. Save it as ~/.codex/notify.py:
#!/usr/bin/env python3
import json, os, platform, subprocess, sys
def main():
event = json.loads(sys.argv[-1])
if event.get("type") != "agent-turn-complete":
return
project = os.path.basename(event.get("cwd", "")) or "Codex"
message = (event.get("last-assistant-message") or "Turn complete").strip()
message = message.replace("\n", " ")[:180]
system = platform.system()
if system == "Darwin":
script = 'display notification {} with title {}'.format(
json.dumps(message), json.dumps("Codex: " + project))
subprocess.run(["osascript", "-e", script])
elif system == "Linux":
subprocess.run(["notify-send", "Codex: " + project, message])
elif system == "Windows":
ps = "New-BurntToastNotification -Text 'Codex: {}','{}'".format(
project.replace("'", "''"), message.replace("'", "''"))
subprocess.run(["powershell", "-NoProfile", "-Command", ps])
if __name__ == "__main__":
main()
Then point notify at it:
notify = ["python3", "/Users/you/.codex/notify.py"]
On Windows, use py or the full path to python.exe, and a Windows path such as 'C:\Users\you\.codex\notify.py' (single quotes in TOML keep the backslashes). The Windows branch needs the BurntToast module (Install-Module BurntToast -Scope CurrentUser). On Linux it needs notify-send and a desktop session. On macOS, allow notifications for Script Editor in System Settings if nothing appears.
Start a new codex session after editing config.toml, then ask a short question to test it.
03notify, hooks and the built-in alert
Codex has three ways to tell you something happened. They overlap, so pick what you need:
notifyStop hookBuilt-in TUI notificationconfig.tomlhooks.json or [hooks][tui] in config.tomlPermissionRequestYesdecision: "block")No/hooksNoYesNoIf you want to know when Codex is waiting for an approval, notify can't help: add a PermissionRequest hook as described in how to get a notification when Codex finishes. The built-in alert is covered in the terminal bell guide.
04Sending notify to your phone
Because notify runs any program, it can call curl to post to ntfy, Telegram, Slack or Discord. The ntfy guide and the chat webhooks guide have scripts you can call from notify or from a hook.
These are one-way. To approve commands or answer Codex from your phone, something has to send your reply back into the session, which notify cannot do. Notifier for Codex does that through Codex's hooks instead: its free codex-notifier tool for Mac, Windows and Linux sends "finished", approvals and questions to an iPhone or Android app and returns your answer to Codex. It does not touch your notify setting, so you can keep both. See pairing your phone.
05FAQ
Can notify tell me when Codex needs approval?
No. notify only receives agent-turn-complete. Use a PermissionRequest hook for approvals, or turn on the built-in TUI notifications, which include approval-requested.
Why does my notify command run with an extra argument?
That is the JSON payload. Codex always appends it as the last argument. A command like notify-send "Codex" "done" breaks because it receives a third argument it doesn't expect, which is why a small script is the safest choice.
Does notify work in a project's .codex/config.toml?
No. Codex ignores notify in project config files and warns at startup. It must be in your user ~/.codex/config.toml.
Does notify work with the IDE extension?
OpenAI's docs say the IDE extension has no notification settings of its own and suggest configuring notify on the Codex host, so the same config.toml entry applies.
Can I have several notify commands?
notify takes one command. To do several things, point it at a script that does them all.