To get Codex CLI push notifications with ntfy, install the ntfy app on your phone, subscribe to a topic with a hard-to-guess name, and add Codex hooks that run curl -s -o /dev/null -d "message" https://ntfy.sh/your-topic. A Stop hook tells you the moment a turn ends, and a PermissionRequest hook tells you when Codex wants approval. Trust both once with /hooks. It's free, takes about ten minutes, and works on Mac, Windows and Linux.
011. Set up ntfy on your phone
- Install ntfy from the App Store or Google Play.
- Tap + and subscribe to a topic. Pick a long random name, such as
codex-7f3k9q2m. On the publicntfy.shserver, anyone who knows the topic can read and post to it, so the name works like a password. - Test it from your computer:
curl -d "Hello from my computer" https://ntfy.sh/codex-7f3k9q2m
The message should arrive on your phone within a second or two.
022. A hook script
A script keeps hooks.json readable and lets you add the project name. Save this as ~/.codex/hooks/ntfy.sh and make it executable (chmod +x ~/.codex/hooks/ntfy.sh):
#!/bin/sh
# Reads the hook's JSON on stdin and posts a short message to ntfy.
TOPIC="codex-7f3k9q2m"
input=$(cat)
event=$(printf '%s' "$input" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("hook_event_name",""))')
project=$(printf '%s' "$input" | python3 -c 'import json,os,sys; print(os.path.basename(json.load(sys.stdin).get("cwd","")))')
case "$event" in
Stop)
title="Codex finished: $project"
body=$(printf '%s' "$input" | python3 -c 'import json,sys; m=json.load(sys.stdin).get("last_assistant_message") or "Turn complete"; print(m[:300])')
priority=default ;;
PermissionRequest)
title="Codex wants approval: $project"
body=$(printf '%s' "$input" | python3 -c 'import json,sys; t=json.load(sys.stdin).get("tool_input") or {}; print((t.get("command") or "An action needs approval")[:300])')
priority=high ;;
*) exit 0 ;;
esac
curl -s -o /dev/null --max-time 10 \
-H "Title: $title" -H "Priority: $priority" -H "Tags: robot" \
-d "$body" "https://ntfy.sh/$TOPIC"
exit 0
-s -o /dev/null is important. ntfy answers every post with a JSON body, and anything a Stop hook prints is read by Codex; plain text there counts as invalid output. The script prints nothing and always exits 0, so it never blocks or decides anything.
033. Add the hooks
In ~/.codex/hooks.json:
{
"hooks": {
"Stop": [
{ "hooks": [ { "type": "command", "command": "~/.codex/hooks/ntfy.sh", "timeout": 15 } ] }
],
"PermissionRequest": [
{ "hooks": [ { "type": "command", "command": "~/.codex/hooks/ntfy.sh", "timeout": 15 } ] }
]
}
}
Start codex, type /hooks, review both entries and trust them. Codex skips hooks until you do, and asks again whenever you edit them. If a slow network delays the end of each turn, add "async": true to the handlers so Codex doesn't wait for curl.
04Windows
In PowerShell, Invoke-RestMethod does the same job. Save as %USERPROFILE%\.codex\hooks\ntfy.ps1:
$topic = "codex-7f3k9q2m"
$event = [Console]::In.ReadToEnd() | ConvertFrom-Json
$project = Split-Path -Leaf $event.cwd
if ($event.hook_event_name -eq "Stop") { $title = "Codex finished: $project"; $body = "$($event.last_assistant_message)" }
elseif ($event.hook_event_name -eq "PermissionRequest") { $title = "Codex wants approval: $project"; $body = "$($event.tool_input.command)" }
else { exit 0 }
if (-not $body) { $body = $title }
Invoke-RestMethod -Method Post -Uri "https://ntfy.sh/$topic" -Headers @{ Title = $title } -Body $body | Out-Null
and use this command in both hooks:
"command": "powershell -NoProfile -ExecutionPolicy Bypass -File C:\\Users\\you\\.codex\\hooks\\ntfy.ps1"
05Keeping it private
Your notification can include the project name, Codex's last message and the command it wants to run. On the public server, anyone with the topic name can read that. To tighten it:
- Use a long random topic and don't share it.
- Send less. Drop
bodyand send only the title, or only "Codex needs you". - Use access control. ntfy supports access tokens: on ntfy.sh with an account, or on a server you host yourself. Add
-H "Authorization: Bearer tk_..."to thecurlline. - Self-host ntfy if commands from work projects must not leave your network.
06Without a script
For "finished" only, Codex's notify setting can call a script that posts to ntfy, with no trust step. See the notify guide.
07What ntfy can't do
ntfy tells you Codex is waiting. It can't send your answer back into the Codex session, so you still walk back to the keyboard to approve. ntfy does support action buttons that call URLs, so a determined do-it-yourselfer can build a reply path, but then you need a server to receive the tap and a hook that waits for it. Approving Codex commands from your phone explains what that involves.
Notifier for Codex is the ready-made two-way version: its free codex-notifier tool for Mac, Windows and Linux installs and trusts its own hooks, and its iPhone or Android app lets you approve or reject, answer questions and send the next instruction. It's independent and not affiliated with OpenAI. Every option compared puts ntfy and the alternatives side by side.
08FAQ
Is ntfy free?
The public ntfy.sh server is free for normal use, and ntfy is open source if you want to host your own. Paid plans add things like reserved topics and higher limits.
Why does Codex say my Stop hook output is invalid?
Your curl printed ntfy's response. Add -s -o /dev/null, or redirect the whole command to /dev/null.
Why don't my hooks fire?
Check /hooks: new or edited hooks are skipped until trusted. Then run the script by hand with sample input: echo '{"hook_event_name":"Stop","cwd":"/tmp/x","last_assistant_message":"hi"}' | ~/.codex/hooks/ntfy.sh.
Will I get a push for every turn?
Yes, Stop fires once per turn. If that's too many, add a condition to the script, such as only sending when you've been away from the keyboard.
Does this work on a server over SSH?
Yes. It only needs outbound HTTPS from the machine where Codex runs, so it's one of the best options for servers and tmux sessions.