Codex CLI push notifications
Codex CLI can push a notification to your phone through PushPiper after every turn, free for 10,000 messages a month on 10 devices. It takes one notify line in ~/.codex/config.toml and a short standard-library Python script, and quotas reset on the 1st of each month at 00:00 UTC.
How Codex CLI turn notifications work
Codex CLI executes a local program every time it finishes an agent turn. It triggers this hook automatically when the turn reaches completion, so you don't have to sit and watch your terminal while the agent runs through multi-step edits or long test suites. That saves time. When a turn completes, Codex launches your command as a subprocess and supplies a single string argument containing a JSON object on sys.argv[1].
The following overview compares the JSON payload keys sent by Codex CLI against what each property contains.
| Field in the JSON | What it holds |
|---|---|
| type | agent-turn-complete |
| thread-id | The session |
| turn-id | The turn that finished |
| cwd | The working directory, used for the title |
| input-messages | What you asked |
| last-assistant-message | Codex's last reply, used for the message |
The type field always equals agent-turn-complete for these events. And because Codex hands this data over in sys.argv[1], your script parses it immediately without reading from standard input. Have you checked what Codex sends? You'll find the full turn text right there.
Create a dedicated PushPiper app for Codex
You should set up a separate application inside PushPiper specifically for your Codex alerts. This lets you mute coding turns without silencing system monitoring or server alerts that share your user key.
- Sign in with Google at the PushPiper web app.
- Copy your 30-character user key starting with u from the web app.
- Create a new application named Codex to generate a 30-character app token starting with a.
- Open the PushPiper web app on your phone to register your device for web push.
PushPiper delivers alerts via web push to Chrome, Edge, Firefox, and Safari across desktop operating systems as well as Android and Linux, meaning you get notifications everywhere without installing software from an app store. On iOS or iPadOS 16.4 and later, open pushpiper.com/app in Safari, tap Share, then Add to Home Screen. It works smoothly. But remember that PushPiper has no native App Store or Play Store apps yet, and it does not make phone calls or send SMS text messages. Check the PushPiper API reference if you need detailed parameter definitions.
Set up the notification script
The notification script runs under Python 3 and uses only modules included in the standard library. You won't need to configure pip packages, compile dependencies, or set up a dedicated virtual environment.
PushPiper limits the message parameter to 1,024 characters and rejects any larger payload with an HTTP 400 error. Because Codex replies often run several paragraphs long, the script slices the assistant text to 1,000 characters before sending it over the network so that the API will never reject your request. That avoids errors. It also extracts the directory name from cwd so your alert title displays the active project repository directly.
import json
import sys
import urllib.parse
import urllib.request
APP_TOKEN = "APP_TOKEN"
USER_KEY = "USER_KEY"
def main() -> None:
event = json.loads(sys.argv[1])
if event.get("type") != "agent-turn-complete":
return
project = event.get("cwd", "").rstrip("/").split("/")[-1] or "Codex"
message = (event.get("last-assistant-message") or "Turn complete")[:1000]
body = urllib.parse.urlencode({
"token": APP_TOKEN,
"user": USER_KEY,
"title": f"Codex finished ({project})",
"message": message,
}).encode()
urllib.request.urlopen("https://api.pushpiper.com/1/messages.json", body, timeout=10)
if __name__ == "__main__":
main()Save this script to a permanent location on your machine (such as ~/.codex/pushpiper_notify.py). Replace APP_TOKEN with your 30-character app token and USER_KEY with your 30-character user key.
Configure Codex in your home directory
Codex looks for notification settings in your user-level configuration file.
Open ~/.codex/config.toml and define the notify array. Use the full path to your script in the command array.
notify = ["python3", "/Users/you/.codex/pushpiper_notify.py"]Replace /Users/you with your home directory path. So double-check your path. Follow these steps to finish setting it up:
- Verify your script path exists on disk and that Python 3 can run it.
- Add the notify array into ~/.codex/config.toml using absolute paths.
- Run a turn in Codex to trigger your first push notification.
If you use other automated developer agents on your workstation, you can set up similar alerts across your terminal tools by following our walkthroughs for Claude Code push notifications, Cursor agent push notifications, and Gemini CLI push notifications.
Notification delivery and priority options
PushPiper processes incoming events via POST requests to https://api.pushpiper.com/1/messages.json at rates up to 600 requests a minute per app token. The free tier gives you EUR 0 billing forever for up to 10,000 messages every month across your devices. If you ever hit that limit during heavy development, the API answers with HTTP 429 until the quota resets on the 1st of the month at 00:00 UTC, which ensures predictable usage without unexpected charges.
The script uses default priority 0, which rings with sound and respects quiet hours. PushPiper supports five priority tiers:
- -2 Lowest, dropping the message silently into your inbox without an alert.
- -1 Low, delivering a silent banner.
- 0 Normal, sending an audible ping that stays quiet during quiet hours.
- 1 High, triggering an immediate notification that bypasses PushPiper quiet hours.
- 2 Emergency, repeating every retry seconds (at least 30) for up to 10,800 seconds until acknowledged.
Quiet hours are configured inside PushPiper itself. Do you need alerts that break through sleep settings? PushPiper cannot send iOS critical alerts, so no priority setting breaks through iOS Do Not Disturb or Focus.
Sources
Questions and answers
Can I put the notify setting inside my project directory?
Codex CLI only reads the notify key from ~/.codex/config.toml in your home directory. Any notify setting placed in a project .codex/config.toml file is ignored.
Why does the script clip the assistant message to 1,000 characters?
PushPiper returns an HTTP 400 error if the message parameter exceeds 1,024 characters. Trimming the assistant response to 1,000 characters prevents Codex replies from causing failed requests.
Does the Python notification script require external dependencies?
The script uses only standard library modules: json, sys, urllib.parse, and urllib.request. You can run it directly with standard Python 3 without installing any third-party packages.
Will emergency alerts break through iOS Focus or Do Not Disturb?
PushPiper notifications do not break through Apple Focus or Do Not Disturb on iOS devices. High and emergency priorities only bypass quiet hours configured directly inside PushPiper settings.
How do I install PushPiper on an iPhone without an app store?
Open pushpiper.com/app in Safari on iOS 16.4 or later, tap Share, and select Add to Home Screen. This installs the web push client so your phone can receive notifications.