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
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.
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-48213rather thanmy-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 addressSend 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
202with the event’s id, and your phone shows “Backup finished”. The#alertschannel 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")// Node 18 or later: fetch is built in. Save as notify.mjs and run with `node notify.mjs`.
async function notify(title, body = '', level = 'info') {
const response = await fetch(`https://api.useahem.com/v1/channels/${process.env.AHEM_PROJECT}/alerts`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.AHEM_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ title, body, level }),
signal: AbortSignal.timeout(10_000),
})
// fetch only throws when there is no answer at all; a 4xx is still a "successful" fetch.
if (!response.ok) throw new Error(`Ahem answered ${response.status}: ${await response.text()}`)
return response.json()
}
await notify('Backup finished', '42 GB in 3 min', 'success')<?php
// Needs PHP's curl extension (php-curl), which most installs have.
function notify(string $title, string $body = '', string $level = 'info'): bool
{
$ch = curl_init('https://api.useahem.com/v1/channels/' . getenv('AHEM_PROJECT') . '/alerts');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('AHEM_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['title' => $title, 'body' => $body, 'level' => $level], JSON_INVALID_UTF8_SUBSTITUTE),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
error_log("Ahem answered $status: " . ($response === false ? curl_error($ch) : $response));
return false;
}
return true;
}
notify('Backup finished', '42 GB in 3 min', 'success');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"}'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: successTo 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:
- Method
POST, URLhttps://api.useahem.com/v1/channels/my-project-48213/n8nwith your project’s address. - Authentication “Generic Credential Type”, Generic Auth Type “Header Auth”, and a new credential with the name
Authorizationand the valueBearer ak_live_…. - 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
infoorsuccessand problems aserror, 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
groupare 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 isAuthorization: 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_KEYmay be empty there.404“There is no channel …”.AHEM_PROJECTmust be your project’s exact address, such asmy-scripts-48213, and the key must belong to that project. Projects aren’t created automatically; channels are.400withvalidation_failed. The answer names the field: usually a missingtitleor alevelthat 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 withjqinstead: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. RunInstall Certificates.commandin/Applications/Python 3.x/once. To see why Ahem refused a request, catchurllib.error.HTTPErrorand printerror.read(). - Home Assistant sends nothing. Its log shows a warning such as
Error. Url: … Status code 404. After editing therest_commandblock, reload it (therest_command.reloadaction) or restart. 202but 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.429withrate_limited. Ahem takes 10 events per second per project, bursts of 100. Wait for theRetry-Afterseconds, or send fewer, bigger events.429withquota_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_phonepushes 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.