Active Directory agent API
The job-queue API the on-prem Active Directory agent polls to create and disable AD accounts.
ClockEU can't reach a company's own domain controller directly — it sits behind their firewall. Instead, the agent (a small Windows service installed on a machine inside that network) polls these two endpoints over outbound HTTPS, so no inbound port ever needs to open.
Authentication
Generate an agent token from Settings → Active Directory, shown once — paste it into the agent's setup wizard.
POST /api/ad-agent-poll.php
Returns any jobs waiting for this company (create_user / disable_user), and marks them "sent" so a second poll before this one completes doesn't hand out the same job twice.
curl -X POST https://acme.clockeu.eu/api/ad-agent-poll.php \
-H "Authorization: Bearer <agent_token>" \
-H "Content-Type: application/json" \
-d '{"agent_name": "DC01"}'
{
"ok": true,
"jobs": [
{
"job_id": 42,
"type": "create_user",
"payload": {
"samAccountName": "j.smith",
"upn": "j.smith@corp.local",
"givenName": "Jane",
"surname": "Smith",
"displayName": "Jane Smith",
"email": "j.smith@corp.local",
"password": "T3mp-Pass!92x",
"ou": null
}
}
]
}
POST /api/ad-agent-result.php
Reports a job as done or failed. The one-time password in a create_user job is wiped from the database the moment this succeeds — it can't be read back afterward.
curl -X POST https://acme.clockeu.eu/api/ad-agent-result.php \
-H "Authorization: Bearer <agent_token>" \
-H "Content-Type: application/json" \
-d '{"job_id": 42, "ok": true, "account": "j.smith"}'
Example: a minimal agent loop
import time, requests
BASE = "https://acme.clockeu.eu"
HEADERS = {"Authorization": "Bearer <agent_token>"}
while True:
r = requests.post(f"{BASE}/api/ad-agent-poll.php", headers=HEADERS,
json={"agent_name": "DC01"}, timeout=30)
for job in r.json().get("jobs", []):
try:
account = create_or_disable_in_ad(job) # your code: LDAP / PowerShell
result = {"job_id": job["job_id"], "ok": True, "account": account}
except Exception as e:
result = {"job_id": job["job_id"], "ok": False, "error": str(e)}
requests.post(f"{BASE}/api/ad-agent-result.php", headers=HEADERS, json=result, timeout=30)
time.sleep(60)
Download the ready-made agent (source + installer instructions) from Software.