User Accounts Webhook
Helm can show how many user accounts your product has, next to its other numbers, without any access to your database. You add one small endpoint to your own backend, and Helm asks it for the counts whenever someone opens the User Accounts page. Django backends can install that endpoint from the django-helm SDK in a few lines. This page also tells your developers exactly what the endpoint receives and what it must return, for any other language.
What you're about to do, in plain English
A webhook here is a web address (URL) on your backend that Helm calls with an HTTP request. Your backend counts its accounts and answers with a short piece of JSON, a plain text format for data. Helm never sees individual users, only the totals you send.
To make sure only Helm can ask for the counts, Helm creates an API key: a long random password that Helm sends with every request. Your backend keeps a copy and refuses any request that does not carry it.
Setup happens in two places:
- Your backend — where your developer adds the endpoint and stores the API key.
- Helm — where you enter your backend's address and generate the API key.
Using django-helm
If your backend is built with Django, you do not need to write the endpoint yourself. django-helm is Helm's SDK (a ready-made package) for Django, from version 0.2.0. Once it is installed, your developer does the following:
- Add
django_helm.analyticstoINSTALLED_APPSin your settings, then runpython manage.py migrate. - Add
path('', include('django_helm.urls'))to your rooturls.py. - Put the API key that Helm generated for you (see Step 1) into
HELM_ANALYTICS['api_key']in your settings. - Done. The endpoint now answers at
/helm/user_accounts.
Django readers still need Step 1 (set the base URL and generate the key) and Step 5 (test the connection) below. Everyone else keeps reading from Step 1 through Step 5 for the steps to build the endpoint by hand, including Steps 2 to 4.
Step 1 — Set up the Backend SDK in Helm
This tells Helm where your backend lives and creates the key your backend will check. The tab is called Backend SDK whether you use django-helm or build the endpoint yourself.
- Open your project in Helm and click Settings in the sidebar.
- Under Monitoring, click Backend SDK.
-
In Backend base URL, enter the address of your backend:
https://plus the host name only, for examplehttps://api.example.com, with no path.The address must start with
https://and must be reachable from the internet. Helm refuses addresses on private networks, such aslocalhost,127.0.0.1,10.x.x.xor192.168.x.x. -
Optionally, fill in User accounts path. Leave it empty to use
/helm/user_accounts, where django-helm serves the endpoint. If your endpoint lives somewhere else, for example a view you wrote yourself, enter its path, such as/helm/user-accounts/. - Click Save Changes. This stores the base URL and the path together.
- Next to API Key, click Generate. Helm shows the new key, which starts with
hwk_. Generate stores the key on its own, so it does not depend on Save Changes. - Copy the key and store it on your backend, for example as an environment variable named
HELM_WEBHOOK_API_KEY.
Step 2 — Understand the request Helm sends
Each time someone asks for the counts, Helm sends one POST request to your
endpoint: your backend base URL followed by the user accounts path.
Headers
Helm sends the API key twice, so your backend can read whichever header is easier:
Authorization: Bearer hwk_...
X-Helm-Api-Key: hwk_...
Content-Type: application/json
User-Agent: Helm-Webhook/1.0
Body
{
"query": "user_accounts",
"since": "2026-10-01T00:00:00Z",
"project": "your-project-slug"
}
queryis always"user_accounts". It lets you serve other Helm queries from the same URL later.sinceis a date and time in UTC, in ISO 8601 format. It is always midnight at the start of the date the user picked in Helm. By default it is 30 days ago.projectis the Helm project's short name as it appears in Helm's URLs. Use it if one endpoint serves several Helm projects.
Limits
- Helm waits 10 seconds for an answer, then gives up. It also stops waiting for the whole answer after 15 seconds in total, even if your backend keeps sending data slowly.
- Helm does not follow redirects. If your endpoint answers with a redirect such as
301or302, Helm treats it as an error. Enter the final address in Helm instead. - The answer must be smaller than 64 KB. Seven counts are far smaller than that.
Step 3 — Return the counts
Your endpoint answers with HTTP status 200 and a JSON object containing these
eight fields. Every value must be a whole number of zero or more. Do not send numbers as
text ("40"), decimals (40.0) or true/false.
{
"total_users": 1200,
"active_users": 950,
"inactive_users": 250,
"activated_users": 1100,
"not_activated_users": 100,
"created_since": 40,
"logged_in_since": 610,
"activated_since": 35
}
What each field means
The first five are counts as of now:
total_users— every account your backend has.active_users— accounts you count as active.inactive_users— accounts you count as inactive.activated_users— accounts that finished activation, for example by confirming their email address.not_activated_users— accounts that have not finished activation yet.
The last three use the since value from the request:
created_since— every account created at or aftersince, whether it has activated or not.logged_in_since— accounts that logged in at or aftersince.activated_since— accounts that finished activation at or aftersince, whenever they were created.
Two more fields are optional. Leave them out if you do not track them:
staff_users— optional. How many of your accounts belong to your own team.analytics_excluded_users— optional. How many accounts you leave out of analytics, such as staff and test accounts.
When your answer includes these two fields, the Helm page shows two extra tiles for them. django-helm sends both automatically.
You decide what "active" and "activated" mean for your product. Helm shows the numbers as you send them and does not check that they add up. If you add other fields to the answer, Helm ignores them.
User emails endpoint
The same django-helm install can also feed your Email List. Helm asks your backend for the email addresses of accounts that have verified their address, and for addresses that users changed, then adds new people to your default mailing feed and renames contacts whose address changed, keeping their subscriptions. Helm never changes an existing contact in any other way. This is optional. Helm only does it when the Backend SDK is set up (Step 1) and your backend serves this second endpoint.
Turn it on in django-helm
- Update django-helm to version 0.3.0 or later.
- Add
django_helm.mailertoINSTALLED_APPS, then runpython manage.py migrate. - Done. The endpoint answers at
/helm/user_emailsand uses the same API key as the user accounts endpoint.
If your backend does not have the app yet, it answers 404 and the
Email List page in Helm shows a short hint telling you to add it.
What Helm asks for
Helm sends one POST request with the same headers as in Step 2 and this body:
{
"query": "user_emails",
"project": "your-project-slug",
"since": "2026-11-06T00:00:00Z",
"until": "2026-11-08T00:00:00Z"
}
sinceis required. It is included in the answer, so an account changed exactly at that moment is returned.untilis optional and is not included. It defaults to the moment of the request.- If
sinceis not earlier thanuntil, your backend answers400.
What your backend returns
{
"project": "your-project-slug",
"generated_at": "2026-11-08T10:00:00Z",
"since": "2026-11-06T00:00:00Z",
"until": "2026-11-08T00:00:00Z",
"accounts": [
{"email": "[email protected]", "first_name": "Jane", "last_name": "Doe", "changed_at": "2026-11-07T09:30:00Z"}
],
"email_changes": [
{"previous_email": "[email protected]", "email": "[email protected]", "changed_at": "2026-11-07T12:00:00Z"}
],
"has_more": false,
"next_since": null
}
accountslists only verified accounts, meaning accounts that are active (is_activeis true).email_changeslists addresses that users changed, so Helm renames the existing contact instead of adding a second one.- Addresses on reserved test domains (
.local,.invalid,.test,.exampleand.localhost) are never reported.
Paging
One answer holds up to 150 accounts and 75 email changes. When there is more, the answer has
"has_more": true and next_since tells Helm where to continue. Helm
keeps asking, starting each request at the previous next_since, until
has_more is false. Entries that share the same changed_at moment are
never split across two pages.
How long changes are kept
django-helm keeps the record of email changes for 90 days and then removes it. When a user is deleted, their change records are removed too. New signups still arrive after a long gap, because they are found from the account's join date. Only email changes and late activations older than 90 days are lost.
How often it runs, and how to run it yourself
Helm syncs about once an hour for every project that has the Backend SDK set up. The
Email List page shows when the last sync ran and how many accounts it
pulled, or why it failed. A large import runs in chunks of 20 pages per hourly run, so
it can take several runs to finish. To pull now, ask Helm's assistant to run the
sync_user_emails tool, or ask Helm to run the import for you.
The tool accepts an optional start (since) and end (until) in
ISO 8601 format, for example 2020-01-01T00:00:00Z to import older accounts.
When more pages remain, its answer includes resume_since: run it again with
since set to that value to continue.
Step 4 — Check the API key on your backend
Before counting anything, your endpoint must check that the request carries the API key
you stored in Step 1. If the key is missing or wrong, answer with 401 and no
counts. Helm then tells the user that your backend rejected the key.
Compare the keys with a constant-time comparison: a function that always
takes the same time whether the first character or the last character differs. A plain
== can stop at the first difference, and an attacker who measures response
times could use that to guess the key one character at a time. Most languages have such a
function:
- Python:
hmac.compare_digest(a, b) - Node.js:
crypto.timingSafeEqual(a, b)(both values must be buffers of the same length) - Ruby on Rails:
ActiveSupport::SecurityUtils.secure_compare(a, b) - Go:
subtle.ConstantTimeCompare(a, b) - PHP:
hash_equals($a, $b)
Example endpoint in Django
This view uses Django's built-in user model. In this example an account is
active when is_active is true, and activated when the user has
logged in at least once. Change those two rules to match your product.
import hmac
import json
import os
from datetime import datetime
from django.contrib.auth import get_user_model
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
def _api_key_from(request):
header = request.headers.get("Authorization", "")
if header.startswith("Bearer "):
return header[len("Bearer "):]
return request.headers.get("X-Helm-Api-Key", "")
@csrf_exempt # Helm cannot send a Django CSRF token; the API key protects this view.
@require_POST
def helm_user_accounts(request):
expected = os.environ.get("HELM_WEBHOOK_API_KEY", "")
supplied = _api_key_from(request)
if not expected or not hmac.compare_digest(supplied.encode(), expected.encode()):
return JsonResponse({"error": "invalid API key"}, status=401)
try:
body = json.loads(request.body)
since = datetime.fromisoformat(body["since"].replace("Z", "+00:00"))
except (ValueError, KeyError, TypeError, AttributeError):
return JsonResponse({"error": "invalid request body"}, status=400)
users = get_user_model().objects.all()
total = users.count()
active = users.filter(is_active=True).count()
# Django's built-in user model does not record when an account was
# activated. This example assumes your user model has an
# ``activated_at`` date and time field that you set on activation.
activated = users.filter(activated_at__isnull=False).count()
return JsonResponse({
"total_users": total,
"active_users": active,
"inactive_users": total - active,
"activated_users": activated,
"not_activated_users": total - activated,
"created_since": users.filter(date_joined__gte=since).count(),
"logged_in_since": users.filter(last_login__gte=since).count(),
"activated_since": users.filter(activated_at__gte=since).count(),
})
Then add a URL for it in your urls.py:
from django.urls import path
from .views import helm_user_accounts
urlpatterns = [
path("helm/user-accounts/", helm_user_accounts),
]
Step 5 — Test the connection
Once your endpoint is deployed, check that Helm and your backend agree.
- In Helm, go back to Settings and open Backend SDK.
- Click Send test request. Helm asks for counts since 30 days ago and shows either the eight numbers or the reason the request failed.
- When the test works, open User Accounts under Monitoring in the sidebar. Pick a date in Since to change the two "since" counts.
What Helm shows when something goes wrong
Helm never retries on its own. It shows one of these messages, and the user can try again:
- The backend SDK is not set up — the backend base URL or the API key is missing in the project settings.
- Helm will not call this URL — the backend base URL no longer meets the rules in Step 1, for example because its host now points to a private address.
- Helm could not connect to your backend — the host name did not resolve, the connection was refused, or the secure (TLS) connection failed.
- Your backend did not answer in time — no answer within 10 seconds, or the whole answer took longer than 15 seconds.
- Your backend rejected the API key — your endpoint answered with
401or403. - Your backend returned an error — any other status than
200, including redirects. - Your backend sent an answer Helm cannot read — the body is not JSON, is not a JSON object, is too large, or a field is missing or is not a whole number of zero or more. The message names the fields.
Troubleshooting
"Your backend rejected the API key"
Your backend does not have the same key that Helm has. Common causes:
- Someone clicked Generate again in Helm, which replaced the key. Copy the new key to your backend.
- The key was copied with a space or line break at the start or end.
- Your server or proxy strips the
Authorizationheader. ReadX-Helm-Api-Keyinstead.
"Your backend returned an error" with HTTP 301, 302 or 308
Your server redirected the request, often from http:// to https://
or to add a trailing slash. Helm does not follow redirects. Copy the final address into
Backend base URL and User accounts path, including any trailing slash.
"Your backend returned an error" with HTTP 403 from Django
If the answer is Django's "CSRF verification failed" page, the view is missing
@csrf_exempt. Helm cannot send a CSRF token, and the API key check
protects the view instead.
"Your backend sent an answer Helm cannot read"
Read the message: it names the missing or wrong fields. Check that every count is a plain
number such as 40, not "40", 40.0 or null,
and that the answer is a JSON object rather than a list.
"Your backend did not answer in time"
Counting rows in a large table can be slow. Add database indexes on the columns you filter by (for example the sign-up date and last login date), or keep the counts in a cache that your backend refreshes regularly.
Helm says the backend base URL resolves to a non-public address
Helm only calls addresses on the public internet, so a project cannot use Helm to reach
private networks. Use your backend's public address. For a local test, expose your
development server through a tunnelling service that gives it a public
https:// address.
"Backend sync not set up" with the django_helm.mailer hint
Your backend answered the user emails request with 404, which means the
endpoint does not exist there. Update django-helm to 0.3.0 or later, add
django_helm.mailer to INSTALLED_APPS, run
python manage.py migrate and deploy. The next hourly sync picks it up.
A custom path in User Emails Path must also match where you serve the view.
"Your backend repeated a page without advancing"
Your backend said has_more is true, but its next_since did not
move past the since Helm had just sent, so Helm stopped instead of asking
the same question forever. A hand-built endpoint usually causes this by not moving
next_since forward. If a lot of entries share one changed_at
moment, return them together in one page, even if that exceeds the page size, and
continue after that moment.
No contacts are arriving
Helm adds a person only when your backend reports them, so check these in order:
django_helm.maileris missing fromINSTALLED_APPS, or its migrations have not run. Your backend then answers404and the Email List page shows "Backend sync not set up".- No one has activated an account since you installed it. The hourly sync only reads recent changes, so ask Helm to run the import with an early
sinceto bring in older accounts. - The Backend base URL or the API key is not set under Backend SDK in the project settings. Helm then skips the sync and the Email List page shows no backend status line at all.
"Too many pages" after a large import
One run reads at most 400 pages, so a very large import stops before the end. Nothing is
lost: every page Helm read is already saved. Run the sync_user_emails tool
again with since set to the resume_since value from its last
answer, and repeat until has_more is false.