Send a push notification to your iPhone from any script

By Bohdan StefaniukUpdated 9 min read

Tested 2 December 2026 with curl 8.7, Python 3.13, Node 24, PHP 8.3, Home Assistant 2026.12 and n8n 3.4, sending to the live Ahem API.

To send a push notification to your iPhone from Python, curl or any other script, install Ahem (an event inbox for developers) on the phone, create a project and an API key, and send one HTTPS POST with a JSON body such as {"title": "Backup finished"}. Your phone buzzes, and the event stays in a searchable inbox. The same request works from Node, PHP, a cron job, Home Assistant or n8n, with no SDK and no Apple developer account.

What you need

  • The Ahem app for iPhone. The Android app is in beta Beta; browser notifications work without either.
  • An Ahem account (the free plan is enough), a project for your scripts, and an API key for it.
  • Something that makes HTTPS requests: curl, Python 3, Node 18 or later, PHP with the curl extension, Home Assistant or n8n.

Step by step

  1. Install the app and sign in. Install Ahem from the App Store, sign in with the same account you use on the web, and allow notifications.

  2. Create a project and a key. In Ahem, create a project, for example “My scripts”, and an API key for it. Note the project’s address: addresses are unique across Ahem, so yours may be my-scripts-48213 rather than my-scripts. The app shows it in the example request next to the key, and in a channel’s ⋯ menu. Keep both in environment variables:

    export AHEM_KEY="ak_live_…"
    export AHEM_PROJECT="my-scripts-48213"   # your project's address
  3. Send the first notification from a terminal:

    curl -sS "https://api.useahem.com/v1/channels/$AHEM_PROJECT/alerts" \
      -H "Authorization: Bearer $AHEM_KEY" \
      -H "Content-Type: application/json" \
      -d '{"title": "Backup finished", "body": "42 GB in 3 min", "level": "success"}'

    Ahem answers 202 with the event’s id, and your phone shows “Backup finished”. The #alerts channel is created with the first event; send to another name and you get another channel.

    {"id":"evt_01m8wq7x6aemzvbhmtd48v5p6f","channel":"my-scripts-48213/alerts","created_at":"2026-12-02T20:10:30Z"}

Only title is required (up to 200 characters). body is Markdown (up to 10,000 characters),level is info, success, warning or error, and you can add a url to open, a dotted type such as backup.completed, and metadata to filter and count by. Every field is in theAPI reference.

Send a push notification from Python, Node or PHP

The same request in three languages, each with no package to install. Each is a small notify() function you can paste into an existing script, and each reads the key and address from the environment.

import json
import os
import urllib.request


def notify(title, body="", level="info"):
    """Sends one event to Ahem. Raises urllib.error.HTTPError if Ahem refuses it."""
    request = urllib.request.Request(
        f"https://api.useahem.com/v1/channels/{os.environ['AHEM_PROJECT']}/alerts",
        data=json.dumps({"title": title, "body": body, "level": level}).encode(),
        headers={
            "Authorization": f"Bearer {os.environ['AHEM_KEY']}",
            "Content-Type": "application/json",
        },
    )
    with urllib.request.urlopen(request, timeout=10) as response:
        return json.load(response)


notify("Backup finished", "42 GB in 3 min", level="success")

Python uses only the standard library; with requests installed it isrequests.post(url, json=event, headers=headers, timeout=10). In Node, fetch doesn’t throw on a 4xx answer, so the function checks response.ok itself.

Send a notification to your iPhone from Home Assistant

Add a rest_command to configuration.yaml and restart Home Assistant once. The payload is built with to_json, so a title with quotes in it can’t break the JSON.

# configuration.yaml
rest_command:
  ahem:
    url: "https://api.useahem.com/v1/channels/my-home-48213/home"   # your project's address
    method: post
    headers:
      Authorization: !secret ahem_authorization   # in secrets.yaml: ahem_authorization: "Bearer ak_live_…"
    content_type: "application/json"
    payload: >-
      {{ {"title": title, "body": body | default(""), "level": level | default("info")} | to_json }}

Then call rest_command.ahem from any automation or script, with a title and, if you like, a body and alevel:

# automations.yaml (or Settings → Automations → ⋮ → Edit in YAML)
- alias: "Tell me when the washing machine is done"
  triggers:
    - trigger: numeric_state
      entity_id: sensor.washing_machine_power
      below: 5
      for: "00:02:00"
  actions:
    - action: rest_command.ahem
      data:
        title: "The washing machine is done"
        level: success

To try it without waiting for the washing machine, run rest_command.ahem with a title from the Actions tab of Home Assistant’s developer tools.

Send a notification to your iPhone from n8n

Add an HTTP Request node at the end of your workflow:

  1. Method POST, URL https://api.useahem.com/v1/channels/my-project-48213/n8n with your project’s address.
  2. Authentication “Generic Credential Type”, Generic Auth Type “Header Auth”, and a new credential with the name Authorization and the value Bearer ak_live_….
  3. Send Body on, Body Content Type JSON, Specify Body “Using JSON”.

Or copy this node and paste it onto the canvas, then pick the credential:

{
  "nodes": [
    {
      "name": "Send to Ahem",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [0, 0],
      "parameters": {
        "method": "POST",
        "url": "https://api.useahem.com/v1/channels/my-project-48213/n8n",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": {{ JSON.stringify('New order from ' + $json.customer) }},\n  \"level\": \"success\",\n  \"type\": \"order.created\"\n}",
        "options": {}
      }
    }
  ],
  "connections": {}
}

The JSON body puts values in with {{ JSON.stringify(…) }} rather than "{{ $json.customer }}" in quotes: a customer called Ana "the" Lee would otherwise break the JSON.

Make it quieter

  • Levels and a rule per channel. Send routine events as info or success and problems as error, then set the channel’s notification rule to Errors only in the app. Everything is kept; only errors buzz.
  • Silent or loud from the script. "notify": "silent" stores the event without a notification, whatever the channel’s rule; use it for backfills and chatty jobs. "notify": "loud" buzzes even on a channel set to errors only, but never on one you switched off.
  • One thread per run. Events with the same group are one thread in the inbox, for example every step of one deploy.
  • Quiet hours that still let errors through are coming Soon. Until then, send "notify": "silent" at night from the script.

Troubleshooting

  • 401. The key is missing or wrong. The header is Authorization: Bearer ak_live_…, with the word Bearer and a space. In a script run by cron or a service, your shell profile isn’t loaded, so $AHEM_KEY may be empty there.
  • 404 “There is no channel …”. AHEM_PROJECT must be your project’s exact address, such as my-scripts-48213, and the key must belong to that project. Projects aren’t created automatically; channels are.
  • 400 with validation_failed. The answer names the field: usually a missing title or a level that isn’t one of the four. In a shell, a variable pasted into a JSON string breaks the JSON as soon as it holds a quote; build the body with jq instead:
    jq -n --arg title "Disk at $(df -h / | awk 'NR == 2 { print $5 }') on $(hostname)" \
      '{title: $title, level: "warning"}' |
    curl -sS "https://api.useahem.com/v1/channels/$AHEM_PROJECT/alerts" \
      -H "Authorization: Bearer $AHEM_KEY" -H "Content-Type: application/json" -d @-
  • Python on a Mac: CERTIFICATE_VERIFY_FAILED. The Python installer from python.org doesn’t use the Mac’s certificates. Run Install Certificates.command in /Applications/Python 3.x/ once. To see why Ahem refused a request, catch urllib.error.HTTPError and print error.read().
  • Home Assistant sends nothing. Its log shows a warning such as Error. Url: … Status code 404. After editing the rest_command block, reload it (the rest_command.reload action) or restart.
  • 202 but no notification. Check that notifications are allowed for Ahem in the iPhone’s Settings and that no Focus is hiding them, then the channel’s rule in the app. In the web app, open the event and its Delivery fold: it lists each device the notification went to, or says nothing was sent.
  • 429 with rate_limited. Ahem takes 10 events per second per project, bursts of 100. Wait for the Retry-After seconds, or send fewer, bigger events.
  • 429 with quota_exhausted. The workspace is at ten times its monthly events. Retrying doesn’t help: new events are refused until next month or an upgrade.

Other ways to do it

A push from a script is a solved problem, and some of these are free.

  • ntfy. Open source and free: curl -d "Backup finished" ntfy.sh/your-topic. Anyone who knows the topic name can read it on the public server, so pick a long one or self-host. A self-hosted server reaches iPhones instantly only by relaying through ntfy.sh.
  • Pushover. Reliable and simple. 30-day trial, then $4.99 once per platform (checked 15 November 2026); it delivers messages and keeps no searchable history. See Ahem vs Pushover.
  • Bark. A free, open-source iPhone app: you get a personal URL and a plain GET request pushes a message.
  • The Home Assistant app. If you already run Home Assistant, notify.mobile_app_your_phone pushes to the companion app for free. Use that for home alerts that only matter at home.
  • A Telegram bot. Free and on every phone, with one chat for everything. See Ahem vs a Telegram bot.

What Ahem adds is the inbox behind the push: every script, server and app files into channels with levels, you choose per channel what buzzes, and you can search last month’s backups or failed cron jobs later. Compare all of them.

FAQ

Questions

Do I need an SDK or a server?
No. One HTTPS request with a JSON body sends a notification, so anything that can make a request works: a shell script, a cron job, a Raspberry Pi, a serverless function.
Does it work on Android?
The Android app is in beta. Browser notifications work on any computer or phone whose browser supports web push, and the iPhone app is in the App Store.
Is it free?
The free plan includes 3,000 events a month and 7 days of history. Every request is one event, whether it buzzes or not.
Can more than one phone get the notification?
Yes. Every device you sign in on gets it (up to 20 per person), and on Maker you can invite people to the project; each of them sets their own rule per channel.
Is it safe to put the API key in a script?
A new key can only send events and create channels; it can’t read your events. Keep it out of version control (an environment variable or a secrets file), and delete it in the app if it leaks: the next request with it gets 401.

One curl, and your phone knows.

Create a free project, copy the key, and send your first push from the terminal.