Skip to main content

API Reference

Base URL: https://api.h.work (prod) / https://api.h852.work (staging)

Auth: Authorization: Bearer <jwt> on all protected endpoints unless noted.

Global rate limit: 100 req/min per IP. Auth endpoints: 10 req/min.


Health

MethodPathAuthDescription
GET/healthNoneLiveness probe — returns 200 if service is up
GET/readyNoneReadiness probe — checks DB + agent connectivity
GET/metricsNetwork policyPrometheus metrics (internal only)

Auth

MethodPathAuthDescription
POST/auth/registerNoneSelf-service: create org + first admin user
POST/auth/loginNoneReturns JWT with userId, email, platformRole, orgMemberships
POST/auth/demo-loginNoneDemo backdoor (DEMO_MODE=true only)
POST/auth/orgsSuperadminCreate org with admin user
POST/auth/accept-invite/:tokenNoneAccept invite + set password → JWT
POST/orgs/:orgId/invitesOrgAdminInvite user by email
DELETE/orgs/:orgId/members/:userIdOrgAdminRemove user from org
GET/orgs/:orgIdJWTOrg details
GET/orgs/:orgId/membersOrgAdminList org members
GET/orgs/:orgId/quotaJWTHourly message quota status

2FA

MethodPathAuthDescription
POST/auth/2fa/setupJWTGenerate TOTP secret + QR code URI
POST/auth/2fa/verifyJWTVerify TOTP code and enable 2FA

Superadmin Auth Tools

MethodPathAuthDescription
POST/auth/bootstrap-superadminNone (once)Promote first user if no superadmin exists
PATCH/admin/users/:id/roleSuperadminUpdate platformRole
PATCH/admin/users/:id/passwordSuperadminReset password

OTP Flow (Onboarding)

MethodPathAuthDescription
GET/invites/validateNoneValidate invite token
POST/auth/send-invite-otpNoneSend email OTP
POST/auth/verify-invite-otpNoneVerify OTP → create/activate account

Conversations

Rate limit: 100 req/min per PRD §14.

MethodPathAuthDescription
POST/conversationsJWTCreate conversation
GET/conversationsJWTList conversations (filter: orgId)
GET/conversations/searchJWTFull-text search (q, orgId, limit, offset)
GET/conversations/:idJWTFetch conversation + messages (paginated)
POST/conversations/:id/messagesJWTSend message
POST/conversations/:id/messages/streamJWTStream agent response as SSE
POST/conversations/:id/assign-agentJWTReassign or rename agent

Expert Queue

MethodPathAuthDescription
GET/expert-queueExpertList queue items (filter: status, orgId)
GET/expert-queue/:idExpertFetch single queue item
POST/expert-queue/:id/suggestExpertGet fresh AI suggestion for item
POST/expert-queue/:id/respondExpertSend response (approve/edit/write own)
POST/expert-queue/:id/resolveExpertResolve with satisfaction score
PATCH/expert-queue/:id/statusExpertUpdate status (pending/in_progress/resolved)
POST/expert-queue/:id/deferExpertDefer item by X hours
POST/expert-queue/:id/add-noteExpertAdd internal note
POST/expert-queue/:id/correctionsExpertSubmit correction for learning loop
GET/expert/orgsExpertGet Expert's available orgs

Removed (2026-05-03): /expert-queue/:id/reassign, /expert/pools, /pools, /expert/pools/:id/members — expert pool model deleted. Expert ↔ Org assignment is now direct via org_experts.


Onboarding

All onboarding endpoints use a token (from the invitation email) instead of JWT auth.

Client-Facing (Phase 2 Wizard)

MethodPathAuthDescription
POST/onboarding/:token/verify-emailTokenSend OTP to admin email
POST/onboarding/:token/confirm-otpTokenVerify OTP → session JWT
POST/onboarding/:token/set-credentialsTokenSet password (+ optional 2FA)
POST/onboarding/:token/profileTokenSave name, title, phone
GET/onboarding/:token/orgTokenOrg details for wizard
GET/onboarding/:token/specialistTokenAssigned Specialist card
POST/onboarding/:token/confirm-slugTokenFinalize and reserve slug
GET/onboarding/:token/whitelistTokenList email whitelist entries
POST/onboarding/:token/whitelistTokenAdd entry to whitelist
DELETE/onboarding/:token/whitelist/:idTokenRemove whitelist entry
POST/onboarding/:token/invite-membersTokenInvite multiple Client Members
POST/onboarding/:token/completeTokenFinalize onboarding (Step 2.6)

Public Onboarding Endpoints

MethodPathAuthDescription
GET/orgs/slug-checkNoneReal-time slug availability check
GET/invitations/:token/validateNoneValidate invite token, return org slug
GET/client/trial-infoJWTTrial countdown for client portal

Organizations (Account Manager)

MethodPathAuthDescription
POST/orgsAMCreate org (status: pending_am_setup)
GET/am/orgsAMList AM's assigned orgs
GET/am/orgs/:orgIdAMOrg detail
PATCH/am/orgs/:orgIdAMUpdate company info
GET/am/orgs/:orgId/phase0-statusAMPhase 0 validation checklist
POST/am/orgs/:orgId/inviteAMSend client invitation (Phase 0 gate check)
POST/am/orgs/:orgId/invite/resendAMResend invitation (fresh 7-day token)
DELETE/am/orgs/:orgId/inviteAMRevoke invitation
GET/am/specialistsAMList available specialists
GET/am/specialists/:idAMSpecialist detail
POST/am/orgs/:orgId/specialistAMAssign specialist to org (1:N)
DELETE/am/orgs/:orgId/specialistAMUnassign specialist

Specialist Change Requests

MethodPathAuthDescription
POST/orgs/:orgId/specialist-change-requestsOrgAdminClient requests different specialist
GET/orgs/:orgId/specialist-change-requestsAMAM views pending requests
PATCH/orgs/:orgId/specialist-change-requests/:idAMAM fulfills or declines request

Superadmin Org Endpoints

MethodPathAuthDescription
POST/organizationsSuperadminCreate org
GET/superadmin/orgsSuperadminList all orgs (legacy — prefer /ops/orgs)
GET/expertsSuperadminList all experts

Admin

MethodPathAuthDescription
GET/admin/membersOrgAdminList org members
POST/admin/members/inviteOrgAdminInvite member
GET/admin/billingOrgAdminOrg billing status
GET/admin/quotaOrgAdminOrg quota usage
POST/admin/impersonate/am/:userIdSuperadminStart silent AM impersonation
DELETE/admin/impersonateSuperadminEnd impersonation session
POST/admin/orgs/:orgId/restoreSuperadminRestore archived stale org

Channels

Inbound Webhooks

MethodPathAuthDescription
POST/channels/slack/eventsHMAC-SHA256Slack Events API webhook
POST/channels/email/inboundNone (Cloudflare)Cloudflare Email Routing inbound webhook
POST/channels/whatsapp/inboundTwilio HMAC-SHA1WhatsApp inbound (Twilio webhook)
POST/channels/teams/webhookBot FrameworkTeams webhook (stub)
GET/channels/wechat/webhookNoneWeChat verification challenge
POST/channels/wechat/webhookWeChat sigWeChat inbound (stub)
POST/channels/telegram/webhookHMAC-SHA256Telegram Bot API updates

Channel Admin

MethodPathAuthDescription
GET/orgs/:orgId/channels/statusOrgAdminHealth status for all channels
GET/orgs/:orgId/channels/webhook-urlsOrgAdminWebhook URLs to configure in channel dashboards

Integration Credentials

MethodPathAuthDescription
POST/orgs/:orgId/integrationsOrgAdminCreate/upsert channel credentials
GET/orgs/:orgId/integrationsOrgAdminList integrations (values masked)
DELETE/orgs/:orgId/integrations/:idOrgAdminDelete integration
POST/orgs/:orgId/integrations/:id/testOrgAdminTest connection

Billing

MethodPathAuthDescription
POST/billing/subscriptionsJWTCreate Stripe subscription
GET/billing/subscriptionsSuperadminList all subscriptions
GET/billing/subscriptions/:orgIdJWTGet org subscription
DELETE/billing/subscriptions/:orgIdSuperadminCancel subscription
POST/billing/webhooksStripe sig (raw body)Stripe webhook handler

Agentic Tasks

MethodPathAuthDescription
POST/agentic/tasksJWTCreate agentic task with step plan
GET/agentic/tasksJWTList tasks by org (filter: status=pending_approval)
GET/agentic/tasks/:idJWTGet task + full plan
POST/agentic/tasks/:id/steps/:stepId/approveExpertApprove a step
POST/agentic/tasks/:id/steps/:stepId/rejectExpertReject step with feedback

Agents

MethodPathAuthDescription
GET/orgs/:orgId/agentsJWTList org agents (filter: role)
POST/orgs/:orgId/agentsOrgAdminCreate agent for org
DELETE/orgs/:orgId/agents/:idOrgAdminRemove agent

Tools

MethodPathAuthDescription
POST/tools/executePLATFORM_API_TOKENInternal: execute tool (shopify_query, amazon_query)
GET/orgs/:orgId/tool-permissionsOrgAdminList enabled tools
PUT/orgs/:orgId/tool-permissions/:toolNameOrgAdminEnable/disable tool with optional config

Analytics

MethodPathAuthDescription
GET/analytics/summaryJWTAggregate analytics (superadmin: all orgs; org: scoped)

Audit Log

MethodPathAuthDescription
GET/audit-logJWTPaginated audit log (filter: from, to, entity_type, limit, cursor)

Learning

MethodPathAuthDescription
GET/learning/correctionsSuperadminList corrections (filter: role)
GET/learning/corrections/statsSuperadminAggregated correction stats by type

Users

MethodPathAuthDescription
GET/users/meJWTCurrent user profile
POST/users/:id/hp-verifyJWTHumanity Protocol credential verification (stub)