Reference
API Reference
REST API endpoints for integrating Hikigai agents into your frontend applications.
Base URL: https://backend.hikigaiplatform.io
From inside a deployed App, call $HIKIGAI_PLATFORM_URL instead (examples for runtime APIs use it). Give browsers $HIKIGAI_PUBLIC_PLATFORM_URL.
Authentication
Every call sends a token as Authorization: Bearer <token>, plus the project as X-Project-ID. Where the token comes from depends on where your code runs:
| Your code runs… | Get the token with | Lasts |
|---|---|---|
| On your computer (while you build) | hikigai login (how) | 6 hours |
| In your deployed App (production) | The SDK, automatically (how) | 5 minutes, renewed |
AppClient() / AgentClient() pick the right token in both places. After hikigai login you can skip the rest of this section.On your computer: hikigai login
Sign in once. The browser opens: pick the project, check the code, click Approve.
hikigai login # Python (comes with hikigai-appsdk / hikigai-agentsdk)
npx @hikigai/app-sdk login # Node.js
hikigai token # print the token, e.g. for curl or Postmancurl -X POST "https://backend.hikigaiplatform.io/api/v1/agents/{agent_id}/invoke" \
-H "Authorization: Bearer $(hikigai token)" \
-H "X-Project-ID: YOUR_PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{"input": "Hello"}'- It works for one project, with your role in it (for example, Testers can call agents but not deploy).
- It ends after 6 hours, on
hikigai logout, or when someone revokes it under CLI logins in the console. Then runhikigai loginagain. - It does not work inside a deployed App. Apps use their own key (below).
In your deployed App
When the platform deploys your App, it sets HIKIGAI_API_KEY, HIKIGAI_PROJECT_ID and HIKIGAI_PLATFORM_URL in it. The SDK swaps the key for a 5-minute token and renews it, so AppClient() with no arguments just works. Without the SDK, get the token yourself:
/api/v1/auth/exchangeGet a 5-minute token for your deployed App. Works only from inside the App.
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/auth/exchange" \
-H "X-API-Key: $HIKIGAI_API_KEY" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID"
# → { "access_token": "eyJ…", "token_type": "Bearer", "expires_in": 300, ... }- Keep the token and get a new one shortly before it expires (for example after 4 minutes), or once after a
401. - Always call
$HIKIGAI_PLATFORM_URL, never a hard-coded address. - The token only works from inside your App; each new deployment gets a new key.
- Never send the key or the token to a browser. Mint a room, speech, media or live token for browsers instead.
Errors
Auth errors come back as {"detail": {"code": "…", "message": "…"}}.
| HTTP | Code | What to do |
|---|---|---|
401 | CLI_SESSION_INVALID | Your hikigai login ended or was revoked. Run hikigai login again. |
403 | CLI_PROJECT_MISMATCH | You are signed in for another project. Run hikigai login --project <id>. |
401 | PROJECT_KEYS_REMOVED | You sent an old project API key (hikigai_uni_…). Use hikigai login instead. |
401 | DEPLOY_KEY_REQUIRED | No valid token. Use hikigai login on your computer, or the App's token in production. |
401 | INVALID_KEY | The App's token is wrong or from an older deployment. Get a new one. |
403 | REQUIRES_ATTESTATION | The exchange was not called from inside your deployed App through HIKIGAI_PLATFORM_URL. |
403 | APP_DEPLOY_REQUIRED / APP_STOPPED | Deploy the App, or resume it. |
403 | KEY_PROJECT_MISMATCH | The token belongs to another project than X-Project-ID. Send the matching project ID. |
403 | PLATFORM_NETWORK_REQUIRED | A runtime call with the App's token came from outside the platform. Call from inside your deployed App. |
403 | CLI_SESSION_NOT_ALLOWED | A hikigai login token was used from inside a deployed App. Apps use their own key. |
429 | RATE_LIMITED | Too many token requests. Keep the token until it is about to expire. |
Agent Deployment
YOUR_TOKEN is $(hikigai token) from your hikigai login. Your role must allow deploying (Owner, Admin, Agentic Developer or Release Engineer).
/api/v1/agents/deployDeploy a new agent with optional MCP connector support.
Request Headers
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
X-Project-ID: YOUR_PROJECT_IDRequest Body
{
"name": "{agent-slug}",
"display_name": "Agent Display Name",
"version": "1.0.0",
"description": "Agent description",
"agent_type": "llm",
"model": "gemini-3.8-flash",
"instruction": "System Role: You are a helpful assistant...",
"timeout": 60,
"input_schema": {
"type": "object",
"properties": {
"message": { "type": "string", "description": "User message" }
},
"required": ["message"]
},
"output_schema": {
"type": "object",
"properties": {
"result": { "type": "string" }
}
},
"mcp_connectors": [
{
"slug": "connector-slug",
"tool_filter": ["*"],
"required": true
}
]
}Choosing model
model is optional. Leave it out and the agent runs on gemini-3.8-flash, a fast, low-cost model that suits most agents. To pick another one, use a name from the Model Registry, or call GET /api/v1/projects/{project_id}/available-models to list the models your project's keys can run.
A model its provider has retired is refused with a 400 whose detail names the model to use instead:
{
"detail": "Model '<old model>' is no longer offered: Google retired it on Vertex AI on October 20, 2026. Use 'gemini-3.8-flash' instead."
}cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents/deploy' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--data '{
"name": "{agent-slug}",
"display_name": "Agent Display Name",
"version": "1.0.0",
"description": "Agent description",
"agent_type": "llm",
"model": "gemini-3.8-flash",
"instruction": "System Role: You are a helpful assistant..."
}'Response
{
"agent_id": "ag_abc123def456",
"name": "cpt2-code-agent-v2",
"slug": "cpt2-code-agent-v2",
"status": "deploying",
"endpoint": null,
"job_id": "job_abc123"
}Deploy is asynchronous. Poll GET /api/v1/agents/{agent_slug} until deployment_status becomes active; the live endpoint is in endpoint_url.
Agent Invocation
Token: in production, the access token your App gets from /auth/exchange; on your computer, the output of hikigai token (hikigai login). Always send X-Project-ID.
Request timeout (optional)
The timeout field is not required. Existing integrations keep working without any changes — if you omit it, the platform uses the agent's deploy-time timeout (console deploys default to 60 seconds; API/SDK deploys default to 30 unless you set one).
Deploying agents is unchanged: you do not need to set timeout at deploy time unless you want a different default for that agent. At invoke time, passtimeoutonly when you need a longer or shorter limit for a specific call (5–300 seconds).
There are two independent timeouts to be aware of:
- Request body (
"timeout": 300) — how long the Hikigai platform waits for the agent to finish processing. - HTTP client (e.g.
requests.post(..., timeout=300)) — how long your application waits for the API response. Set this to match or exceed the body timeout so your app does not give up before the server responds.
This matches SDK behavior: agent.invoke(..., timeout=300) is also optional and uses the same defaults when omitted. Console deploys default the agent timeout to 60 seconds; API/SDK deploy defaults to 30 seconds unless you set timeout at deploy time.
/api/v1/agents/{agent_slug}/invokeInvoke an agent to process a message with optional MCP connector data.
Request Headers
Authorization: Bearer <access_token>
Content-Type: application/json
X-Project-ID: $HIKIGAI_PROJECT_IDRequest Body
{
"input": {
"query": "Show me my blood pressure data for today",
"userId": "android-user-010",
"deviceId": "056ac949aa621795"
},
"timeout": 300,
"connectors": {
"my-ehr-connector": {}
}
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agents/{agent-slug}/invoke" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "X-Project-ID: $HIKIGAI_PROJECT_ID" \
--data '{
"input": {
"message": "Your message here"
},
"timeout": 300
}'Response
{
"output": {
"result": "Based on the health data, the patient shows stable vital signs..."
},
"agent_id": "ag_abc123def456",
"status": "success",
"session_id": "session-123",
"latency_ms": 1250,
"tokens_used": 342,
"request_id": "req_xyz789",
"tools_called": [],
"artifacts": []
}Structured results land in output (parsed against the agent's output schema when possible). status is one of success, partial, failed, or requires_human_review.
Streaming
/api/v1/agents/{agent_slug}/streamStream agent responses via Server-Sent Events (SSE). Useful for real-time UI updates.
Each chunk is one SSE event: it starts with data: and ends with an empty line. A chunk can span several lines (for example JSON output); keep every line up to the empty line together. data: [DONE] ends the stream. The SDKs do this for you.
Request Headers
Authorization: Bearer <access_token>
Content-Type: application/json
Accept: text/event-stream<access_token> is the 5-minute token your deployed App gets from POST /api/v1/auth/exchange (the SDK gets it for you), or from your computer with your hikigai login. Project scope comes from the token — X-Project-ID is not required on this endpoint.
Request Body
{
"input": {
"query": "Your query here",
"userId": "user-id",
"deviceId": "device-id"
},
"timeout": 300,
"connectors": {
"connector-slug": {}
},
"session_id": "session-abc123"
}timeout is optional for streaming as well — see the explanation above.
cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agents/{agent-slug}/stream" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'Content-Type: application/json' \
--header 'Accept: text/event-stream' \
--data '{
"input": {
"query": "Your query here",
"userId": "user-id",
"deviceId": "device-id"
},
"connectors": {
"connector-slug": {}
}
}' \
--no-bufferResponse Format (SSE)
data: Based
data: on
data: the
data: health
data: data
data: [DONE]data: and followed by double newlines. The stream ends with data: [DONE].Agent Warm-up
Optional. Agents set to scale to zero stop after a period without traffic (30 minutes by default), and the next invoke waits while the agent starts, which can take one to four minutes. Warm-up starts agents early so the first real request finds them running. If you never call it, nothing changes: agents still start on the first invoke. A warm-up counts as activity, so an agent nobody invokes goes back to zero after the idle window. The SDKs wrap both endpoints as client.warmup() and client.warmupStatus() (warmup_status() in Python).
/api/v1/agent-warmupStart waking agents. Returns 202 right away; the agents start in the background.
Request Headers
Authorization: Bearer <access_token>
Content-Type: application/json
X-Project-ID: $HIKIGAI_PROJECT_IDSame credentials as invoke: the deployed App's token from POST /api/v1/auth/exchange, or your hikigai login.
Request Body
{
"agent_ids": ["medical-coder", "scribe"]
}agent_ids takes agent IDs, slugs or names (up to 50). Omit it, or send {}, to warm every scale-to-zero agent the project owns or has linked; an empty list warms nothing. Agents outside the project come back as not_found.
cURL Example
curl --location --request POST "$HIKIGAI_PLATFORM_URL/api/v1/agent-warmup" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "X-Project-ID: $HIKIGAI_PROJECT_ID" \
--data '{ "agent_ids": ["medical-coder"] }'Response (202)
{
"agents": [
{
"agent": "medical-coder",
"agent_id": "ag_abc123def456",
"slug": "medical-coder",
"status": "warming",
"job_id": "job_789",
"detail": null
}
]
}Statuses
| Status | Meaning |
|---|---|
warming | The platform is starting the agent |
ready | The agent is running, or is always on |
failed | The warm-up failed; the first invoke cold-starts as usual |
not_applicable | Runtime that is not warmed (for example Lambda, or not deployed) |
not_found | No such agent in this project |
not_requested | Status endpoint only: no warm-up in the last 15 minutes |
Repeated requests are cheap. While a warm-up for an agent is running, or within a minute after it finishes, the platform returns that one instead of starting another.
/api/v1/agent-warmup/statusWarm-up state and live runtime state per agent. Poll this every few seconds to learn when agents are ready.
Query Parameters
agent_ids: comma-separated IDs, slugs or names. Omit it for every scale-to-zero agent of the project.
cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agent-warmup/status?agent_ids=medical-coder,scribe" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "X-Project-ID: $HIKIGAI_PROJECT_ID"Response
{
"agents": [
{ "agent": "medical-coder", "agent_id": "ag_abc123def456", "slug": "medical-coder",
"status": "ready", "job_id": "job_789", "detail": null,
"live_state": "running", "desired_count": 1, "running_count": 1 },
{ "agent": "scribe", "agent_id": "ag_def456ghi789", "slug": "scribe",
"status": "not_requested", "job_id": null, "detail": null,
"live_state": "scaled_to_zero", "desired_count": 0, "running_count": 0 }
]
}Live state
status describes the warm-up request; live_state is what the agent's runtime is doing right now, whether or not a warm-up was requested. A finished warm-up reports ready only while the agent is still running; once it has scaled to zero again (idle rule or an admin), status is not_requested.
| live_state | Meaning |
|---|---|
running | AWS ECS has a running task |
starting | A task is wanted but not running yet |
stopping | The last task is shutting down |
scaled_to_zero | No task wanted and none running; the next request (or a warm-up) starts one |
on_demand | Cloud Run or Lambda: an instance starts per request |
null | Unknown (not deployed, or the state could not be read) |
desired_count and running_count are the ECS task counts (null for other runtimes).
Agent Management
/api/v1/agentsList public, approved agents (the marketplace), with pagination. For your project's agents use GET /api/v1/projects/{project_id}/agents (AgentClient.list_agents() does).
Request Headers
Authorization: Bearer YOUR_TOKEN
X-Project-ID: YOUR_PROJECT_IDQuery Parameters
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
limit | integer | Items per page (default: 20, max: 100) |
Lists public, approved marketplace agents only; no auth needed and the headers are ignored. Filters: category, tags, search, is_featured. For your own project's agents use GET /api/v1/projects/{project_id}/agents.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents?page=1&limit=20' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"agents": [
{
"id": "ag_abc123",
"name": "agent-name",
"slug": "agent-slug",
"description": "Agent description",
"version": "1.2.3",
"deployment_status": "active",
"endpoint_url": "https://....run.app",
"invocation_count": 1542
}
],
"total": 5,
"page": 1,
"limit": 20,
"pages": 1
}/api/v1/agents/{agent_slug}Get details of a specific agent by ID, slug, or name.
Request Headers
Authorization: Bearer YOUR_TOKEN
X-Project-ID: YOUR_PROJECT_IDcURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents/{agent-slug}' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"id": "ag_abc123def456",
"name": "agent-name",
"slug": "agent-slug",
"model": "gemini-3.8-flash",
"instruction": "You are a helpful assistant...",
"description": "Agent description",
"version": "1.2.3",
"agent_type": "llm",
"deployment_status": "active",
"deployment_error": null,
"endpoint_url": "https://....run.app",
"cloud_provider": "gcp",
"invocation_count": 1542,
"created_at": "2026-11-01T10:00:00Z",
"updated_at": "2026-11-18T09:30:00Z",
"deployed_at": "2026-11-18T09:31:12Z"
}/api/v1/agents/{agent_slug}/redeployRedeploy an agent with updated configuration and mcp_connectors. Every redeploy needs a new, higher version.
Request Headers
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
X-Project-ID: YOUR_PROJECT_IDRequest Body
{
"version": "1.2.4",
"instruction": "Updated system prompt",
"model": "gemini-3.8-flash",
"mcp_connectors": [
{
"slug": "connector-slug",
"tool_filter": ["*"],
"required": true
}
]
}version(required) — a SemVer higher than the agent's current version. Missing → 400; the same or a lower version → 409 (the error names the next version to use). Retrying a deploy that never went live may reuse its version.cloud_credential_id/cloud_credential_name(optional) — the cloud account to redeploy with. Omit both to use the project's current account for the agent's cloud (project default, then organization default), not the one saved by the previous deploy. With no account of your own for that cloud the redeploy fails — Hikigai's account is never used.- Every deploy (agents, apps, MCP servers; personal workspaces included) needs your own cloud account and, for agents, your own key for the model's provider (Google, OpenAI, Anthropic or OpenRouter). Missing either returns 400 (or a failed deploy job) naming what to add;
GET /api/v1/cloud/credentialsreportsallow_platform_managed: false.
cURL Example
curl --location --request POST 'https://backend.hikigaiplatform.io/api/v1/agents/{agent-slug}/redeploy' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--data '{
"version": "1.2.4",
"instruction": "Updated system prompt",
"model": "gemini-3.8-flash",
"mcp_connectors": [
{
"slug": "connector-slug",
"tool_filter": ["*"],
"required": true
}
]
}'Response
{
"agent_id": "ag_abc123def456",
"name": "agent-name",
"slug": "agent-slug",
"version": "1.2.4",
"status": "deploying",
"endpoint": "https://....run.app",
"job_id": "job_abc123"
}Redeploy is asynchronous. Poll GET /api/v1/agents/{agent_slug} until deployment_status is active (or failed / error, with the reason in deployment_error).
Account & Usage
Who you are and how much of your plan you have used. These are management routes: call them with a hikigai login token (Authorization: Bearer $(hikigai token)). A deployed App's workload token is refused here with DEPLOY_KEY_REQUIRED.
/api/v1/meThe signed-in developer, the plan tier and the scopes carried by the token.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/me' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"id": "6f1c2a9e-…",
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com",
"company": "Example Health",
"tier": "free",
"scopes": ["agents:read", "agents:invoke", "..."]
}/api/v1/usageToday's (UTC) invocation and agent counts against your workspace plan limits.
Team projects count against the team workspace; personal projects against the caller's personal workspace. The period is the current UTC day.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/usage' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"period_start": "2026-11-19T00:00:00Z",
"period_end": "2026-11-19T23:59:59Z",
"invocations_limit": 50,
"invocations_used": 12,
"agents_limit": 10,
"agents_used": 2
}Agent Discovery & Project Agents
Search, categories and A2A agent cards need no authentication and cover public, approved marketplace agents. The project routes list and delete the agents deployed to one project; they take a hikigai login token for that project (a workload token gets DEPLOY_KEY_NOT_ALLOWED).
/api/v1/agents/searchSearch public, approved marketplace agents by name, description or exact tag. No auth.
Query parameters
q(string, required). Case-insensitive substring of name or description, or an exact tag.category,risk_tier,clinical_domain(optional exact-match filters).limit(int, default10, 1–50). Ordered by request count, highest first.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents/search?q=triage&limit=5'Response
{
"results": [
{
"id": "0b7e…",
"name": "triage-agent",
"slug": "triage-agent",
"description": "Symptom triage",
"category": "clinical",
"developer_name": "Example Health"
}
]
}A missing or empty q returns 422.
/api/v1/agents/categoriesCategories of public, approved agents, with counts. No auth.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents/categories'Response
{
"categories": [
{ "name": "clinical", "count": 12 },
{ "name": "operations", "count": 4 }
]
}/api/v1/agents/{agent_id}/.well-known/agent.jsonA2A Agent Card for a public, approved agent: a machine-readable manifest for agent discovery. Accepts an agent ID or slug. No auth.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/agents/triage-agent/.well-known/agent.json'Response
{
"name": "Triage Agent",
"description": "Symptom triage",
"url": "/api/v1/agents/0b7e…",
"version": "1.2.0",
"clinical_metadata": {
"risk_tier": "low",
"clinical_domain": "primary_care",
"requires_physician_oversight": true,
"fda_clearance_status": null
},
"capabilities": { "streaming": false, "pushNotifications": false, "agent_type": "llm" },
"skills": [],
"input_schema": { "...": "..." },
"output_schema": { "...": "..." },
"provider": { "organization": "Example Health", "developer_id": "6f1c…" },
"security_card": { "signed": false, "issuer": "hikigai-platform" }
}404 "Agent not found" when no public, approved agent matches.
/api/v1/projects/{project_id}/agentsThe agents deployed to a project, newest first. Requires agents:read. Used by list_agents() / listAgents().
Query parameters
include_linked(bool, defaultfalse): also return marketplace agents linked to the project (source: "marketplace").
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/<project_id>/agents' \
--header "Authorization: Bearer $(hikigai token)"Response (abridged)
[
{
"id": "0b7e…",
"name": "triage-agent",
"display_name": "Triage Agent",
"slug": "triage-agent",
"model": "gemini-3.8-flash",
"agent_type": "llm",
"input_modality": "text",
"output_modality": "text",
"deployment_status": "active",
"deployment_error": null,
"version": "1.2.0",
"cloud_provider": "gcp",
"cloud_service": "cloud_run",
"endpoint_url": "https://…",
"request_count": 120,
"created_at": "2026-11-01T10:00:00Z",
"deployed_at": "2026-11-01T10:04:00Z",
"source": "deployed"
}
]403 not a member of the project, or missing agents:read. A CLI login for another project gets 403 CLI_PROJECT_MISMATCH.
/api/v1/projects/{project_id}/available-modelsThe models this project can deploy with its keys and cloud accounts. Requires agents:read. The console's model pickers use it.
For Google, OpenAI and Anthropic the key is found the same way deploy and invoke find it (your own key in the project, then the organization's), and that provider's model list says which registry models the key serves. A Google Cloud account on the project or organization makes Gemini available on Vertex AI without a key. Answers are cached per key for 6 hours. When a provider can't be asked, its registry models are listed with verified: false. Keys are never returned.
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/<project_id>/available-models' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"models": [
{ "name": "gemini-3.8-flash", "provider": "google", "live": false, "source": "org", "verified": true },
{ "name": "claude-sonnet-5-5", "provider": "anthropic", "live": false, "source": "member", "verified": true }
],
"default_model": "gemini-3.8-flash", // DEFAULT_MODEL when offered, else the first non-live model
"providers": {
"google": { "key_source": "org", "verified": true },
"openai": { "key_source": null, "verified": false },
"anthropic": { "key_source": "member", "verified": true },
"vertex": { "key_source": null, "verified": false }
}
}source is member, org or gcp_account. An empty models list means no key or cloud account can run any model yet. 403 without agents:read in the project.
/api/v1/projects/{project_id}/agents/{agent_id}Delete a project's agent: tears down its cloud resources, then removes it. Used by delete_agent() / deleteAgent().
agent_id must be the agent's UUID (the SDKs resolve a slug first). You need agents:delete, or agents:delete_own for agents you deployed. Subscribers receive an agent.deleted event.
cURL Example
curl --location --request DELETE 'https://backend.hikigaiplatform.io/api/v1/projects/<project_id>/agents/<agent_id>' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"message": "Agent deleted successfully",
"agent_id": "0b7e…"
}404 not in this project · 403 no permission to delete this agent · 502 cloud teardown failed (the agent is kept, so retry).
Realtime
Publish tokens let a device or browser push one audio/video/text stream to an agent through a media edge (WHIP/RTSP). The events WebSocket pushes your project's platform events to you as they happen. HTTP routes take a workload token (Authorization: Bearer <workload_token> + X-Project-ID) or a hikigai login token.
/api/v1/realtime/publish-tokensMint a single-use, single-stream publish credential for one agent, plus ICE servers.
Request body
agent_id(string, required): agent ID, slug or name, owned by or linked to your project.modalities(string[], default["audio"]): any ofaudio,video,text.principal_type(developer|device, defaultdeveloper).device_id(string): required whenprincipal_typeisdevice; the principal becomesdevice:<device_id>.ttl_seconds(int, 30–900, default 900): never longer than the credential that minted it;expires_inreports the actual value.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/realtime/publish-tokens' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: <project_id>' \
--header 'Content-Type: application/json' \
--data '{
"agent_id": "triage-agent",
"modalities": ["audio", "video"],
"principal_type": "device",
"device_id": "cam-0042",
"ttl_seconds": 300
}'Response
{
"publish_token": "eyJhbGciOi…",
"stream_id": "3d1f…",
"expires_in": 300,
"ice_servers": [
{ "urls": ["stun:stun.l.google.com:19302"] },
{ "urls": ["turn:turn.example.com:3478"], "username": "…", "credential": "…" }
]
}400 unsupported modality or missing device_id · 404 agent not found · 503 realtime relay temporarily unavailable.
/api/v1/realtime/publish-tokens/validateAuth webhook for a media server (e.g. MediaMTX): validates and consumes a publish token. No auth.
Single use: a second call with the same token fails. Call it once per publish attempt, from the media edge, not from your client.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/realtime/publish-tokens/validate' \
--header 'Content-Type: application/json' \
--data '{ "publish_token": "eyJhbGciOi…" }'Response
{
"valid": true,
"principal": "device:cam-0042",
"principal_type": "device",
"agent_id": "0b7e…",
"project_id": "a12c…",
"stream_id": "3d1f…",
"modalities": ["audio", "video"]
}401 invalid, expired or already-used publish token.
/api/v1/realtime/streamsNumber of realtime streams active right now in your project.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/realtime/streams' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: <project_id>'Response
{ "active_streams": { "a12c…": 3 } }By default a project may run at most 10 streams at once, each up to 3600 seconds.
/api/v1/events/wsLive push of your project's platform events (CloudEvents 1.0). Wrapped by events.stream(patterns) in AppSDK, AgentSDK and the Node SDKs.
Send the first frame within 10 seconds. It must be auth with access_token (a workload token or $(hikigai token)) or api_key (a Deploy key); project_id is optional but must match the credential when sent. patterns are glob patterns (up to 20, default ["*"]); a subscribe frame replaces them. Delivery is at-most-once: each connection queues up to 500 events and drops the oldest when full. A project may hold 50 connections at once.
Frames
// connect
wss://backend.hikigaiplatform.io/api/v1/events/ws
C→S {"type":"auth","access_token":"<workload_token>","project_id":"<project_id>","patterns":["agent.*","job.*"]}
S→C {"type":"ready","project_id":"<project_id>","patterns":["agent.*","job.*"]}
C→S {"type":"subscribe","patterns":["storage.*"]} // replaces patterns; answered with "ready"
C→S {"type":"ping"} // → {"type":"pong"}
C→S {"type":"disconnect"}
S→C {"type":"event","event":{
"specversion":"1.0",
"id":"9b2e…",
"source":"//hikigai/platform-backend",
"type":"agent.deleted",
"time":"2026-11-19T10:00:00+00:00",
"datacontenttype":"application/json",
"subject":"0b7e…",
"projectid":"a12c…",
"data":{"agent_id":"0b7e…","project_id":"a12c…","agent_name":"triage-agent","slug":"triage-agent"}
}}
S→C {"type":"error","code":"connection_cap_exceeded","message":"…"} // then close 1013Python (AppSDK)
async with client.events.stream(["agent.*", "job.*"]) as stream:
async for event in stream:
print(event["type"], event["data"])Close codes: 1008 auth or policy (timeout, bad first frame, invalid token or key, project mismatch, not a member) · 1013 too many connections. A console session token is refused.
End-User Identity
Give your app's end users — clinicians, patients, staff — their own signup, login, multi-factor auth, QR badge login, and single sign-on. Each app gets a dedicated AWS Cognito user pool that the platform provisions and runs for you, so you never touch AWS. Login returns standard OIDC tokens (ID, access, refresh).
managed keeps users in Hikigai's Cognito (zero setup). byo (bring-your-own) keeps them in your own AWS account, which the platform reaches through a cross-account IAM role you create.Base path: /api/v1/identity
Auth (server / SDK): these are runtime routes. Call them from inside a deployed App with the workload token the SDK obtains from POST /api/v1/auth/exchange: Authorization: Bearer <workload_token>, X-Project-ID: YOUR_PROJECT_ID and User-Agent: hikigai-sdk/… (only checked for raw keys; workload and hikigai login tokens work with any user agent). The AppSDK sends all three for you. From your computer, use your hikigai login token instead.
Auth (manual exchange): POST $HIKIGAI_PLATFORM_URL/api/v1/auth/exchange with the App's X-API-Key and X-Project-ID returns the workload token (5 minutes); then send Authorization: Bearer <workload_token> plus X-Project-ID on subsequent calls.
Scopes
Each endpoint requires one scope on the workload token. End users hitting auth endpoints from your app use invoke; one-time setup uses manage / read.
| Scope | Used by | Endpoints |
|---|---|---|
invoke | Your app, per end user | signup, confirm, login, refresh, logout, forgot-password, reset-password, change-password, MFA, SSO sign-in, QR login |
manage | Setup & admin | enable, configure SSO, issue QR badge, BYO test, update end-user profile (role, etc.), disable MFA |
read | Setup & admin | get config, BYO setup |
Typical integration flow
Every call below uses the same three headers (see each endpoint for full cURL). Replace YOUR_PROJECT_ID, YOUR_APP_ID, and <workload_token> (the 5-minute access token your deployed App gets from POST /api/v1/auth/exchange).
# 0. Check pool is active
GET /api/v1/identity/apps/YOUR_APP_ID
# 1. Sign up an end user
POST /api/v1/identity/signup
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com", "password": "Temp#Pass2026", "first_name": "Asha", "last_name": "Mehta", "role": "clinician", "attributes": { "phone_number": "+14155552671" }, "metadata": { "doctorID": "6278383837" } }
# 1b. Confirm (if the pool requires email verification)
POST /api/v1/identity/confirm
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com", "code": "123456" }
# 2. Log in → OIDC tokens (or MFA challenge)
POST /api/v1/identity/login
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com", "password": "Temp#Pass2026" }
# 2b. If login returns "status": "challenge", finish with:
POST /api/v1/identity/mfa/respond
{ "app_id": "YOUR_APP_ID", "email": "...", "session": "...", "code": "482913" }
# 3. MFA enrollment (uses access_token from login)
POST /api/v1/identity/mfa/associate → secret_code
POST /api/v1/identity/mfa/verify → { "status": "SUCCESS" }
POST /api/v1/identity/mfa/set-preference → { "enabled": true }
# 4. QR badge (admin issues, kiosk exchanges)
POST /api/v1/identity/apps/YOUR_APP_ID/users/clinician%40hospital.com/qr-login
POST /api/v1/identity/qr-login
{ "app_id": "YOUR_APP_ID", "qr_payload": "HKG2...." }
# Session maintenance
POST /api/v1/identity/refresh → { "refresh_token": "..." }
POST /api/v1/identity/logout → { "email": "..." }
# Forgot password (Cognito emails a verification code)
POST /api/v1/identity/forgot-password
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com" }
POST /api/v1/identity/reset-password
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com", "code": "123456", "new_password": "NewTemp#Pass2026" }
# Change password (user is logged in — uses access_token from login)
POST /api/v1/identity/change-password
{ "app_id": "YOUR_APP_ID", "access_token": "...", "current_password": "...", "new_password": "..." }
# Update profile / role (Cognito — path may be email or Cognito sub; app_id required)
PATCH /api/v1/end-users/clinician%40hospital.com?app_id=YOUR_APP_ID
{ "role": "doctor", "first_name": "Asha", "last_name": "Mehta" }
# Runtime verification (apps — Cognito/GCP source of truth)
POST /api/v1/identity/verify-qr
{ "app_id": "YOUR_APP_ID", "qr_payload": "HKG2...." }
POST /api/v1/identity/verify-pin
{ "app_id": "YOUR_APP_ID", "email": "clinician@hospital.com", "pin": "123456" }
POST /api/v1/identity/verify-sso
{ "app_id": "YOUR_APP_ID", "token": "eyJraWQiOi..." }
# The signed-in user's own data (user taken from the ID token)
POST /api/v1/identity/me/metadata
{ "app_id": "YOUR_APP_ID", "token": "eyJraWQiOi...", "user_data": { "preferences": { "units": "metric" } } }
POST /api/v1/identity/me/secrets/set (also /get, /delete)
{ "app_id": "YOUR_APP_ID", "token": "eyJraWQiOi...", "name": "partner.session", "value": "...", "expires_in_seconds": 3600 }
# Get one user's detail (console path — profile + Cognito status)
GET /api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/identity/users/clinician%40hospital.com# Shared headers for every curl (from inside the deployed App):
curl ... \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ ... }'Setup & status
/api/v1/identity/apps/{app_id}/enableProvision the app's Cognito user pool. Run this once per app. Returns immediately with status 'provisioning' or 'active'.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"mode": "managed", // "managed" or "byo"
"enabled_methods": ["password", "mfa", "qr", "sso"],
"byo_role_arn": null, // required when mode = "byo"
"byo_account_id": null
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/apps/YOUR_APP_ID/enable" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "mode": "managed", "enabled_methods": ["password", "mfa", "qr"] }'Response
{
"app_id": "app_123",
"project_id": "proj_123",
"mode": "managed",
"status": "active",
"cognito_pool_id": "us-east-2_aBcD1234",
"cognito_client_id": "1h57kf5a2...",
"cognito_region": "us-east-2",
"enabled_methods": ["password", "mfa", "qr"],
"error_message": null
}/api/v1/identity/apps/{app_id}Get the app's identity config and provisioning status.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/apps/YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response
{
"app_id": "app_123",
"project_id": "proj_123",
"mode": "managed",
"status": "active",
"cognito_pool_id": "us-east-2_aBcD1234",
"cognito_client_id": "1h57kf5a2...",
"cognito_region": "us-east-2",
"enabled_methods": ["password", "mfa", "qr"],
"error_message": null
}End-user accounts
Console management path: /api/v1/projects/{project_id}/apps/{app_id}/identity
Permissions: apps:read to list users; apps:update to create, import, or delete.
Auth: a console session, or your hikigai login token (Authorization: Bearer $(hikigai token)) for that project (these are console / management routes).
/api/v1/projects/{project_id}/apps/{app_id}/identity/usersList end users registered in the app's Cognito pool. Used by the Developer Console User Management tab.
Request Headers
Authorization: Bearer YOUR_TOKENQuery Parameters
| Parameter | Default | Description |
|---|---|---|
limit | 50 | Max 200 per page |
offset | 0 | Pagination offset |
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/identity/users' \
--header 'Authorization: Bearer YOUR_TOKEN'Response
{
"users": [
{
"id": "a1b2c3d4-....",
"project_id": "proj_123",
"first_name": "Asha",
"last_name": "Mehta",
"email": "clinician@hospital.com",
"role": "clinician",
"external_subject": "a1b2c3d4-....",
"is_active": true,
"qr_issued": false,
"metadata": { "doctorID": "6278383837" },
"created_at": "2026-06-11T12:00:00Z",
"last_verified_at": null
}
]
}id and external_subject are the Cognito subject (sub / user_sub) — the same value as the sub claim in the login id_token. Names, role, and metadata come from Cognito attributes (given_name, family_name, custom:role, custom:metadata). Prefer email as the stable handle in SDK/admin paths./api/v1/identity/signupRegister a new end user in the app's pool. If the pool requires confirmation, follow with /identity/confirm; otherwise the user can log in right away.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"password": "Temp#Pass2026",
"first_name": "Asha", // optional
"last_name": "Mehta", // optional
"role": "clinician", // optional — app-domain role (Cognito custom:role)
"attributes": { // optional — Cognito user attributes (string values)
"phone_number": "+14155552671" // E.164 format; other Cognito attrs also allowed
},
"metadata": { "doctorID": "6278383837" } // optional — opaque app JSON → custom:metadata
}attributes— Cognito profile fields. Values must be strings. Keys must be Cognito attributes (or custom attributes defined on the pool), e.g.phone_number,given_name,custom:…. Unknown keys can cause Cognito to reject signup.metadata— opaque app-specific JSON object (any shape). Stored on Cognito ascustom:metadata(JSON string, max 2048 chars; GCP BYO uses custom claims). Use for things likedoctorID, clinic id, flags — not for Cognito identity fields like phone.
attributes, not metadata:{ "attributes": { "phone_number": "+14155552671" } }+ and country code). It is stored in Cognito and returned under cognito.phone_number on GET …/identity/users/{email}.role is stored on Cognito as custom:role (e.g. clinician, nurse, doctor). Pass it as a top-level field or inside attributes as role / custom:role (those keys are mapped to custom:role). To change role later, use PATCH /api/v1/end-users/{email}?app_id=… or the console PATCH …/identity/users/{email} path.metadata is an optional JSON object — pass any keys/values your app needs (e.g. doctorID, clinic id, flags). It is not for Cognito attributes like phone. Stored as Cognito custom:metadata (JSON string, max 2048 chars). Returned by the users list and GET .../identity/users/{email}. Update later via PATCH /api/v1/end-users/{email}?app_id=….cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/signup" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com",
"password": "Temp#Pass2026",
"first_name": "Asha",
"last_name": "Mehta",
"role": "clinician",
"attributes": { "phone_number": "+14155552671" },
"metadata": { "doctorID": "6278383837" }
}'Response (201)
{
"user_sub": "a1b2c3d4-....", // Cognito subject (sub); may be null until confirmed
"user_id": "a1b2c3d4-....", // same as user_sub (Cognito sub)
"email": "clinician@hospital.com",
"confirmed": false
}user_id and user_sub are both the Cognito subject. Prefer email as the handle for management APIs. user_sub may be null until the account is confirmed (auto-confirm pools return it right away). The same ids are returned by /identity/login and the users list./api/v1/identity/confirmConfirm a signup with the code emailed to the user.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"code": "123456"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/confirm" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com",
"code": "123456"
}'Response (200)
{
"success": true,
"message": "Account confirmed"
}/api/v1/identity/loginAuthenticate an end user. Returns OIDC tokens, or an MFA challenge if multi-factor is required.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"password": "Temp#Pass2026"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/login" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com",
"password": "Temp#Pass2026"
}'Response — success
{
"status": "authenticated",
"id_token": "eyJraWQiOi...",
"access_token": "eyJraWQiOi...",
"refresh_token": "eyJjdHkiOi...",
"expires_in": 3600,
"token_type": "Bearer",
"user_sub": "a1b2c3d4-....", // Cognito subject (same as the id_token 'sub' claim)
"user_id": "a1b2c3d4-...." // same as user_sub
}user_sub and user_id are the Cognito subject (equal to the sub claim inside the id_token). Prefer email for management APIs. They are only present when status is authenticated.Response — MFA required
{
"status": "challenge",
"challenge_name": "SOFTWARE_TOKEN_MFA",
"session": "AYABeF..."
}status is challenge or challenge_name is present, collect the user's TOTP code and call POST /api/v1/identity/mfa/respond with the returned session to finish the login and receive tokens./api/v1/identity/refreshExchange a refresh token for fresh access and ID tokens.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"refresh_token": "eyJjdHkiOi..."
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/refresh" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"refresh_token": "eyJjdHkiOi..."
}'Response
{
"status": "authenticated",
"id_token": "eyJraWQiOi...",
"access_token": "eyJraWQiOi...",
"refresh_token": "eyJjdHkiOi...",
"expires_in": 3600,
"token_type": "Bearer"
}/api/v1/identity/logoutGlobally sign the user out, revoking their refresh tokens.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/logout" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com"
}'Response
{
"success": true,
"message": "Logged out"
}Password management
Reset a forgotten password via email verification code (sent by Cognito), or change the password when the user is already logged in. All three endpoints require the invoke scope.
/api/v1/identity/forgot-passwordRequest a password-reset verification code. Cognito emails the code to the user if the account exists. Does not change the password yet.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/forgot-password" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com"
}'Response (200)
{
"success": true,
"message": "If an account exists for this email, a password reset code has been sent."
}POST /api/v1/identity/reset-password once the user enters the code./api/v1/identity/reset-passwordSet a new password using the verification code from the forgot-password email.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"code": "123456",
"new_password": "NewTemp#Pass2026"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/reset-password" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com",
"code": "123456",
"new_password": "NewTemp#Pass2026"
}'Response (200)
{
"success": true,
"message": "Password reset successfully"
}/api/v1/identity/change-passwordChange password for a logged-in user who knows their current password. Requires the access_token from login.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"current_password": "Temp#Pass2026",
"new_password": "NewTemp#Pass2026"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/change-password" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"current_password": "Temp#Pass2026",
"new_password": "NewTemp#Pass2026"
}'Response (200)
{
"success": true,
"message": "Password changed successfully"
}Multi-factor auth (TOTP)
Enroll a user's authenticator app, then require it at login. The associate step returns a secret you render as an otpauth:// QR code for Google Authenticator, Authy, etc.
Typical enroll flow: POST /identity/login (user password) → POST /identity/mfa/associate → render QR → POST /identity/mfa/verify → POST /identity/mfa/set-preference with enabled: true.
Admin disable: POST /api/v1/end-users/{email}/mfa/disable?app_id=… (manage scope) when the user cannot sign in to turn MFA off themselves.
/api/v1/identity/mfa/associateBegin TOTP enrollment for a signed-in user. Returns the shared secret to display as a QR code.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"access_token": "eyJraWQiOi..." // from login
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/mfa/associate" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"access_token": "eyJraWQiOi..."
}'Response
{
"secret_code": "JBSWY3DPEHPK3PXP",
"session": null
}/api/v1/identity/mfa/verifyVerify the first TOTP code to finish enrollment.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"code": "482913",
"device_name": "iPhone Authenticator" // optional
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/mfa/verify" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"code": "482913",
"device_name": "iPhone Authenticator"
}'Response
{
"status": "SUCCESS"
}/api/v1/identity/mfa/set-preferenceTurn TOTP MFA on or off for a user.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"enabled": true
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/mfa/set-preference" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"access_token": "eyJraWQiOi...",
"enabled": true
}'Response
{
"success": true,
"message": "MFA preference updated"
}/api/v1/identity/mfa/respondComplete a login that returned an MFA challenge. Returns OIDC tokens.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"session": "AYABeF...", // from the login challenge
"code": "482913"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/mfa/respond" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"email": "clinician@hospital.com",
"session": "AYABeF...",
"code": "482913"
}'Response
{
"status": "authenticated",
"id_token": "eyJraWQiOi...",
"access_token": "eyJraWQiOi...",
"refresh_token": "eyJjdHkiOi...",
"expires_in": 3600,
"token_type": "Bearer"
}QR badge login
Issue a per-user QR credential a clinician can scan to sign in without typing a password — ideal for shared workstations. Issue the badge once (admin), then exchange a scanned payload for tokens at the kiosk.
/api/v1/identity/apps/{app_id}/users/{email}/qr-loginIssue a QR badge credential for a user. No request body — email is in the path (URL-encode @ as %40). The payload is shown once — encode it into the badge.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1cURL Example
curl --location --request POST "$HIKIGAI_PLATFORM_URL/api/v1/identity/apps/YOUR_APP_ID/users/clinician%40hospital.com/qr-login" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response (201)
Returns qr_payload and qr_code_png_base64. May also return 200 on re-issue.
{
"credential_id": "qr-version-uuid",
"end_user_id": "a1b2c3d4-....",
"email": "clinician@hospital.com",
"qr_payload": "HKG2....",
"qr_code_png_base64": "iVBORw0KGgo..."
}/api/v1/identity/qr-code/renderRender a qr_payload (or any text) as a PNG QR image. Returns image/png.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{ "data": "HKG2...." }cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/qr-code/render" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "data": "HKG2...." }' \
-o badge-qr.pngResponse (200)
Binary PNG image (Content-Type: image/png).
/api/v1/identity/qr-loginExchange a scanned QR payload for OIDC tokens.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"qr_payload": "HKG2...."
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/qr-login" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"qr_payload": "HKG2...."
}'Response
{
"status": "authenticated",
"id_token": "eyJraWQiOi...",
"access_token": "eyJraWQiOi...",
"refresh_token": "eyJjdHkiOi...",
"expires_in": 3600,
"token_type": "Bearer"
}End-user profile & role
Cognito (or GCP Identity Platform) is the source of truth for end-user profile data. Fetch or update role, name, metadata, phone, and active status. Email is immutable — it is the Cognito login identity.
Console path (by email): GET /api/v1/projects/{project_id}/apps/{app_id}/identity/users/{email} — full detail including live Cognito status. Auth: Bearer; permission apps:read.
SDK path: GET or PATCH /api/v1/end-users/{email_or_sub}?app_id=… —app_id is required. Path may be the user's email or Cognito sub. Auth: SDK headers; scopes read (GET) or manage (PATCH). Do not use POST /api/v1/end-users to create users — use POST /api/v1/identity/signup.
/api/v1/projects/{project_id}/apps/{app_id}/identity/users/{email}Get full detail for one end user by email from Cognito/GCP (names, role, metadata) plus live pool status (MFA, enabled, email verified).
Request Headers
Authorization: Bearer YOUR_TOKEN
Content-Type: application/jsonPath Parameters
project_id, app_id — your project and app ids.email — the end user's email (URL-encode @, e.g. test1%40gmail.com).
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/identity/users/test1%40gmail.com' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json'Response
{
"id": "a1b2c3d4-....",
"email": "test1@gmail.com",
"first_name": "Asha",
"last_name": "Mehta",
"role": "clinician",
"is_active": true,
"external_subject": "a1b2c3d4-....",
"qr_issued": false,
"created_at": "2026-06-11T12:00:00Z",
"last_login_at": null,
"metadata": { "doctorID": "6278383837" },
"cognito": {
"user_sub": "a1b2c3d4-....",
"status": "CONFIRMED",
"enabled": true,
"email_verified": true,
"mfa_enabled": false,
"mfa_methods": [],
"preferred_mfa": null,
"created_at": "2026-06-11T12:00:00Z",
"last_modified_at": "2026-06-12T08:30:00Z",
"phone_number": "+14155552671",
"metadata": { "doctorID": "6278383837" }
}
}given_name, family_name, custom:role, custom:metadata). The cognito object is live pool status. Phone from signup attributes appears under cognito.phone_number./api/v1/end-users/{email_or_sub}?app_id=Get an end user's Cognito profile by email or Cognito sub (SDK path). Query param app_id is required.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1Path & query
email_or_sub — user email or Cognito sub (URL-encode email).app_id (query, required) — app whose Cognito/GCP pool to use.
cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/end-users/clinician%40hospital.com?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response (200)
{
"id": "a1b2c3d4-....",
"project_id": "proj_123",
"first_name": "Asha",
"last_name": "Mehta",
"email": "clinician@hospital.com",
"role": "clinician",
"external_subject": "a1b2c3d4-....",
"is_active": true,
"qr_issued": false,
"metadata": { "doctorID": "6278383837" },
"created_at": "2026-06-11T12:00:00Z",
"last_verified_at": null
}/api/v1/end-users/{email_or_sub}?app_id=Update an end user's Cognito profile. All body fields are optional. Email cannot be updated. Query param app_id is required.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonPath & query
email_or_sub — user email or Cognito sub.app_id (query, required).
Request Body
{
"role": "doctor", // optional — Cognito custom:role
"first_name": "Asha", // optional — given_name
"last_name": "Mehta", // optional — family_name
"phone_number": "+14155552671", // optional — Cognito attribute (E.164); "" clears
"metadata": { "department": "cardiology" }, // optional — replaces custom:metadata
"is_active": true // optional — enable/disable in Cognito
}cURL Example
curl --location --request PATCH "$HIKIGAI_PLATFORM_URL/api/v1/end-users/clinician%40hospital.com?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"role": "doctor"
}'Response (200)
{
"id": "a1b2c3d4-....",
"project_id": "proj_123",
"first_name": "Asha",
"last_name": "Mehta",
"email": "clinician@hospital.com",
"role": "doctor",
"external_subject": "a1b2c3d4-....",
"is_active": true,
"qr_issued": false,
"metadata": null,
"created_at": "2026-06-11T12:00:00Z",
"last_verified_at": null
}email, external_subject, password, and ids cannot be changed here. Sending them returns 422. To change a login email, create a new account (or delete + recreate). Use the password endpoints to change passwords. phone_number updates the Cognito attribute (E.164, e.g. +14155552671); send an empty string to clear it./api/v1/end-users/{email_or_sub}/mfa/disable?app_id=Admin-disable TOTP MFA for an end user (manage scope). Requires app_id query. Unlike POST /identity/mfa/set-preference, this does not require the user's access token.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonPath & query
email_or_sub — user email or Cognito sub.app_id (query, required).
cURL Example
curl --location --request POST "$HIKIGAI_PLATFORM_URL/api/v1/end-users/clinician%40hospital.com/mfa/disable?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response (200)
{ "success": true, "message": "MFA disabled" }QR & PIN credentials (Cognito-backed)
QR badges and PINs live on the app's Cognito user (custom attributes / QR v2), not a separate DB table. Base path: /api/v1/end-users with required app_id query (or use /identity/apps/{app_id}/users/{email}/qr-login and …/pin).
Auth: Authorization: Bearer <workload_token>, X-Project-ID, User-Agent: hikigai-sdk/… from inside your deployed App (same as the other identity routes).
Scopes: read to list; manage to issue, rotate, or revoke.
Verify at runtime: POST /api/v1/identity/verify-qr, verify-pin, verify-sso — each requires app_id in the body.
/api/v1/end-users/{email_or_sub}/credentials?app_id=List synthesized credential metadata from Cognito (QR version id and/or pin). app_id query required.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1Path & query
email_or_sub — user email or Cognito sub.app_id (query, required).
cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/end-users/clinician%40hospital.com/credentials?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response
{
"credentials": [
{
"id": "qr-version-uuid",
"end_user_id": "a1b2c3d4-....",
"credential_type": "qr",
"status": "active",
"issued_at": "2026-06-11T12:00:00Z",
"expires_at": null,
"last_used_at": null
},
{
"id": "pin",
"end_user_id": "a1b2c3d4-....",
"credential_type": "pin",
"status": "active",
"issued_at": null,
"expires_at": null,
"last_used_at": null
}
]
}CREDENTIAL_ID: the id field on each object (QR version uuid, or pin). Also returned as credential_id from issue/rotate QR responses./api/v1/end-users/{email_or_sub}/credentials/{credential_id}?app_id=Revoke a Cognito QR badge (rotates version) or clear PIN hash. app_id query required.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1Path & query
email_or_sub — user email or Cognito sub.credential_id — from list credentials (credentials[].id).app_id (query, required).
cURL Example
curl --location --request DELETE "$HIKIGAI_PLATFORM_URL/api/v1/end-users/clinician%40hospital.com/credentials/CREDENTIAL_ID?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response
{
"success": true,
"message": "Credential revoked"
}Runtime verification (QR / PIN / SSO)
Apps verify clinicians through the platform against the app's Cognito pool. Every verify call requires app_id. Scope: invoke.
/api/v1/identity/verify-qrVerify a scanned HKG2 QR badge against the app's Cognito pool.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"qr_payload": "HKG2...."
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/verify-qr" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "app_id": "app_123", "qr_payload": "HKG2...." }'Response (200)
{
"end_user_id": "a1b2c3d4-....",
"project_id": "proj_123",
"first_name": "Asha",
"last_name": "Mehta",
"role": "clinician",
"method": "qr",
"verified_at": "2026-06-12T08:30:00Z",
"metadata": { "doctorID": "6278383837" }
}/api/v1/identity/verify-pinVerify an end user's PIN stored on Cognito (custom:pin_hash).
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"email": "clinician@hospital.com",
"pin": "123456"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/verify-pin" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "app_id": "app_123", "email": "clinician@hospital.com", "pin": "123456" }'/api/v1/identity/verify-ssoVerify an SSO id token against the app's Cognito pool.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"token": "eyJraWQiOi..."
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/verify-sso" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "app_id": "app_123", "token": "eyJraWQiOi..." }'The signed-in user's own data
Your server acts for a signed-in user by passing their ID token as token. The user is always the one the token belongs to (401 if it does not verify), so a user can only change themselves. Scope: invoke. Phones use the same features through the gateway (/v1/auth/me/metadata, /v1/auth/secrets/*).
/api/v1/identity/me/metadataThe signed-in user updates their own metadata.user_data. Keys are set, null removes a key, other user_data keys are kept; the rest of metadata stays admin-only.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"token": "eyJraWQiOi...",
"user_data": { "preferences": { "units": "metric" }, "old_key": null }
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/me/metadata" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{ "app_id": "app_123", "token": "eyJraWQiOi...", "user_data": { "preferences": { "units": "metric" } } }'Response (200)
{
"end_user_id": "a1b2c3d4-....",
"project_id": "proj_123",
"first_name": "Asha",
"last_name": "Mehta",
"role": "clinician",
"method": "sso",
"verified_at": "2026-06-12T08:30:00Z",
"metadata": { "doctorID": "6278383837", "user_data": { "preferences": { "units": "metric" } } }
}At most 50 keys per call, key names 1–64 characters, unknown body fields 422. The whole metadata must stay within 2048 characters (400 otherwise).
/api/v1/identity/me/secrets/setKeep a short-lived private value for the signed-in user (kept encrypted on the user's own record; never in metadata or tokens, and the console never shows the value). Also /get and /delete.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"token": "eyJraWQiOi...",
"name": "partner.session",
"value": "...",
"expires_in_seconds": 3600
}Responses
POST /api/v1/identity/me/secrets/set → 200 { "name": "partner.session", "expires_at": "2026-11-11T13:00:00+00:00" }
POST /api/v1/identity/me/secrets/get { "app_id", "token", "name" }
→ 200 { "name": "partner.session", "value": "...", "expires_at": "..." }
→ 404 NOT_FOUND (none, or it expired)
POST /api/v1/identity/me/secrets/delete { "app_id", "token", "name" }
→ 200 { "success": true } (also when there was none)Returned only to the same user of the same app until it expires. Values are kept encrypted on the user's own Cognito record in a hidden attribute that the app cannot read, so they never appear in ID tokens. Names match ^[a-z0-9][a-z0-9_.-]{0,63}$ and expires_in_seconds is 60–86400 (default 3600). All of one user's values together must stay under roughly 1,400 characters (a 1,052-character token with an id and a URL fits); a set that does not fit gets 400 and the earlier values stay. Expired values are dropped automatically, and deleting the user deletes them. Not available when the App's users are in GCP Identity Platform (400).
In the console, User Management shows a user's secrets by name and expiry only, and admins can add or remove one: GET …/identity/users/{email}/secrets (apps:read) → {"secrets":[{"name","expires_at"}]}, POST …/identity/users/{email}/secrets (apps:update) {name, value, expires_in_seconds} → 201 {name, expires_at}, and DELETE …/identity/users/{email}/secrets/{name} (apps:update), under /api/v1/projects/{project_id}/apps/{app_id}. Values are never returned there.
Single sign-on & social
Let users sign in with Google, Apple, Okta, Azure AD, SAML, or any OIDC provider. Configure the provider once, then run the standard authorize-redirect / code-exchange flow.
/api/v1/identity/apps/{app_id}/ssoAdd or update an SSO / social provider on the app's pool.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"provider_name": "Google",
"provider_type": "Google",
"provider_details": {
"client_id": "...",
"client_secret": "...",
"authorize_scopes": "openid email profile"
},
"callback_urls": ["https://yourapp.com/auth/callback"],
"attribute_mapping": { "email": "email" },
"scopes": ["openid", "email", "profile"]
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/apps/YOUR_APP_ID/sso" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"provider_name": "Google",
"provider_type": "Google",
"provider_details": {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"authorize_scopes": "openid email profile"
},
"callback_urls": ["https://yourapp.com/auth/callback"],
"attribute_mapping": { "email": "email" },
"scopes": ["openid", "email", "profile"]
}'Response
{
"app_id": "app_123",
"project_id": "proj_123",
"mode": "managed",
"status": "active",
"cognito_pool_id": "us-east-2_aBcD1234",
"cognito_client_id": "1h57kf5a2...",
"cognito_region": "us-east-2",
"enabled_methods": ["password", "mfa", "qr", "sso"],
"error_message": null
}/api/v1/identity/sso/authorize-urlBuild the hosted-UI authorize URL to redirect the user to for sign-in.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"redirect_uri": "https://yourapp.com/auth/callback",
"provider": "Google", // optional
"scopes": ["openid", "email", "profile"] // optional
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/sso/authorize-url" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"redirect_uri": "https://yourapp.com/auth/callback",
"provider": "Google"
}'Response
{
"authorize_url": "https://app-123.auth.us-east-2.amazoncognito.com/oauth2/authorize?..."
}/api/v1/identity/sso/tokenExchange the authorization code from the callback for OIDC tokens.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"app_id": "app_123",
"code": "auth-code-from-callback",
"redirect_uri": "https://yourapp.com/auth/callback"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/sso/token" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "app_123",
"code": "auth-code-from-callback",
"redirect_uri": "https://yourapp.com/auth/callback"
}'Response
{
"status": "authenticated",
"id_token": "eyJraWQiOi...",
"access_token": "eyJraWQiOi...",
"refresh_token": "eyJjdHkiOi...",
"expires_in": 3600,
"token_type": "Bearer"
}Bring-your-own Cognito
To keep users in your own AWS account, create a cross-account IAM role from the template below, then enable the app with mode: "byo" and the role ARN.
/api/v1/identity/byo/setupGet the CloudFormation template and the trust values (Hikigai account ID + ExternalId) to create the cross-account role.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/byo/setup" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1'Response
{
"hikigai_account_id": "439563881130",
"external_id": "hikigai-app-123",
"template": "AWSTemplateFormatVersion: '2010-09-09' ..."
}/api/v1/identity/byo/testVerify the platform can assume your cross-account role before enabling BYO.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
User-Agent: hikigai-sdk/0.0.1
Content-Type: application/jsonRequest Body
{
"role_arn": "arn:aws:iam::123456789012:role/HikigaiIdentityProvisioningRole",
"region": "us-east-2" // optional
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/identity/byo/test" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'User-Agent: hikigai-sdk/0.0.1' \
--header 'Content-Type: application/json' \
--data '{
"role_arn": "arn:aws:iam::123456789012:role/HikigaiIdentityProvisioningRole",
"region": "us-east-2"
}'Response
{
"ok": true,
"account_id": "123456789012",
"error": null
}End Users
Manage the end users and QR / PIN credentials of one App. Users live in the App's Cognito (or GCP Identity Platform) pool, so every call needs the app_id query parameter. A user can be named by email or by Cognito sub; a sub is looked up among the first 200 users of the pool, so prefer the email.
Auth: Authorization: Bearer <workload_token> and X-Project-ID from inside a deployed App, or a hikigai login token. Scopes: read to list, manage to change anything.
Already under End-User Identity: get and update a user, disable MFA, list credentials, revoke a credential.
Errors: 400 missing app_id, missing project or invalid request · 403 missing scope · 404 user or credential not found · 503 identity provider unavailable · 501 other identity errors.
/api/v1/end-users?app_id=List the App's end users from its Cognito / GCP pool. Scope: read.
Query: app_id (required) · limit 1–200, default 50 · offset ≥ 0, default 0
cURL Example
curl --location "https://backend.hikigaiplatform.io/api/v1/end-users?app_id=YOUR_APP_ID&limit=50" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"end_users": [
{
"id": "a1b2c3d4-....",
"project_id": "YOUR_PROJECT_ID",
"first_name": "Asha",
"last_name": "Mehta",
"email": "clinician@hospital.com",
"role": "clinician",
"external_subject": "a1b2c3d4-....",
"is_active": true,
"qr_issued": false,
"metadata": null,
"created_at": "2026-06-11T12:00:00+00:00",
"last_verified_at": null
}
]
}SDK: client.identity.list_users(app_id, limit=50, offset=0) / client.identity.listUsers(appId, { limit, offset }).
/api/v1/end-usersNot supported: always returns 400. Create users with POST /api/v1/identity/signup.
400 { "detail": "Create users via POST /api/v1/identity/signup (requires app_id, email, password). ..." }SDK: client.identity.create_user(app_id=…, email=…, password=…, first_name=…, last_name=…) / createUser({…}) call /identity/signup for you.
/api/v1/end-users/{email_or_sub}/credentials/qr?app_id=Issue a QR badge for the user. Scope: manage. Returns 201; qr_payload is shown only once.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
Content-Type: application/jsonBody: {}. Cognito QR badges do not expire, so expires_at is refused with 400. Issuing again replaces the previous badge.
cURL Example
curl --location --request POST "https://backend.hikigaiplatform.io/api/v1/end-users/clinician%40hospital.com/credentials/qr?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{}'Response (201)
{
"credential_id": "qr-version-uuid",
"end_user_id": "a1b2c3d4-....",
"qr_payload": "HKG2....",
"qr_code_png_base64": "iVBORw0KGgo...",
"status": "active",
"expires_at": null
}The SDKs issue badges through POST /api/v1/identity/apps/{app_id}/users/{email}/qr-login: client.identity.issue_qr(app_id, email) / issueQr(appId, email).
/api/v1/end-users/{email_or_sub}/credentials/pin?app_id=Set or replace the user's PIN (stored as a bcrypt hash on the Cognito user). Scope: manage. Returns 201.
curl --location --request POST "https://backend.hikigaiplatform.io/api/v1/end-users/clinician%40hospital.com/credentials/pin?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{ "pin": "482913" }'
→ 201 { "id": "pin", "end_user_id": "a1b2c3d4-....", "credential_type": "pin", "status": "active",
"issued_at": null, "expires_at": null, "last_used_at": null }Digits only, exactly the platform PIN length (6 by default); otherwise 400.
/api/v1/end-users/{email_or_sub}/credentials/{credential_id}/rotate?app_id=Re-issue the user's QR badge; the old badge stops working at once. Scope: manage. Returns 201.
credential_id is the QR credential's id from list credentials, or the literal qr. No body. 404 when the user has no QR badge or the id does not match.
curl --location --request POST "https://backend.hikigaiplatform.io/api/v1/end-users/clinician%40hospital.com/credentials/qr/rotate?app_id=YOUR_APP_ID" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 201 same shape as issuing a QR badgeSDK: client.identity.rotate_qr(app_id, email, credential_id) / rotateQr(appId, email, credentialId).
App Users & Own Secrets
Per-App user management under /api/v1/identity/apps/{app_id}, plus reading and deleting a signed-in user's own short-lived secrets. Writing a secret (me/secrets/set) is under End-User Identity.
Auth: workload or hikigai login token and X-Project-ID. Errors: 400 invalid request · 401 verification failed · 403 scope · 404 user not found · 409 other identity errors · 423 locked (with Retry-After) · 503 provider unavailable.
/api/v1/identity/apps/{app_id}/usersList the App's end users (same data as GET /end-users, under a users key). Scope: read.
curl --location "https://backend.hikigaiplatform.io/api/v1/identity/apps/YOUR_APP_ID/users?limit=50&offset=0" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 200 { "users": [ { "id": "…", "email": "…", "first_name": "…", "last_name": "…", "role": "…", "is_active": true, "...": "..." } ] }SDK: client.identity.list_app_users(app_id) / listAppUsers(appId).
/api/v1/identity/apps/{app_id}/users/{email}Delete an end user from the App's pool; their own secrets go with them. Scope: manage.
curl --location --request DELETE "https://backend.hikigaiplatform.io/api/v1/identity/apps/YOUR_APP_ID/users/clinician%40hospital.com" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 200 { "success": true, "message": "User deleted" }SDK: client.identity.delete_app_user(app_id, email) / deleteAppUser(appId, email).
/api/v1/identity/apps/{app_id}/users/{email}/pinSet or replace a user's PIN. Scope: manage. Returns 201.
curl --location --request POST "https://backend.hikigaiplatform.io/api/v1/identity/apps/YOUR_APP_ID/users/clinician%40hospital.com/pin" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{ "pin": "482913" }'
→ 201 { "success": true, "message": "PIN set" }Check it at runtime with POST /api/v1/identity/verify-pin. SDK: client.identity.issue_pin(app_id, email, pin) / issuePin(appId, email, pin).
/api/v1/identity/me/secrets/getRead one of the signed-in user's own secrets until it expires. Scope: invoke.
{
"app_id": "YOUR_APP_ID",
"token": "eyJraWQiOi...", // the signed-in user's ID token
"name": "partner.session" // 1–64 characters
}
→ 200 { "name": "partner.session", "value": "...", "expires_at": "2026-11-11T13:00:00+00:00" }
→ 404 { "detail": { "code": "NOT_FOUND", "message": "No such secret, or it expired." } }
→ 401 { "detail": "User login is invalid or revoked" }SDK: client.identity.get_own_secret(app_id, token, name) (returns None on 404) / getOwnSecret(appId, token, name) (returns null).
/api/v1/identity/me/secrets/deleteDelete one of the signed-in user's own secrets. Succeeds even when there was none. Scope: invoke.
{ "app_id": "YOUR_APP_ID", "token": "eyJraWQiOi...", "name": "partner.session" }
→ 200 { "success": true, "message": "Deleted" }SDK: client.identity.delete_own_secret(app_id, token, name) / deleteOwnSecret(appId, token, name).
Identity Verification (CLEAR, ID.me)
Prove who a patient is with CLEAR or ID.me. Store your own vendor credentials once per project, start a session and send the patient to verification_url. The platform runs the vendor's OpenID Connect flow (PKCE, single-use state), keeps the result and gives a vendor-neutral answer. Demographics can be matched without being disclosed.
Auth: workload token (or hikigai login token) and X-Project-ID; everything is scoped to the token's project.
Scopes: manage configure, delete and test providers · read list providers, list sessions, get a session · invoke start, complete, cancel, link, match, status lookups, and get a session with include_attributes=true.
Providers: idme, clear. Environments: sandbox (default), production.
Session status: pending → verified | failed | expired | cancelled. A pending session expires after 15 minutes by default.
Events: identity.verification_completed and identity.verification_failed; use them in production instead of polling.
Errors: 400 invalid request (unknown provider, return URL not allowlisted, metadata 4 KB or larger, …) · 401 vendor rejected · 403 scope · 404 provider not configured or session not found · 409 provider misconfigured or session no longer pending · 503 vendor unreachable, or identity verification disabled.
SDKs: Python client.identity_verification (AgentSDK and AppSDK) · Node client.identityVerification.
Provider configuration
/api/v1/identity-verification/providersThis project's configured providers (secrets masked) plus the catalog of supported vendors. Scope: read.
curl --location "https://backend.hikigaiplatform.io/api/v1/identity-verification/providers" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 200 {
"providers": [ { "...": "provider object, see PUT" } ],
"catalog": [
{ "provider_type": "idme", "display_name": "ID.me", "assurance_summary": "...",
"default_scope": "...", "environments": ["sandbox", "production"],
"default_endpoints": { "sandbox": { "...": "..." }, "production": { "...": "..." } } }
]
}SDK: list_providers() / listProviders().
/api/v1/identity-verification/providers/{provider}Create or update the vendor configuration (idme | clear). Only the fields you send change. Scope: manage.
Request Body (all optional)
{
"environment": "sandbox", // sandbox | production
"display_name": "ID.me", // ≤ 120 chars
"client_id": "...", // ≤ 255 chars
"client_secret": "...", // write-only; "" clears
"api_key": "...", // CLEAR Verified API key; write-only
"scope": "...", // OAuth scope / ID.me policy handle, ≤ 512
"allowed_return_urls": ["https://app.example.com/verified"], // ≤ 20 absolute http(s) prefixes
"endpoint_overrides": { "issuer": "https://..." }, // https:// only
"attribute_policy": {
"store_attributes": false, // keep verified attributes (encrypted)
"expose_to_agents": false, // let MCP tools return them
"attribute_allowlist": ["first_name", "last_name", "date_of_birth"]
},
"enabled": true
}endpoint_overrides keys: issuer, authorization_endpoint, token_endpoint, userinfo_endpoint, jwks_uri, discovery_url, attributes_endpoint, session_endpoint. attribute_allowlist values: first_name, last_name, date_of_birth, email, phone, postal_code, address. Unknown keys get 400.
Response
{
"provider_type": "idme", "display_name": "ID.me", "environment": "sandbox",
"enabled": true, "status": "active", "error_message": null,
"client_id": "...", "client_secret_masked": "…abcd", "api_key_masked": null,
"has_client_secret": true, "has_api_key": false, "scope": "...",
"allowed_return_urls": ["https://app.example.com/verified"],
"endpoint_overrides": {}, "endpoints": { "issuer": "...", "authorization_endpoint": "..." },
"attribute_policy": { "store_attributes": false, "expose_to_agents": false, "attribute_allowlist": null },
"assurance_summary": "...", "last_tested_at": null, "created_at": "...", "updated_at": "..."
}SDK: configure_provider("idme", client_id=…, client_secret=…, allowed_return_urls=[…]) / configureProvider('idme', { clientId, clientSecret, allowedReturnUrls }).
/api/v1/identity-verification/providers/{provider}Remove the project's configuration for a vendor. Scope: manage.
→ 200 { "success": true, "message": "Provider configuration removed" }
→ 404 when the provider is not configuredSDK: delete_provider(provider) / deleteProvider(provider).
/api/v1/identity-verification/providers/{provider}/testCheck that the vendor's discovery metadata is reachable with the stored configuration. Scope: manage.
→ 200 {
"provider_type": "idme", "environment": "sandbox",
"discovery_reachable": true, "discovery_url": "https://...",
"issuer": "https://...", "endpoints": { "...": "..." },
"token_auth_method": "client_secret_post",
"pinned_endpoints": [], "message": "..."
}404 not configured or disabled · 409 misconfigured (for example, no client_id). SDK: test_provider(provider) / testProvider(provider).
Verification sessions
/api/v1/identity-verification/sessionsStart a verification and send the patient's browser to verification_url (returned only here). Scope: invoke. Returns 201.
Request Body
{
"provider": "idme", // required: idme | clear
"patient_reference": "fhir-Patient-123", // optional, ≤ 255; never sent to the vendor
"app_id": "YOUR_APP_ID", // optional; must belong to the project
"end_user_id": null, // optional; a user of the App's pool (Cognito sub or email; needs app_id)
"return_url": "https://app.example.com/verified", // optional; must be allowlisted
"redirect_uri": null, // optional; your own vendor redirect (allowlisted), then call /complete
"requested_assurance": "ial2", // optional; ial2 (default) or ial1
"metadata": { "visit": "v-77" } // optional; under 4 KB, no PHI
}cURL Example
curl --location "https://backend.hikigaiplatform.io/api/v1/identity-verification/sessions" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{ "provider": "idme", "patient_reference": "fhir-Patient-123", "return_url": "https://app.example.com/verified" }'Response (201): the session object
{
"session_id": "...", "project_id": "...", "app_id": null, "end_user_id": null,
"provider": "idme", "environment": "sandbox", "patient_reference": "fhir-Patient-123",
"status": "pending", "requested_assurance": null, "assurance_level": null,
"provider_subject": null, "id_token_verified": null, "failure_reason": null,
"has_attributes": false, "can_match_demographics": false,
"initiated_via": "api", "agent_id": null,
"return_url": "https://app.example.com/verified", "metadata": {},
"linked_at": null, "end_user": null,
"created_at": "...", "expires_at": "...", "completed_at": null,
"verification_url": "https://api.idmelabs.com/oauth/authorize?...",
"attributes": null
}Without redirect_uri, the vendor returns the patient to the platform callback (below), which then redirects to return_url. Return URLs must match an allowed_return_urls prefix and use https (http only for localhost). SDK: start("idme", patient_reference=…, return_url=…) / start('idme', { patientReference, returnUrl }).
/api/v1/identity-verification/sessionsList the project's sessions. Scope: read.
Query (all optional): app_id, patient_reference, end_user_id, status, provider, limit 1–200 (default 50), offset (default 0). end_user_id takes the user's sub or the email the session was linked with.
curl --location "https://backend.hikigaiplatform.io/api/v1/identity-verification/sessions?status=verified&limit=20" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 200 { "sessions": [ { "...": "session object" } ] }SDK: list(status="verified") / list({ status: 'verified' }).
/api/v1/identity-verification/sessions/{session_id}One session's status. Scope: read, or invoke with include_attributes=true.
include_attributes (default false) adds attributes, which exist only when the provider's attribute_policy.store_attributes kept them; reading them is audited. A pending session past expires_at is reported as expired.
curl --location "https://backend.hikigaiplatform.io/api/v1/identity-verification/sessions/SESSION_ID?include_attributes=true" \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'SDK: get(session_id, include_attributes=True) / get(sessionId, { includeAttributes: true }). Polling helper: wait(session_id) / wait(sessionId).
/api/v1/identity-verification/sessions/{session_id}/completeFinish a session when you used your own redirect_uri: pass the vendor's code and state. Scope: invoke.
{ "code": "...", // 1–4096 chars
"state": "..." } // 8–64 chars
→ 200 session object (status "verified" or "failed", with failure_reason)
→ 404 unknown state, or the state belongs to another session
→ 409 session is no longer pending
→ 503 vendor unreachable (the session stays pending; retry before it expires)SDK: complete(session_id, code=…, state=…) / complete(sessionId, { code, state }).
/api/v1/identity-verification/sessions/{session_id}/cancelCancel a pending session. Scope: invoke.
→ 200 session object with "status": "cancelled"
→ 409 "Session is already <status>"SDK: cancel(session_id) / cancel(sessionId).
/api/v1/identity-verification/sessions/{session_id}/linkLink a pending or verified session to a user of the session's App (its Cognito / GCP pool), or unlink it with null. Scope: invoke.
{ "end_user_id": "COGNITO_SUB_OR_EMAIL" } // null unlinks
→ 200 session object (end_user_id is the user's sub; linked_at; end_user summary)
→ 400 "end_user_id is not a user of this app", or the session has no app_id
→ 503 the App's identity provider is unavailable
→ 409 a failed / expired / cancelled session cannot be linkedSDK: link(session_id, end_user_id) / link(sessionId, endUserId).
/api/v1/identity-verification/sessions/{session_id}/matchAnswer 'does this verified identity match these demographics?' without returning what is on record. Scope: invoke.
{ "first_name": "Asha", // 1–255
"last_name": "Mehta", // 1–255
"date_of_birth": "1984-02-29" } // YYYY-MM-DD preferred
→ 200 { "session_id": "...", "match": true, "reason": null }When match is false, reason is mismatch, incomplete_query, no_demographics_on_record or session_<status>; it never says which field differed. SDK: match(session_id, first_name=…, last_name=…, date_of_birth=…) / match(sessionId, { firstName, lastName, dateOfBirth }).
/api/v1/identity-verification/patients/{patient_reference}The latest verified session for a patient reference, optionally filtered by ?provider=. Scope: invoke.
→ 200 { "patient_reference": "fhir-Patient-123", "verified": true, "session": { "...": "session object" } }
→ 200 { "patient_reference": "fhir-Patient-123", "verified": false, "session": null }SDK: patient_status(patient_reference, provider="idme") / patientStatus(patientReference, { provider }).
/api/v1/identity-verification/end-users/{end_user_id}The latest verified session linked to an end user (their sub, or the email the session was linked with). Scope: invoke.
→ 200 { "end_user_id": "END_USER_ID", "verified": true, "session": { "...": "session object" } }SDK: end_user_status(end_user_id) / endUserStatus(endUserId).
/api/v1/identity-verification/callbackWhere the vendor sends the patient's browser. Your code does not call it: register it as the redirect URI in your CLEAR / ID.me app.
No auth; the single-use state is the credential. On success it redirects (302) to the session's return_url with verification_session_id and verification_status added; without a return_url it shows a short result page. Errors are HTML pages: 400 missing or unknown state · 409 already finished · 429 too many requests from one address · 503 vendor unreachable or feature disabled.
https://backend.hikigaiplatform.io/api/v1/identity-verification/callbackObject Storage
Platform-managed object storage for deployed apps. Upload PDFs, images, audio, and other documents scoped to a project and app. Files are stored in a private AWS S3 bucket — they are never public. Access is via time-limited signed URLs generated by the platform API.
/storage/{object_id}/url, the API returns a Hikigai URL under /api/v1/storage/public/{object_id} with exp and sig query params. That URL redirects (302) to S3. Your app hits Hikigai first; file bytes still come from S3 until the link expires.Base path: /api/v1/projects/{project_id}/apps/{app_id}/storage
Permissions: apps:read for list, get, stats, and signed URLs; apps:update for upload and delete.
Auth: Authorization: Bearer <token>: the workload token of a deployed App (the SDKs get it for you), your hikigai token from hikigai login, or a console session. Old project API keys (hikigai_…) are refused with 401 PROJECT_KEYS_REMOVED.
/api/v1/projects/{project_id}/apps/{app_id}/storage/uploadUpload a file to platform storage. Returns object metadata and a 1-hour signed URL for immediate use.
Request Headers
Authorization: Bearer YOUR_TOKEN
Content-Type: multipart/form-data
X-Project-ID: YOUR_PROJECT_IDForm Fields
| Field | Type | Description |
|---|---|---|
file | binary | Required. Max 100MB. PDF, images, audio, zip, etc. |
metadata | JSON string | Optional key-value metadata stored with the object. Common keys: description, agent_id, generated_by. Shown in the Developer Portal Documents tab. |
ttl | integer | Optional auto-expiry in seconds (omit = permanent) |
filename | string | Optional display name override |
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage/upload' \
--header "Authorization: Bearer $(hikigai token)" \
--form 'file=@report.pdf' \
--form 'metadata={"description":"Monthly report","agent_id":"pdf-generator"}' \
--form 'ttl=86400'Response (201)
{
"object_id": "uuid",
"object_key": "projects/{pid}/apps/{aid}/{object_id}/report.pdf",
"original_filename": "report.pdf",
"content_type": "application/pdf",
"size_bytes": 245120,
"signed_url": "https://hikigai-apps-storage-....s3.amazonaws.com/...?X-Amz-...",
"expires_at": null,
"created_at": "2026-06-11T12:00:00Z"
}/api/v1/projects/{project_id}/apps/{app_id}/storageList stored objects for an app (paginated).
Query Parameters
| Parameter | Default | Description |
|---|---|---|
page | 1 | Page number |
limit | 20 | Max 100 per page |
status | active | active | expired | all |
content_type | — | Filter by exact MIME type (e.g. application/pdf) |
content_type_prefix | — | Filter by MIME prefix (e.g. image/ or audio/) |
search | — | Filename search |
sort | created_at | created_at | size_bytes | original_filename |
order | desc | asc | desc |
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage?status=active&limit=20' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"objects": [
{
"id": "uuid",
"original_filename": "report.pdf",
"content_type": "application/pdf",
"size_bytes": 245120,
"metadata": { "description": "Monthly report", "agent_id": "pdf-generator" },
"status": "active",
"upload_source": "sdk",
"expires_at": null,
"created_at": "2026-06-11T12:00:00Z"
}
],
"total": 1,
"page": 1,
"limit": 20,
"total_pages": 1
}/api/v1/projects/{project_id}/apps/{app_id}/storage/{object_id}Get metadata for a single stored object (does not return file bytes).
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage/OBJECT_ID' \
--header "Authorization: Bearer $(hikigai token)"/api/v1/projects/{project_id}/apps/{app_id}/storage/{object_id}/urlMint a time-limited download URL. Default TTL 1 hour; max 7 days. The returned URL is a Hikigai public link that redirects to S3.
Query Parameters
ttl=3600 # seconds (min 60, max 604800)cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage/OBJECT_ID/url?ttl=3600' \
--header "Authorization: Bearer $(hikigai token)"Response
{
"object_id": "uuid",
"signed_url": "https://backend.hikigaiplatform.io/api/v1/storage/public/uuid?exp=...&sig=...",
"expires_in": 3600,
"expires_at": "2026-06-11T13:00:00Z"
}/api/v1/projects/{project_id}/apps/{app_id}/storage/{object_id}/downloadRedirect (302) to a fresh S3 signed URL — convenient for browser downloads.
Query Parameters
ttl=3600 # optional; seconds (min 60, max 604800). Defaults to platform signed-URL TTL.cURL Example
curl -L --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage/OBJECT_ID/download' \
--header "Authorization: Bearer $(hikigai token)" \
-o report.pdf/api/v1/projects/{project_id}/apps/{app_id}/storage/{object_id}Delete an object from S3 and mark it deleted in the platform database.
cURL Example
curl --location --request DELETE 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/storage/OBJECT_ID' \
--header "Authorization: Bearer $(hikigai token)"Response (200)
{
"success": true,
"message": "Storage object deleted"
}/api/v1/projects/{project_id}/apps/{app_id}/storage/statsStorage usage stats for the app (file count, total size, PDF count, expiring soon).
Response
{
"total_objects": 5,
"active_objects": 4,
"expired_objects": 1,
"total_size_bytes": 12582912,
"total_size_human": "12.0 MB",
"pdf_count": 3,
"expiring_soon_count": 0
}upload_source on list/get responses is sdk when the upload used a deployed App's workload token or a hikigai login token, otherwise portal (browser session upload).
AppSDK & AgentSDK
Both SDKs expose the same client.storage client from a deployed app or agent:
from hikigai.appsdk import AppClient
client = AppClient() # Deploy key in a deployed App, else your hikigai login
# Upload
with open("report.pdf", "rb") as f:
result = client.storage.upload(
app_id="your-app-id",
file=f,
filename="report.pdf",
content_type="application/pdf",
metadata={
"description": "Monthly report",
"agent_id": "pdf-generator",
},
ttl=86400,
)
print(result.signed_url) # short-lived download URL from upload
# Fresh signed URL later (Hikigai public link that redirects to S3)
url = client.storage.signed_url(app_id="your-app-id", object_id=result.object_id, ttl=3600)
# List, get, delete
objects = client.storage.list(app_id="your-app-id")
info = client.storage.get(app_id="your-app-id", object_id=result.object_id)
client.storage.delete(app_id="your-app-id", object_id=result.object_id)Session Context
A project-scoped key/value store for state that spans several agent calls in one end-user workflow, so your App can keep state while agents stay stateless. Session IDs are opaque strings minted by the server (sess_ + 24 hex chars). Values are any JSON and are encrypted at rest.
Auth: Authorization: Bearer <workload_token> (from POST /api/v1/auth/exchange; the SDKs get it for you) or your hikigai login token, plus X-Project-ID. The project comes from the verified token, never from the URL.
Scopes: reads need read; writes (create, extend, clear, set, delete) need invoke. A missing scope returns 403.
Errors: {"detail": "…"}. 400 missing project or bad key name · 404 session (or key) not found or expired · 409 ETag conflict or quota · 413 value too large · 429 rate limit · 503 store temporarily unavailable (retry).
Limits: default TTL 14400 s (4 h); any requested TTL is clamped to 60–86400 s. The TTL is sliding: every successful write resets it. A value is at most 65536 bytes of serialized JSON; a session holds at most 256 keys; a project at most 10000 active sessions. Keys are 1–128 chars from [a-zA-Z0-9._-]; keys starting with __ are reserved.app_id: the per-session routes take an optional ?app_id= (default _). It must match the app_id the session was created with, or you get 404.
SDKs: Python AppClient.create_session(), .session(session_id), .list_sessions(); Node AppClient.createSession(), .session(sessionId), .listSessions(). The returned SessionContext has set, get, get_with_etag/getWithEtag, get_all/getAll, get_all_with_etags/getAllWithEtags, delete, clear, touch, metadata and update (read-modify-write that retries on 409).
/api/v1/sessionsCreate a session. Returns 201 with the session record. Scope: invoke.
Request Body (all fields optional)
{
"external_user_ref": "dr-smith", // string, max 256. Your opaque end-user ref (not authenticated)
"ttl_seconds": 3600, // int >= 1, clamped to 60..86400; omitted = 14400
"app_id": "_", // string, max 128. Default "_"
"metadata": { "source": "triage-ui" } // any JSON object, stored with the session
}cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/sessions' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{"external_user_ref": "dr-smith", "ttl_seconds": 3600}'Response (201)
{
"session_id": "sess_9f2c4e1a7b3d5f6e8a0b1c2d",
"project_id": "YOUR_PROJECT_ID",
"app_id": "_",
"external_user_ref": "dr-smith",
"ttl_seconds": 3600,
"expires_at": "2026-11-19T11:00:00+00:00",
"created_at": "2026-11-19T10:00:00+00:00",
"key_count": null,
"metadata": {}
}409 when the project already has 10000 active sessions.
/api/v1/sessionsList the project's active sessions. Scope: read.
Query Parameters
user_ref string optional. Only sessions with this external_user_ref
limit int 1..200, default 50
cursor string optional. next_cursor from the previous pagecURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/sessions?user_ref=dr-smith&limit=50' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"sessions": [
{
"session_id": "sess_9f2c4e1a7b3d5f6e8a0b1c2d",
"external_user_ref": "dr-smith",
"app_id": "_",
"created_at": "2026-11-19T10:00:00+00:00",
"key_count": 2
}
],
"next_cursor": null
}The user_ref filter is applied to each page after it is fetched, so a page can hold fewer than limit items: keep paging while next_cursor is not null. Only sessions in the default _ app bucket are listed.
/api/v1/sessions/{session_id}Session metadata: TTL, expiry, key count, user ref. Scope: read.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"session_id": "sess_9f2c4e1a7b3d5f6e8a0b1c2d",
"project_id": "YOUR_PROJECT_ID",
"app_id": "_",
"external_user_ref": "dr-smith",
"ttl_seconds": 3600,
"expires_at": "2026-11-19T10:59:12+00:00",
"created_at": "2026-11-19T10:00:00+00:00",
"key_count": 2,
"metadata": {}
}404 "Session not found or expired".
/api/v1/sessions/{session_id}Set a new TTL (extend or shorten) from now. Scope: invoke.
Request Body
{ "ttl_seconds": 7200 } // required, int >= 1, clamped to 60..86400cURL Example
curl --location --request PATCH 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{"ttl_seconds": 7200}'Response
{
"session_id": "sess_9f2c4e1a7b3d5f6e8a0b1c2d",
"project_id": "YOUR_PROJECT_ID",
"app_id": "_",
"ttl_seconds": 7200,
"expires_at": "2026-11-19T12:00:00+00:00",
"...": "other fields are null here; call GET for the full record"
}404 if the session has expired.
/api/v1/sessions/{session_id}Delete the whole session and all its keys. Idempotent. Scope: invoke.
cURL Example
curl --location --request DELETE 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{ "success": true, "message": "Session cleared" }200 even if the session never existed or has already expired.
/api/v1/sessions/{session_id}/context/{key}Write a value. Send If-Match for optimistic concurrency. Each write resets the session TTL. Scope: invoke.
Headers
If-Match: 3 // optional. The ETag you last read (quotes allowed); "0" for a key that must not exist yet. Omit to overwriteRequest Body
{ "value": { "acuity": "high", "notes": ["chest pain"] } } // required. Any JSON value, max 65536 bytes serializedcURL Example
curl --location --request PUT 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d/context/triage' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--header 'If-Match: 3' \
--data '{"value": {"acuity": "high"}}'Response (also sets the ETag header)
{
"key": "triage",
"etag": "4",
"expires_at": "2026-11-19T11:05:00+00:00"
}ETags are integers that go up by one with each write to that key. 409 with an ETag header: another writer changed the value; read it again and retry with that ETag. 409 also when the session already has 256 keys. 413 value over 65536 bytes · 400 invalid or reserved key · 404 session expired.
/api/v1/sessions/{session_id}/context/{key}Read one value and its ETag. Scope: read.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d/context/triage' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response (also sets the ETag header)
{
"key": "triage",
"value": { "acuity": "high" },
"etag": "4"
}404 when the session has expired and when the key is missing. The SDK get() returns your default value on 404.
/api/v1/sessions/{session_id}/contextRead every key in the session. Scope: read.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d/context' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"session_id": "sess_9f2c4e1a7b3d5f6e8a0b1c2d",
"expires_at": "2026-11-19T11:05:00+00:00",
"external_user_ref": "dr-smith",
"context": {
"triage": { "value": { "acuity": "high" }, "etag": "4" },
"summary": { "value": "Patient reports…", "etag": "1" }
}
}/api/v1/sessions/{session_id}/context/{key}Delete one key. Idempotent for the key. Scope: invoke.
cURL Example
curl --location --request DELETE 'https://backend.hikigaiplatform.io/api/v1/sessions/sess_9f2c4e1a7b3d5f6e8a0b1c2d/context/triage' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{ "success": true, "key": "triage" }200 even if the key is missing; 404 if the session itself has expired.
Background Jobs
A durable queue for long-running agent work: priorities, scheduling (a delay or a fixed time up to 30 days ahead), retries with exponential backoff, idempotency keys and a dead-letter state. Statuses: queued, scheduled, running, retrying, and the terminal completed, failed, dead_lettered, cancelled.
Auth: Authorization: Bearer <workload_token> or your hikigai login token, plus X-Project-ID.
Scopes: jobs:enqueue, jobs:read, jobs:cancel, jobs:replay (a deployed App's workload token has all four). A missing scope returns 403; a missing project returns 400 "X-Project-ID header is required.".
SDKs: Python and Node AgentClient.jobs: enqueue, get, list, cancel, replay, wait (polls until a terminal status) and stream (SSE, with polling as a fallback).
/api/v1/jobs/enqueueEnqueue a job. Returns 201 with the job id, status URL and stream URL. Scope: jobs:enqueue.
Request Body
{
"job_type": "agent.invoke", // required. agent.invoke | agent.warmup
"agent_id": "AGENT_UUID", // required for agent.* types; owned by or linked to the project
"payload": { // required object. agent.invoke reads:
"input": { "message": "Batch-code these notes" }, // input (or message): the agent invoke body
"timeout_seconds": 120 // per-call timeout, default 120
},
"priority": "standard", // critical | standard | bulk. Default standard
"schedule": { // optional. One of:
"delay_seconds": 300 // int >= 0, max 30 days
// "execute_at": "2026-11-20T09:00:00Z" ISO-8601, in the future, max 30 days ahead
},
"retry_policy": { // optional. Overrides the job type's defaults
"strategy": "exponential",
"max_attempts": 5, // 1..100
"min_backoff_seconds": 30,
"max_backoff_seconds": 600,
"max_retry_duration_seconds": 3600,
"jitter": true,
"retry_on": ["TRANSIENT", "TIMEOUT", "RATE_LIMITED", "RESOURCE_EXHAUSTED"],
"no_retry_on": ["PERMANENT", "AUTH_FAILED", "VALIDATION_ERROR", "NOT_FOUND"]
},
"dead_letter": { "destination": "default", "alert_channels": [] }, // optional
"idempotency_key": "notes-batch-42", // optional, max 255. Deduped per project for 1 hour
"metadata": {} // optional object
}cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/jobs/enqueue' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{
"job_type": "agent.invoke",
"agent_id": "AGENT_UUID",
"payload": {"input": {"message": "Batch-code these notes"}},
"priority": "standard",
"idempotency_key": "notes-batch-42"
}'Response (201)
{
"job_id": "3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13",
"status": "queued",
"priority": "standard",
"job_type": "agent.invoke",
"scheduled_at": null,
"estimated_start": null,
"max_attempts": 5,
"status_url": "/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13",
"stream_url": "/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13/stream",
"created_at": "2026-11-19T10:00:00Z"
}A job with a schedule starts as scheduled. Errors: 400 invalid job_type/priority, execute_at in the past, or more than 30 days ahead · 422 agent_id missing or not in the project · 409 duplicate idempotency key (body {"detail": {"job_id": "…", "message": "Duplicate idempotency_key"}}) · 429 the project already has 1000 active jobs, or the rate limit. An agent.invoke job's result is {"response": …, "http_status": 200}.
/api/v1/jobsList the project's jobs, newest first by default. Scope: jobs:read.
Query Parameters
status string optional. Comma-separated, e.g. failed,dead_lettered
job_type string optional
agent_id string optional
priority string optional. critical | standard | bulk
page int >= 1, default 1
per_page int 1..100, default 20
sort string created_at (default) | updated_at | scheduled_at | started_at | completed_at | priority | status
order string desc (default) | asccURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/jobs?status=failed,dead_lettered&per_page=20' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"jobs": [ "... same shape as GET /api/v1/jobs/{job_id} ..." ],
"total": 1,
"page": 1,
"per_page": 20,
"total_pages": 1
}/api/v1/jobs/{job_id}A job's status, result, retry policy and attempt history. Scope: jobs:read.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Response
{
"job_id": "3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13",
"job_type": "agent.invoke",
"status": "completed",
"priority": "standard",
"agent_id": "AGENT_UUID",
"project_id": "YOUR_PROJECT_ID",
"current_attempt": 1,
"max_attempts": 5,
"last_error": null,
"last_error_code": null,
"retry_policy": { "strategy": "exponential", "max_attempts": 5, "min_backoff_seconds": 10, "...": "..." },
"schedule_config": null,
"scheduled_at": null,
"started_at": "2026-11-19T10:00:01Z",
"completed_at": "2026-11-19T10:00:09Z",
"created_at": "2026-11-19T10:00:00Z",
"result": { "response": { "...": "..." }, "http_status": 200 },
"attempts": [
{
"attempt_number": 1,
"status": "completed",
"error_message": null,
"error_code": null,
"duration_ms": 8120,
"attempted_at": "2026-11-19T10:00:01Z",
"completed_at": "2026-11-19T10:00:09Z"
}
]
}404 "Job not found" if it does not exist or belongs to another project.
/api/v1/jobs/{job_id}/cancelCancel a job that has not finished. Returns the updated job. Scope: jobs:cancel.
cURL Example
curl --location --request POST 'https://backend.hikigaiplatform.io/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13/cancel' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'Returns the job (same shape as GET) with status: "cancelled". 404 not found · 409 "Job already in terminal state: <status>".
/api/v1/jobs/{job_id}/replayRe-enqueue a dead-lettered job as a new job. Returns 201. Scope: jobs:replay.
Request Body (optional)
{
"override_payload": { "input": { "message": "Retry with a smaller batch" } }, // replaces the original payload
"override_retry_policy": { "max_attempts": 3 } // same fields as retry_policy on enqueue
}cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13/replay' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{}'Responds like enqueue (201, new job_id). The new job keeps the original type, agent, priority and dead-letter settings and gets metadata.replayed_from. 404 not found · 409 "Only dead_lettered jobs can be replayed" · enqueue errors (such as 429) still apply.
/api/v1/jobs/{job_id}/streamServer-Sent Events: status changes until the job reaches a terminal status. Scope: jobs:read.
cURL Example
curl --no-buffer --location 'https://backend.hikigaiplatform.io/api/v1/jobs/3b6f0c1e-8a2d-4c5e-9f71-2d4a6b8c0e13/stream' \
--header 'Authorization: Bearer <workload_token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Accept: text/event-stream'Events (text/event-stream)
event: status
data: {"job_id": "3b6f0c1e-…", "status": "running", "attempt": 1, "message": "Job running"}
event: completed
data: {"job_id": "3b6f0c1e-…", "status": "completed", "result": {"response": {...}, "http_status": 200}, "error": null}A status event on every status change (message holds the last error, if any). The stream sends one final event and closes: completed, dead_lettered, or a status event for failed/cancelled. 404 is returned before the stream opens.
Live Sessions
Bidirectional realtime audio over WebSocket (protocol v2). A typical live transcription client runs inside a deployed App: the SDK exchanges the App's Deploy key for a workload token, mints a short-lived session, opens the WebSocket URL returned by mint, streams raw PCM microphone audio, and renders caption frames as they arrive. From your computer, a hikigai login token can mint sessions too.
How the two endpoints work together
Both calls are required, in order. Step 2 (/live/session) mints credentials over HTTPS. Step 3 (/live) is the WebSocket that carries audio and transcription — connect with the wss_url returned by mint.
| Call | Path | Role |
|---|---|---|
POST (HTTPS) | /api/v1/agents/{agent_slug}/live/session | Mint wss_url, live_token, and session_id. This path is not a WebSocket endpoint. |
WS | wss_url from mint (ends in /live) | Open the socket with the exact wss_url returned by mint. Authenticate with the first JSON frame using live_token. |
Typical integration flow
Replace YOUR_PROJECT_ID and {agent_slug} with your values. Audio must be mono signed 16-bit LE PCM at 16 kHz (binary WebSocket frames, not base64 JSON).
# 1. Get an access_token (inside the deployed App the SDK does this for you)
# 2. Mint live session (every connect / reconnect)
POST /api/v1/agents/{agent_slug}/live/session
Headers: Authorization: Bearer <access_token>, X-Project-ID
Body: { "session_id": "<fresh UUID>", "user_id": "app-transcriber" }
→ wss_url, live_token, session_id
# 3. Open WebSocket(wss_url) // exact URL from step 2; path ends in /live
# First frame:
{ "type": "auth", "live_token": "…", "session_id": "…", "protocol_version": 2 }
# 4. Start mic capture
{ "type": "start", "modality": "audio", "mime_type": "audio/pcm;rate=16000", "protocol_version": 2 }
→ stream binary PCM frames while recording
# 5. Receive captions (source: input_transcription); replace UI text on partials
{ "type": "data", "modality": "text", "content": "…", "source": "input_transcription", "finished": false|true }
# 6. Stop capture / disconnect
{ "type": "end" }
{ "type": "disconnect" }
→ close WebSocketStep 1 — Auth exchange
Inside a deployed App the SDK gets the access token for you when the App starts and renews it. This is a platform token for API calls, not an end-user login token. Send it as Authorization: Bearer <access_token> on the mint request in Step 2. See Authentication.
Step 2 — Mint live session (/live/session)
HTTPS only — this call issues credentials; it does not open the stream. Mint before every connect and reconnect. The app creates a fresh UUID for session_id and an opaque user_id for your client. The response includes wss_url, live_token, and session_id, which you pass into Step 3.
/api/v1/agents/{agent_slug}/live/sessionMint wss_url and live_token for a live WebSocket session.
Request Headers
Authorization: Bearer <access_token from Step 1>
X-Project-ID: YOUR_PROJECT_ID
Content-Type: application/jsonRequest Body
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"user_id": "app-transcriber"
}cURL Example
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agents/{agent_slug}/live/session" \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'X-Project-ID: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data '{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"user_id": "app-transcriber"
}'Response
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"wss_url": "wss://backend.hikigaiplatform.io/api/v1/agents/<agent_id>/live",
"live_token": "<live_token>",
"protocol_version": 2,
"expires_in": 120,
"agent_id": "ag_…",
"direct_connect": false
}wss_url is the Step 3 WebSocket address (path ends in /live). Use it unchanged — every session goes through the platform gateway. The live_token is short-lived (expires_in, 120 seconds by default), so connect right after minting.Step 3 — Connect and authenticate (/live)
After Step 2 succeeds, open a WebSocket to the wss_url in that response. That URL is the live stream endpoint (path ends in /live). Both Step 2 and Step 3 are required: mint issues credentials; this socket carries audio and captions. Authenticate with the first JSON frame using the minted live_token and the same session_id. No key or workload token is sent on this socket.
/api/v1/agents/{agent_id}/liveLive stream WebSocket. Connect using the exact wss_url from Step 2.
URL
Use wss_url from the Step 2 response as-is. Example shape (host may be the platform gateway or a direct agent endpoint):
wss://backend.hikigaiplatform.io/api/v1/agents/<agent_id>/liveExample: App server mints, browser connects
Your App's server mints the session with its access token (Step 1) and returns only wss_url, live_token and session_id to the browser. The browser never sees the access token. It opens wss_url (the /live socket), streams PCM from an AudioWorklet downsampled to 16 kHz, and replaces transcript text on partials.
// App server (Node) — Step 2: mint (/live/session) and return only the session details
app.post("/api/live/session", async (req, res) => {
const mint = await fetch(`${process.env.HIKIGAI_PLATFORM_URL}/api/v1/agents/${agentSlug}/live/session`, {
method: "POST",
headers: {
Authorization: `Bearer ${await getAccessToken()}`, // 5-minute App token, see Authentication
"X-Project-ID": process.env.HIKIGAI_PROJECT_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({ session_id: req.body.session_id, user_id: "browser-transcriber" }),
});
res.status(mint.status).json(await mint.json()); // { wss_url, live_token, session_id, ... }
});// Browser — ask your App's server for a session, then connect
const PROTOCOL_VERSION = 2;
const PCM_MIME = "audio/pcm;rate=16000";
let sessionId = crypto.randomUUID();
const mint = await fetch("/api/live/session", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ session_id: sessionId }),
});
const { wss_url, live_token, session_id } = await mint.json();
sessionId = session_id || sessionId;
// Step 3 — connect + auth (/live via wss_url)
const ws = new WebSocket(wss_url);
ws.binaryType = "arraybuffer";
ws.onopen = () => {
ws.send(JSON.stringify({
type: "auth",
live_token,
session_id: sessionId,
protocol_version: PROTOCOL_VERSION,
}));
};
// Step 4 — after getUserMedia + AudioWorklet → 16 kHz PCM
ws.send(JSON.stringify({
type: "start",
modality: "audio",
mime_type: PCM_MIME,
protocol_version: PROTOCOL_VERSION,
}));
// workletPort.onmessage = (e) => ws.send(e.data); // binary PCM frames
// Step 5 — captions
ws.onmessage = (event) => {
if (typeof event.data !== "string") return;
const msg = JSON.parse(event.data);
if (msg.type === "data" && msg.modality === "text" && msg.content) {
if (msg.source === "input_transcription" || !msg.source) {
transcriptEl.textContent = msg.content; // replace on partials
}
}
if (msg.type === "error") {
console.error(msg.message);
ws.close();
}
};
// Step 6
ws.send(JSON.stringify({ type: "end" }));
ws.send(JSON.stringify({ type: "disconnect" }));
ws.close();First frame — auth
{
"type": "auth",
"live_token": "<live_token from Step 2>",
"session_id": "<session_id from Step 2>",
"protocol_version": 2
}Step 4 — Stream audio
When capture starts, send a start frame, then continuous binary PCM. When capture stops, send end. Resample microphone input to mono PCM16 at 16 kHz before sending (browsers often capture at 44.1/48 kHz).
{ "type": "start", "modality": "audio", "mime_type": "audio/pcm;rate=16000", "protocol_version": 2 }
// binary WebSocket frames: raw PCM16 mono @ 16 kHz
// …
{ "type": "end" }- Optional: send one short silent PCM frame (~40 ms) immediately after
startto prime the session. - While paused: stop microphone PCM, keep the socket open, and send silent PCM periodically (for example every 15 s) to keep the session alive.
Step 5 — Handle transcription frames
Captions arrive as text data frames with source: "input_transcription". Transcription often emits data without a preceding server start. Silence may produce no frames.
- On each
datawith non-emptycontent, update the current pending caption. - Partials are cumulative: replace the pending line rather than appending.
- When
finishedistrue(or the server sendsend), commit the pending line. - An
errorframe ends the session; disconnect and stop reconnecting for that attempt.
{ "type": "data", "modality": "text", "content": "hello how are", "source": "input_transcription", "partial": true, "finished": false }
{ "type": "data", "modality": "text", "content": "hello how are you", "source": "input_transcription", "partial": false, "finished": true }
{ "type": "end" }
{ "type": "error", "message": "…" }Step 6 — Close
Stop capture with end, optionally send disconnect, then close the WebSocket. Closing the socket alone is sufficient; sending both frames before close is recommended.
{ "type": "end" }
{ "type": "disconnect" }
// then ws.close()Text turns
Non-transcription live agents can send text turns on the same socket after auth:
{ "type": "start", "modality": "text", "protocol_version": 2 }
{ "type": "data", "modality": "text", "content": "Summarize the last turn." }
{ "type": "end" }Troubleshooting
| Symptom | Likely cause |
|---|---|
| WS closes with 1008 / auth failure | Mint skipped, a key or workload token sent on the socket, or live_token / session_id mismatched. |
| 404 / failed WebSocket upgrade | Socket URL was constructed manually instead of using wss_url, or /live/session was opened as a WebSocket. |
| No captions after N ms | Incorrect URL, base64 JSON audio instead of binary PCM, wrong sample rate, waiting only for a server start, or silence (no transcription emitted). |
| Garbled or empty transcript | Microphone not resampled to 16 kHz mono PCM; verify mime_type on start. |
input_modality / output_modality (and optional vad) configure the live model. Transcription agents typically use audio in → text out.Speech
Real-time speech-to-speech translation and speech-to-text transcription over dedicated WebSockets. These are gateway-native endpoints, not agents — there is nothing to deploy, and they do not appear in the model registry.
403 with a plain-text detail, and the WebSocket closes with credentials_missing. Connect GCP under Cloud accounts.Audio format
Input is raw little-endian 16-bit mono PCM at 16 kHz. Translate output is the same at 24 kHz. Chunks of about 100 ms are the recommended balance of throughput and latency. Both SDKs convert from μ-law, Float32, and other sample rates for you.
Step 1 — Mint a speech token
/api/v1/speech/tokensUse your App's access token to mint a short-lived, browser-safe speech token.
Call this from your deployed App (workload token) so no platform credential reaches an untrusted client. Credentials and entitlement are validated here, so a misconfigured organization fails with an actionable error rather than a socket that dies on first audio.
Request
{
"endpoint": "translate",
"config": {
"target_language_code": "es",
"echo_target_language": true,
"input_transcription": true,
"output_transcription": true
},
"locked": false,
"ttl_seconds": 600
}Set locked: true to forbid configure frames, pinning the session to this exact config — useful for a kiosk or a phone line.
Response
{
"speech_token": "<jwt>",
"expires_in": 600,
"session_id": "spch_4f1c9a2b8e0d7c65",
"endpoint": "translate",
"config": { "target_language_code": "es", ... },
"locked": false
}/api/v1/speech/languagesSupported BCP-47 codes per endpoint. Unauthenticated.
Translate takes bare language subtags (es, pt-BR); transcribe takes full locales (es-ES, en-US). Sending the wrong shape returns unsupported_language with a suggestion.
{
"translate": { "field": "target_language_code", "codes": ["af", "ak", ...] },
"transcribe": { "field": "language_codes", "codes": ["af-ZA", "am-ET", ...] }
}Step 2 — Connect
Both endpoints speak the same protocol: JSON control frames plus raw binary PCM, identical in grammar to the live agent tunnel. The first frame must be auth, within 10 seconds.
Authentication
Either of two credentials:
{"type": "auth", "speech_token": "<from step 1>"}
{"type": "auth", "access_token": "<workload_token>", "project_id": "YOUR_PROJECT_ID"}access_token is the workload token the SDK holds inside a deployed App. A project API key in the auth frame is rejected with DEPLOY_KEY_REQUIRED.
Server frames
| Frame | Meaning |
|---|---|
ready | Setup acknowledged upstream. Carries session_id, model, resolved config, audio formats, and a resume_token. Wait for this before sending audio — the model discards anything that arrives earlier. |
transcript | source is input or output; final distinguishes interim from settled text. |
| binary | Translated audio, 24 kHz PCM. Translate only. |
reconfigured | A configure was applied; echoes the new config. |
turn_complete / interrupted | Turn boundaries. |
error | Typed code plus a human-readable message. |
/api/v1/speech/translateSpeech-to-speech translation across 75+ languages. Emits translated audio and transcripts.
Model
gemini-3.5-live-translate-previewConfiguration
| Field | Default | Description |
|---|---|---|
target_language_code | "en" | BCP-47 output language. One per session. |
echo_target_language | true | When the speaker already uses the target language, echo them through rather than staying silent. |
input_transcription | true | Transcribe the source audio. |
output_transcription | true | Transcribe the translated audio (subtitles). |
The last three defaults differ from Google's, which default echo off and both transcriptions off.
Full exchange
--> {"type": "auth", "speech_token": "<token>"}
--> {"type": "start", "modality": "audio", "mime_type": "audio/pcm;rate=16000"}
<-- {"type": "ready", "session_id": "spch_...", "model": "gemini-3.5-live-translate-preview",
"config": {"target_language_code": "es", "echo_target_language": true, ...},
"audio": {"input": {"encoding": "pcm_s16le", "sample_rate": 16000, "channels": 1},
"output": {"encoding": "pcm_s16le", "sample_rate": 24000, "channels": 1}}}
--> <binary PCM @ 16 kHz>
<-- {"type": "transcript", "source": "input", "text": "Good morning", "language_code": "en", "final": true}
<-- <binary PCM @ 24 kHz>
<-- {"type": "transcript", "source": "output", "text": "Buenos días", "final": true}
<-- {"type": "turn_complete"}Changing language mid-session
Send configure at any time. The gateway brings up a replacement model session before retiring the old one, so audio keeps flowing and the listener hears no gap. No reconnect, no new token.
--> {"type": "configure", "config": {"target_language_code": "fr"}}
<-- {"type": "reconfigured", "changed": true, "config": {"target_language_code": "fr", ...}}Rejected if the token was minted with locked: true.
/api/v1/speech/transcribeSpeech-to-text across 85+ locales, with interim results as the speaker talks.
Model
gemini-3.5-transcribe-live-previewConfiguration
| Field | Default | Description |
|---|---|---|
language_codes | auto-detect | Up to 8 full locales (en-US, not en) to bias recognition. |
custom_vocabulary | — | Up to 1000 names, jargon, or product terms to bias towards. |
Full exchange
--> {"type": "auth", "speech_token": "<token>"}
--> {"type": "start", "modality": "audio", "mime_type": "audio/pcm;rate=16000"}
<-- {"type": "ready", "session_id": "spch_...", "model": "gemini-3.5-transcribe-live-preview"}
--> <binary PCM @ 16 kHz>
<-- {"type": "transcript", "source": "input", "text": "the quarterly", "language_code": "en-US", "final": false}
<-- {"type": "transcript", "source": "input", "text": "the quarterly report", "language_code": "en-US", "final": true}Errors
| Code | Cause and fix |
|---|---|
credentials_missing | No Google Cloud account on the project (or its team organization). Speech bills to your own cloud project. |
unsupported_language | Wrong code shape for the endpoint. The message suggests the right one. |
stream_cap_exceeded | Organization is at its concurrent-session cap (50 by default, raisable by an admin). Reconnecting with the same resume_token reclaims the original slot rather than competing for a new one. |
config_invalid | A config field failed validation; the message names it. |
forbidden | A configure was sent on a token minted with locked: true. |
session_duration_exceeded | Session passed the 1 hour wall-clock ceiling. |
upstream_unavailable | The model was unreachable. Retry with backoff. |
vertex_permission_denied | The organization's Google Cloud service account lacks roles/aiplatform.user. Not retryable until the role is granted. |
vertex_api_not_enabled | The Vertex AI API (aiplatform.googleapis.com) is not enabled in the organization's Google Cloud project. |
credentials_invalid | Google rejected the organization's service-account key. Rotate it in Organization settings → Cloud accounts. |
Rooms
Project-scoped realtime collaboration. Two APIs:
- WebSocket — JSON events (transcripts, presence, app messages)
- WebRTC — audio, video, and in-call chat via SFU
Rooms are namespaced server-side as {project_id}:{room} so members of one project never see another project's traffic. Authenticate with the workload token a deployed App gets from POST /api/v1/auth/exchange (the SDKs send it in the auth frame), or with a short-lived room_token minted for an end user, or (on your computer) with a hikigai login token. No separate create-room API — your app picks a name; first join creates it.
WebSocket
Realtime JSON pub/sub for app events (transcripts, presence, notes). For audio, video, and in-call chat, use WebRTC instead.
How the pieces fit together
Your app ──calls──► Hikigai
│
├─ REST (optional)
│ POST /api/v1/rooms/tokens mint room_token for a browser user
│ POST /api/v1/rooms/{room}/publish push one event (no socket)
│ GET /api/v1/rooms/stats hub health
│
└─ WebSocket WS /api/v1/rooms/ws live join / publish / receive
1. auth → ready
2. join room → joined (+ others get presence)
3. publish → others get message { event, data, seq }
4. leave / disconnectAPIs in this section
| API | Role |
|---|---|
WS /api/v1/rooms/ws | Live session: auth, join rooms, publish, receive fan-out |
POST /api/v1/rooms/tokens | Mint a short-lived room_token for end-user clients (scoped rooms + caps) |
POST /api/v1/rooms/{room}/publish | Push one event into a room without holding a socket |
GET /api/v1/rooms/stats | Ops / health for the rooms hub |
End-to-end flow (two clients)
Both clients must use the same project and the same room name. Whoever joins first creates the room (no create API).
Publisher (App A) Subscriber (App B)
───────────────── ──────────────────
1. Open WS /api/v1/rooms/ws (can connect anytime)
2. → { type: "auth", access_token: "…", project_id: "…" }
3. ← { type: "ready", connection_id, capabilities }
4. → { type: "join", room: "consultation-42" }
5. ← { type: "joined", room, members, seq }
1. Open WS + auth → ready
2. → join "consultation-42"
3. ← joined
4. ← presence (A already there)
6. → { type: "publish", room, event, data }
5. ← { type: "message", event, data, seq, sender }
7. → leave / disconnect leave / disconnectTypical product flows
| Scenario | API flow |
|---|---|
| Two apps share live events | Both: WS auth → join same room → one publishes, others receive message |
| Browser as end user | Your server: POST /rooms/tokens → hand token to the browser → browser WS auth with room_token → join → listen/publish |
| Agent / server pushes a note | POST /rooms/{room}/publish while browsers are already joined on WS (they receive message without the server opening a socket) |
| Transcript while on a call | Call media + in-call chat via WebRTC SFU; transcript / app events via this WebSocket publish into the same room name |
/api/v1/rooms/wsLive rooms protocol. First frame must be auth within the auth window. Then join rooms and publish/receive JSON events.
Connection URL
wss://backend.hikigaiplatform.io/api/v1/rooms/wsFrom your App's server code, connect through HIKIGAI_PLATFORM_URL (with http replaced by ws). Browsers connect to the public address with a room_token.
Step 1 — Authenticate
Send exactly one credential as the first JSON frame. Capabilities depend on the credential:
| Credential | Capabilities |
|---|---|
App access token (+ project_id) | subscribe, publish, manage on that project's rooms. A hikigai login token gets the same, within your role. |
room_token | Only rooms + capabilities minted into the token (default subscribe + publish) |
{"type": "auth", "access_token": "<workload_token>", "project_id": "YOUR_PROJECT_ID"}
// or minted room token
{"type": "auth", "room_token": "YOUR_ROOM_TOKEN"}Success:
{
"type": "ready",
"connection_id": "conn_a1b2c3d4e5f6",
"project_id": "YOUR_PROJECT_ID",
"capabilities": ["manage", "publish", "subscribe"]
}Step 2 — Join a room
Joining creates the room if it does not exist yet. Optional last_seq asks the server to replay missed messages after a reconnect (at-least-once delivery).
{"type": "join", "room": "consultation-42"}
{"type": "join", "room": "consultation-42", "last_seq": 12}{
"type": "joined",
"room": "consultation-42",
"capabilities": ["manage", "publish", "subscribe"],
"seq": 0,
"members": [{ "id": "conn_…", "principal": "…" }]
}Other members already in the room get a presence update when you join or leave.
Step 3 — Publish and receive
event is your app-defined name; data is any JSON. By default you do not receive your own publish (echo: true to opt in). Subscribers see a message frame with a monotonic seq per room.
{"type": "publish", "room": "consultation-42", "event": "transcript.partial", "data": {"text": "Patient reports…", "finished": false}}
{"type": "publish", "room": "consultation-42", "event": "transcript.final", "data": {"text": "Patient reports mild headache.", "finished": true}, "echo": false}{
"type": "message",
"room": "consultation-42",
"event": "transcript.final",
"data": { "text": "Patient reports mild headache.", "finished": true },
"seq": 3,
"sender": "conn_xyz",
"ts": "2026-07-29T12:00:00.000Z"
}Step 4 — Leave or disconnect
{"type": "leave", "room": "consultation-42"} // leave one room
{"type": "disconnect"} // close the whole connectionClosing the browser tab also drops the connection; other members see presence / left.
Other useful frames
| Frame | Direction | Purpose |
|---|---|---|
who | → / ← | Ask for / receive current member list |
ping / pong | → / ← | Keepalive |
refresh / refreshed | → / ← | Rotate room_token without reconnecting |
kick / close_room | → | Manage capability — remove a member or close the room |
error | ← | code + message (e.g. unauthorized, forbidden, room_full, cursor_expired) |
Room name rules
1–128 characters: letters, digits, _ . : -. Must start with a letter or digit.
JavaScript sketch
// App server code (Node). In a browser, connect to the public address with a room_token instead.
const ws = new WebSocket(process.env.HIKIGAI_PLATFORM_URL.replace(/^http/, "ws") + "/api/v1/rooms/ws");
ws.onopen = () => {
ws.send(JSON.stringify({ type: "auth", access_token: accessToken, project_id: process.env.HIKIGAI_PROJECT_ID }));
};
ws.onmessage = (ev) => {
const f = JSON.parse(ev.data);
if (f.type === "ready") {
ws.send(JSON.stringify({ type: "join", room: "consultation-42" }));
} else if (f.type === "joined") {
ws.send(JSON.stringify({
type: "publish",
room: "consultation-42",
event: "note",
data: { text: "hello" },
}));
} else if (f.type === "message") {
console.log(f.event, f.data, f.seq);
} else if (f.type === "error") {
console.error(f.code, f.message);
}
};/api/v1/rooms/tokensMint a short-lived room_token for end users. Your App's server calls this with its access token, then the browser authenticates on the WebSocket with the room_token (no API key or access token in the browser).
When to use
Flow: backend mints token → ships it to the browser → browser { type: "auth", room_token } → join only the allowed rooms.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
Content-Type: application/jsonBody
{
"rooms": ["consultation-*"],
"capabilities": ["subscribe", "publish"],
"principal": "end-user-123",
"ttl_seconds": 600
}rooms supports simple globs (e.g. consultation-*). Room tokens are for the WebSocket; for WebRTC mint an SFU media token with POST /api/v1/rooms/{room}/media-token instead (see WebRTC).
cURL
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/rooms/tokens" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID" \
-H 'Content-Type: application/json' \
-d '{"rooms":["consultation-*"],"capabilities":["subscribe","publish"],"ttl_seconds":600}'/api/v1/rooms/{room}/publishPush one event into a room from your backend without opening a WebSocket. Clients that are already joined on WS receive a normal message frame.
Flow
Browsers: already WS-joined to "consultation-42"
Backend: POST /rooms/consultation-42/publish { event, data }
Browsers: ← message { event, data, seq, … }Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID
Content-Type: application/jsonBody
{
"event": "note.updated",
"data": { "text": "Labs ordered" }
}cURL Example
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/rooms/consultation-42/publish" \
-H 'Authorization: Bearer <workload_token>' \
-H 'X-Project-ID: YOUR_PROJECT_ID' \
-H 'Content-Type: application/json' \
-d '{"event": "note.updated", "data": {"text": "Labs ordered"}}'/api/v1/rooms/statsRooms hub statistics and backplane health (workload token required).
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_IDcURL Example
curl "$HIKIGAI_PLATFORM_URL/api/v1/rooms/stats" \
-H 'Authorization: Bearer <workload_token>' \
-H 'X-Project-ID: YOUR_PROJECT_ID'RoomSession in AgentSDK / AppSDK (Python or Node) to handle auth, join, publish, and the inbound frame loop without writing raw WebSocket code. See AppSDK → Rooms.WebRTC
Audio, video, and text via the platform SFU(media tracks + DataChannel hikigai-data). No rooms WebSocket required for the call. App-level JSON events (transcripts, presence) stay on the WebSocket.
The SFU uses aiortc frame-level fan-out (decode → relay → re-encode) — suited to small/medium rooms, not LiveKit-style RTP packet forwarding. Rooms are scoped by project_id:room; token publish / subscribe gate media and chat.
SFU
Audio/video are media tracks; in-call text uses DataChannel hikigai-data. Join, leave, and renegotiate all require the media JWT. Your deployed App gets an access token from POST /auth/exchange and mints the media JWT; browsers only ever receive the media JWT, never a key or access token. A peer may skip publishing mic/cam but still receive others' A/V by adding recvonly audio/video transceivers beforecreateOffer (needed so the offer has media m-lines for the SFU to attach). After ICE connects the SFU attaches other peers' media and may push{"type":"renegotiate"} on DataChannel hikigai-events. Clients must then re-offer: POST {sfu_url}/rooms/{room}/sessions/{id}/offerwith the media JWT (same as leave auth).
hikigai-data chat envelope (SFU fans out only this shape; other JSON is ignored). Requires token publish to send andsubscribe to receive:
// send
{ "type": "message", "event": "chat", "data": { "text": "hello" } }
// peers receive (SFU stamps sender / principal / ts)
{
"type": "message",
"event": "chat",
"data": { "text": "hello" },
"sender": "<participant_id>",
"principal": "<sub>",
"ts": 1710000000000
}0. POST $HIKIGAI_PLATFORM_URL/api/v1/auth/exchange (inside the deployed App)
Headers: X-API-Key: $HIKIGAI_API_KEY, X-Project-ID: $HIKIGAI_PROJECT_ID
→ { access_token, expires_in: 300, … }
1. POST /api/v1/rooms/{room}/media-token
Authorization: Bearer {access_token}
X-Project-ID: YOUR_PROJECT_ID
→ { token, sfu_url, ice_servers, turn_source, expires_in }
2. pc = new RTCPeerConnection({ iceServers })
// Publish: addTrack(mic/cam). To receive others without publishing, still add:
// pc.addTransceiver("audio", { direction: "recvonly" })
// pc.addTransceiver("video", { direction: "recvonly" })
createDataChannel("hikigai-data")
offer = createOffer() → setLocalDescription
3. POST {sfu_url}/rooms/{room}/join
Authorization: Bearer {token} // media JWT from step 1
Content-Type: application/sdp
body = offer.sdp
→ 201 + SDP answer (+ Location)
4. setRemoteDescription(answer) → media + chat live
5. Leave: DELETE {Location}
Authorization: Bearer {token}/api/v1/rooms/{room_id}/media-tokenMint SFU JWT + ICE servers from your App's server. The browser receives only the media token, then does the WHIP join.
Headers
Authorization: Bearer <access_token>
X-Project-ID: $HIKIGAI_PROJECT_ID
Content-Type: application/json<access_token> is your App's 5-minute token from POST /api/v1/auth/exchange. The SDKs get it for you.
Body
{
"capabilities": ["publish", "subscribe"],
"agent_id": null,
"metadata": {}
}Response
{
"token": "<jwt>",
"sfu_url": "<platform SFU base URL>",
"ice_servers": [
{ "urls": ["stun:…"] },
{ "urls": ["turn:…"], "username": "…", "credential": "…" }
],
"turn_source": "managed",
"expires_in": 300
}sfu_url is filled by the platform — use it as the base for WHIP join ({sfu_url}/rooms/{room}/join). Do not hardcode it.turn_source: managed | byo | stun_only. Optional body ice_servers overrides TURN for this token only.
The media token must be valid when the browser joins (expires_in, 5 minutes). A call that is already running keeps going after that; it ends when the participant leaves or access is revoked (App stopped or deleted, user signed out). Mint a new token for every join.
cURL
# Run inside the deployed App.
# 1) Get an access token (lasts 5 minutes)
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/auth/exchange" \
-H "X-API-Key: $HIKIGAI_API_KEY" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID"
# → { "access_token": "eyJ…", "expires_in": 300, ... }
# 2) Mint media token
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/rooms/call-1/media-token" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID" \
-H 'Content-Type: application/json' \
-d '{"capabilities":["publish","subscribe"]}'TURN / ICE
WebRTC needs STUN/TURN so peers behind NATs can connect. Hikigai returnsice_servers on every SFU media-token. Pass that list straight into RTCPeerConnection({ iceServers }).
How ice_servers are chosen
- Per-request override on
POST …/media-tokenbodyice_servers(or SDKiceServers) — this call only - Org BYO — Organization settings → WebRTC TURN → Bring your own
- Hikigai-managed TURN (default)
- STUN-only if nothing else is configured
Response field turn_source: managed | byo | stun_only.
Managed TURN is Hikigai's relay next to the SFU: turn:<ip>:3478 over UDP and TCP (?transport=tcp), with a username of the form <expiry>:<principal>that stays valid for 24 hours. The relay address can change when Hikigai redeploys media, so mint a media token per call and do not cache ice_servers.
Per-call override (media-token)
POST /api/v1/rooms/{room}/media-token
{
"capabilities": ["publish", "subscribe"],
"ice_servers": [
{ "urls": ["stun:stun.l.google.com:19302"] },
{
"urls": ["turn:turn.example.com:3478", "turns:turn.example.com:5349"],
"username": "user",
"credential": "secret"
}
]
}When set, overrides org BYO and managed TURN for this token only. URLs must be stun: / turn: / turns:; TURN entries need username + credential.
/api/v1/organizations/{org_id}/webrtc-turnRead org TURN mode. Secrets are never returned — only has_credential / has_shared_secret flags. Requires org:read.
Response
{
"mode": "managed",
"urls": null,
"username": null,
"has_credential": false,
"has_shared_secret": false
}cURL
curl 'https://backend.hikigaiplatform.io/api/v1/organizations/ORG_ID/webrtc-turn' \
-H 'Authorization: Bearer YOUR_ACCESS_JWT'/api/v1/organizations/{org_id}/webrtc-turnSwitch between Hikigai-managed TURN and bring-your-own coturn/provider. Requires org:update (OWNER/ADMIN). Console: Organization settings → WebRTC TURN.
Body
{
"mode": "byo",
"urls": "turn:turn.example.com:3478,turns:turn.example.com:5349",
"username": "static-user",
"credential": "static-pass"
}For mode: "byo", provide comma-separated turn:/turns: URLs plus either a static username+credential pairor a coturn REST shared_secret (ephemeral HMAC creds, valid 24 hours). Omit credential / shared_secret on later updates to keep the stored secret; set clear_credential / clear_shared_secret to wipe them.
// Back to Hikigai-managed (clears BYO material)
{ "mode": "managed" }Response
{
"mode": "byo",
"urls": "turn:turn.example.com:3478,turns:turn.example.com:5349",
"username": "static-user",
"has_credential": true,
"has_shared_secret": false
}cURL
curl -X PUT 'https://backend.hikigaiplatform.io/api/v1/organizations/ORG_ID/webrtc-turn' \
-H 'Authorization: Bearer YOUR_ACCESS_JWT' \
-H 'Content-Type: application/json' \
-d '{"mode":"byo","urls":"turn:turn.example.com:3478","username":"u","credential":"p"}'Multi-Cloud
Catalog-driven deployment targets for agents, apps, and MCP servers on GCP or AWS. Optional BYOC credentials are managed under /api/v1/cloud/credentials.
/api/v1/cloud/catalogList providers, services, regions, zones, and per-service JSON Schema. Optional workload filter: app | agent | mcp.
Request Headers
Authorization: Bearer YOUR_TOKEN # $(hikigai token)
X-Project-ID: YOUR_PROJECT_IDcURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/cloud/catalog?workload=agent' \
--header "Authorization: Bearer $(hikigai token)" \
--header 'X-Project-ID: YOUR_PROJECT_ID'/api/v1/cloud/targets/validateDry-run a deployment target (service, region, config) before deploy.
Request Body
{
"workload": "app",
"service_id": "gcp-cloud-run",
"region": "us-central1",
"config": {"cpu": "1", "memory": "512Mi"}
}/api/v1/cloud/credentials/{credential_id}Rename, enable/disable, make default, or set the deploy target of an AWS cloud account: where agents, apps and MCP servers deployed with it run. Blank fields are created in the account; settings on the deploy itself win; a target for another region is ignored. {} clears it. Organization accounts: PATCH /api/v1/organizations/{org_id}/cloud/credentials/{credential_id}.
Request Body
{
"deploy_target": {
"region": "us-east-1",
"workload_cluster": "my-apps-cluster",
"mcp_cluster": "my-mcp-cluster",
"vpc_id": "vpc-0123456789abcdef0",
"subnets": ["subnet-0a1b2c3d4e5f60718", "subnet-0f1e2d3c4b5a69788"],
"security_groups": ["sg-0123456789abcdef0"],
"mcp_security_groups": ["sg-0fedcba9876543210"]
}
}/api/v1/cloud/credentials/{credential_id}/discover?region=us-east-1List the ECS clusters and the VPCs (with subnets and security groups) in that AWS account and region, using its credential (describe/list calls only). Needs ecs:ListClusters, ecs:DescribeClusters, ec2:DescribeVpcs, ec2:DescribeSubnets, ec2:DescribeSecurityGroups. Organization accounts: GET /api/v1/organizations/{org_id}/cloud/credentials/{credential_id}/discover.
Response
{
"account": "111122223333",
"region": "us-east-1",
"clusters": [{"name": "my-apps-cluster", "arn": "arn:aws:ecs:…", "status": "ACTIVE", "services": 12, "running_tasks": 14}],
"vpcs": [{"id": "vpc-…", "name": "apps", "cidr": "10.0.0.0/16", "is_default": false,
"subnets": [{"id": "subnet-…", "availability_zone": "us-east-1a", "public": true}],
"security_groups": [{"id": "sg-…", "name": "apps-tasks"}]}],
"warnings": []
}A part the credential may not read (e.g. no ecs:ListClusters) is left empty and named in warnings; the rest is still returned. A credential that cannot be used at all returns 400.
MCP Servers
Your App can call one of your MCP servers (deployed in the project, or linked to it as a connector) directly. It first gets a short MCP token for that server from Hikigai, then sends it to the MCP server. This is a runtime route: it works from inside a deployed App, and from your computer after hikigai login.
- Agents don't need this: when an agent uses an MCP server, Hikigai adds the token for it.
- Mobile apps call
{gateway_url}/v1/mcp/{server}instead (see Mobile Apps).
How the pieces fit together (deployed App)
Your App (server code)
│
├─ 1. Get the App's token (valid 5 minutes)
│ POST $HIKIGAI_PLATFORM_URL/api/v1/auth/exchange
│ X-API-Key: $HIKIGAI_API_KEY X-Project-ID: $HIKIGAI_PROJECT_ID
│ → { access_token }
│
├─ 2. Get an MCP token for one server (valid 1 hour, only for that server)
│ POST $HIKIGAI_PLATFORM_URL/api/v1/mcp/access-token { "server": "my-mcp-server" }
│ Authorization: Bearer <access_token>
│ → { token, header, mcp_url }
│
└─ 3. Call the MCP server itself (not through Hikigai)
POST <mcp_url> X-Hikigai-Mcp-Token: <token>
body: MCP JSON-RPC (initialize, tools/list, tools/call…)
Keep the App's token about 4 minutes, then do step 1 again.
Keep the MCP token until the MCP server returns 401, then do step 2 again.Why two tokens? The App's token only works on HIKIGAI_PLATFORM_URL, so it can't be sent to the MCP server. The MCP token is like a ticket for one MCP server: it works only there, and only for 1 hour.
On your computer skip step 1: after hikigai login, use $(hikigai token) as the token in step 2. Steps 2 and 3 are the same.
With the SDK (Python)
AppClient does step 1 for you (in the App, and with hikigai login on your computer). Step 3 uses the official mcp package.
from hikigai.appsdk import AppClient
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
client = AppClient()
ticket = client.api.post("/api/v1/mcp/access-token", json={"server": "my-mcp-server"})
async with streamablehttp_client(ticket["mcp_url"], headers={ticket["header"]: ticket["token"]}) as (read, write, _):
async with ClientSession(read, write) as mcp:
await mcp.initialize()
tools = await mcp.list_tools()
result = await mcp.call_tool("my_tool", {"query": "hello"})With the SDK (Node.js)
import { AppClient } from '@hikigai/app-sdk'
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
const client = new AppClient()
const res = await client.runtimeAuth.fetch(`${client.baseUrl}/api/v1/mcp/access-token`, {
method: 'POST',
body: JSON.stringify({ server: 'my-mcp-server' }),
})
const ticket = await res.json() // { token, header, mcp_url }
const mcp = new Client({ name: 'my-app', version: '1.0.0' })
await mcp.connect(new StreamableHTTPClientTransport(new URL(ticket.mcp_url), {
requestInit: { headers: { [ticket.header]: ticket.token } },
}))
const tools = await mcp.listTools()
const result = await mcp.callTool({ name: 'my_tool', arguments: { query: 'hello' } })/api/v1/mcp/access-tokenGet a short MCP token for one MCP server. Call it through HIKIGAI_PLATFORM_URL from a deployed App.
Request Headers
Authorization: Bearer <access_token> // in the App: from /api/v1/auth/exchange (step 1)
// on your computer: $(hikigai token)
X-Project-ID: $HIKIGAI_PROJECT_ID
Content-Type: application/jsonRequest Body
{ "server": "my-mcp-server" } // MCP server slug or id, in the project or linked to itResponse
{
"token": "eyJ…", // valid 1 hour, only for this server
"header": "X-Hikigai-Mcp-Token", // send the token in this header
"mcp_url": "https://my-mcp-server-9016559f.apps.hikigaiplatform.io/…" // the server's MCP endpoint
}cURL Example (from inside your App)
# Step 1: the App's token
ACCESS_TOKEN=$(curl -s -X POST "$HIKIGAI_PLATFORM_URL/api/v1/auth/exchange" \
-H "X-API-Key: $HIKIGAI_API_KEY" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID" | jq -r .access_token)
# Step 2: the MCP token
curl -X POST "$HIKIGAI_PLATFORM_URL/api/v1/mcp/access-token" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "X-Project-ID: $HIKIGAI_PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{ "server": "my-mcp-server" }'cURL Example (from your computer)
hikigai login
curl -X POST "https://backend.hikigaiplatform.io/api/v1/mcp/access-token" \
-H "Authorization: Bearer $(hikigai token)" \
-H "Content-Type: application/json" \
-d '{ "server": "my-mcp-server" }'Errors
| HTTP | Code | Meaning |
|---|---|---|
| 401 | DEPLOY_KEY_REQUIRED | Not called from a deployed App or with a hikigai login token. |
| 403 | MCP_NOT_LINKED | No MCP server with that slug / id in the project or linked to it. |
| 409 | - | The MCP server is not deployed yet. |
<mcp_url>Call the MCP server with the token. Use your MCP client as usual (the server's transport: streamable HTTP or SSE) and add the header to every request.
Request Headers
X-Hikigai-Mcp-Token: <token>
Content-Type: application/json
Accept: application/json, text/event-streamRequest Body (example)
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }MCP clients send initialize first, then tools/list or tools/call; an MCP client library (see the SDK examples above) does this for you. The response is the MCP server's own. A missing, expired or wrong-server token gets 401 from the MCP server: get a new MCP token (step 2).
Mobile Apps (Android & iOS)
Register an Android or iOS app and it gets its own gateway URL. The app calls agents, rooms, WebRTC and MCP servers there, with an App Check token that proves it is your real app. There are two groups of endpoints, used by different people at different times:
| Group | Who calls it | When |
|---|---|---|
Manage/api/v1/projects/{project_id}/mobile-apps/… | You (the developer), from a script or CI. Never the phone. | Once, while setting up. These do exactly what the console buttons do (Register, Save settings, Download config, Create token), so if you use the console you don't need them. |
From the app{gateway_url}/v1/… | Your mobile app. | While people use it: App Check about once an hour, the rest whenever the app needs them. |
Where do I get my gateway URL?
It is created when you register the app and shown once the app is Live. Any of these gives it to you:
- The config file you download and add to your app:
gateway_urlinhikigai-services.json(Android),GATEWAY_URLinHikigaiService-Info.plist(iOS). Your app reads it from there. - The console: the URL at the top of your mobile app's page, under its name.
- The API:
proxy.urlinGET /api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}.
Everywhere below, replace {gateway_url} with it. For example, if it is https://android-acme-care-backend-9016559f.apps.hikigaiplatform.io:
{gateway_url}/v1/app-check/exchange
→ https://android-acme-care-backend-9016559f.apps.hikigaiplatform.io/v1/app-check/exchange
{gateway_url}/v1/agents/cpt2-code-agent/invoke
→ https://android-acme-care-backend-9016559f.apps.hikigaiplatform.io/v1/agents/cpt2-code-agent/invokeIt stays the same when the app is redeployed. Each registered app (Android, iOS) has its own.
Manage mobile apps
Headers for all of these: Authorization: Bearer <token> (console session, or your hikigai login token). Mobile apps need Pro or a team organization.
How the pieces fit together
You (setup, once) ──calls──► Hikigai (console, or a script / CI)
│
├─ 1. Register
│ POST /api/v1/projects/{project_id}/mobile-apps → status "provisioning"
│
├─ 2. Wait until it is Live
│ GET /api/v1/projects/{project_id}/mobile-apps/{id} → status "active", proxy.url = gateway URL
│
├─ 3. Config file for the app
│ GET /api/v1/projects/{project_id}/mobile-apps/{id}/config
│
├─ 4. Debug token for development (shown once)
│ POST /api/v1/projects/{project_id}/mobile-apps/{id}/debug-tokens
│
└─ Later (any time)
PATCH …/mobile-apps/{id} change what it may use, App Check, sign-in
POST …/mobile-apps/{id}/redeploy redeploy its gateway
GET …/mobile-apps/{id}/debug-tokens list · DELETE …/debug-tokens/{token_id} revoke
DELETE …/mobile-apps/{id} delete the app/api/v1/projects/{project_id}/mobile-appsRegister an Android or iOS app. Returns 201 with the mobile app; its gateway is ready when status is "active" (a few minutes).
Request Body
{
"platform": "android", // "android" | "ios"
"app_identifier": "com.acme.care", // package name / bundle ID; can't be changed
"nickname": "Acme Care", // optional
"sha256_fingerprints": ["AB:CD:…"], // Android: signing keys allowed (debug keys; Play app-signing + upload key)
"play_integrity_service_account": "{…}", // Android: service-account JSON (as a string), for phones with Google Play
"apple_team_id": "ABCDE12345", // iOS
"environment": "development", // default "development" (debug tokens work); promote with PATCH later
"allowed_agents": ["cpt2-code-agent"], // starts empty = no access; "*" = all agents in the project
"allowed_mcp_servers": [], // starts empty; "*" = all MCP servers in or linked to the project
"allowed_rooms": ["consult-1", "visit-*"], // room names or prefix patterns; "*" = every room; starts empty = no rooms
"require_user_login": false,
"app_check_mode": "enforce" // "enforce" | "monitor" (both reject; monitor also logs failures)
}Response
{
"id": "0f16d821-…",
"project_id": "9016559f-…",
"public_app_id": "1:9016559f:android:0f16d82127f64e7e",
"platform": "android",
"nickname": "Acme Care",
"app_identifier": "com.acme.care",
"sha256_fingerprints": ["AB:CD:…"],
"has_play_integrity_key": false,
"apple_team_id": null,
"unknown_attestation_roots": [], // Android phones without Google Play refused for an untrusted manufacturer root
"allowed_agents": ["cpt2-code-agent"],
"allowed_mcp_servers": [],
"allowed_rooms": ["consult-1"],
"require_user_login": false,
"app_check_mode": "enforce",
"environment": "development",
"status": "provisioning", // provisioning | active | failed | stopped
"proxy": { "status": "building", "url": null, ... }, // url = gateway_url once active
"warnings": ["Add the Play Integrity service-account key so phones with Google Play can be verified."],
"created_at": "2026-10-16T07:40:00Z"
}/api/v1/projects/{project_id}/mobile-appsList the project's mobile apps.
Same objects as above.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}Get one mobile app.
Same object as above.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}Change settings. Send only the fields to change: everything in the register body except platform and app_identifier. The app picks up changes within a minute.
{ "allowed_agents": ["cpt2-code-agent"], "require_user_login": true }
// Promote a development registration (it can add missing settings in the same request)
{ "apple_team_id": "ABCDE12345", "environment": "production" }Changing a security setting (allowlists, login rule, App Check mode, fingerprints, keys, Team ID, environment) ends every phone's session; phones do App Check again. A nickname change does not. Promoting to production revokes all debug tokens. Production can't go back to development.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/configDownload the config file: hikigai-services.json (Android) or HikigaiService-Info.plist (iOS). Available once status is active.
{
"config_version": 1,
"project_id": "9016559f-…",
"mobile_app_id": "1:9016559f:android:0f16d82127f64e7e",
"platform": "android",
"package_name": "com.acme.care", // iOS: "bundle_id" (plist keys: PROJECT_ID, BUNDLE_ID, GATEWAY_URL, …)
"gateway_url": "https://android-acme-care-backend-9016559f.apps.hikigaiplatform.io"
}Nothing in it is secret. It does not change when the app is redeployed.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/redeployRedeploy the app's gateway (e.g. to pick up a platform update). Returns 202.
{ "deployment_id": "…", "status": "deploying" }/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/debug-tokensCreate a debug token for development builds (development registrations only). The token is returned once (201).
Request Body
{
"name": "Pixel 8 (QA)",
"kind": "device" // "device" (default, 24 h) | "emulator" (iOS Simulator 24 h, Android emulator 6 h)
}Response
{
"id": "…",
"name": "Pixel 8 (QA)",
"kind": "device",
"token_prefix": "hkdbg_Ul0D",
"token": "hkdbg_…", // only in this response
"created_at": "…",
"expires_at": "…",
"last_used_at": null,
"revoked": false
}- device: accepted only together with device proof from this registration's app: Play Integrity or Key Attestation showing this package name and a registered signing key (Android), or App Attest for this Team ID and bundle ID (iOS). A token copied into another app is refused. With the token, unlocked test phones are accepted. Expires after 24 hours.
- emulator, iOS: accepted without device proof, for the iOS Simulator. Anyone holding it can use it until it expires (24 hours).
- emulator, Android: for emulators with a Google Play system image. Accepted only with a Play Integrity token for this package name, bound to a fresh challenge; Google can't check the signing key on an emulator, so that check is skipped. Key Attestation is not accepted with it. Expires after 6 hours.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/debug-tokensList debug tokens (without the token itself).
Same objects as above, without token.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/debug-tokens/{token_id}Revoke a debug token. New exchanges and the sessions it created are refused.
Never ship a debug token in a release build.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/revoke-sessionsEnd every phone's session (and open calls). Phones do App Check again.
{ "success": true }/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/sessionsList live sessions (up to 100, newest first).
[{ "id": "…", "subject": "android:…", "method": "play_integrity", "expires_at": "…" }]/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/sessions/{session_id}End one session.
{ "success": true }/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/devicesiOS: list App Attest keys (one per app install), most recently used first.
[{ "id": "…", "environment": "production", "last_used_at": "…", "revoked": false }]/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}/devices/{device_id}iOS: revoke one App Attest key and end its sessions.
The same phone can register a new key, so this doesn't ban a person. To block someone, turn on require_user_login and disable their account.
/api/v1/projects/{project_id}/mobile-apps/{mobile_app_id}Delete the mobile app and its gateway. The app on phones stops working.
{ "success": true, "message": "Mobile app 'Acme Care' deleted" }From the app (gateway URL)
The phone calls {gateway_url} from the config file. First it gets an App Check token, then it sends that token on every other call.
How the pieces fit together
Your mobile app ──calls──► {gateway_url} (from the config file)
│
├─ 1. App Check (every 15 minutes)
│ POST /v1/app-check/challenge one-time challenge (skip only with an iOS emulator token)
│ └─ Google / the phone / Apple sign it Play Integrity · Key Attestation · App Attest
│ POST /v1/app-check/exchange challenge + signed result (+ debug token on development builds)
│ → app_check_token (15 minutes; debug: 5 minutes)
│
├─ 2. Sign-in (if your app has users) header X-Hikigai-App-Check: <app_check_token>
│ POST /v1/auth/login email + password → id_token, access_token, refresh_token
│ POST /v1/auth/refresh new tokens (id tokens last 1 hour)
│ GET /v1/auth/me the signed-in user: name, role, metadata
│ POST /v1/auth/me/metadata the user updates their own metadata.user_data
│ POST /v1/auth/secrets/set, get, delete the user's own short-lived private values
│ POST /v1/auth/logout sign out everywhere
│ POST /v1/auth/forgot-password, reset-password, change-password, signup, confirm,
│ mfa/respond, mfa/associate, mfa/verify, mfa/set-preference, sso/authorize-url, sso/token, qr-login
│ Users live in the app's User Management tab. The phone never names a user list.
│
└─ 3. Everything else headers X-Hikigai-App-Check + Authorization: Bearer <id_token> (when sign-in is required)
POST /v1/agents/{agent}/invoke full answer
POST /v1/agents/{agent}/stream streamed answer
POST /v1/agents/{agent}/live/session live voice session
POST /v1/rooms/{room}/token join a WebSocket room
POST /v1/webrtc/{room}/media-token join a WebRTC call
POST /v1/mcp/{server} MCP request
GET /v1/external/{KEY}/{path} a third-party API; the gateway adds the key KEY
/v1/notifications/* register for notifications, live stream, inbox (see Notifications)
After 15 minutes, or on 401 → do step 1 again. A call that is already open
keeps running until it ends or the session is revoked.Headers on every call except challenge / exchange:
X-Hikigai-App-Check: <app_check_token> // every call except challenge / exchange
Authorization: Bearer <id_token from /v1/auth/login> // only when require_user_login is on (and for /v1/auth/me, /v1/auth/me/metadata, /v1/auth/secrets/*, /v1/auth/logout)
Content-Type: application/json{gateway_url}/v1/app-check/challengeGet a one-time challenge for Play Integrity / Key Attestation / App Attest. Valid 5 minutes, one use. Not needed for emulator tokens.
{ "challenge": "q8Xr…", "expires_in": 300 }{gateway_url}/v1/app-check/exchangeProve it's your real app and get an App Check token (valid 15 minutes; 5 minutes with a debug token). Send one of these bodies:
// Android with Google Play: Play Integrity (standard request with requestHash = challenge)
{ "platform": "android", "challenge": "q8Xr…", "integrity_token": "…" }
// Android without Google Play: Key Attestation (attestation challenge = UTF-8 bytes of the challenge;
// the key's certificate chain from KeyStore.getCertificateChain, leaf first, each base64 DER)
{ "platform": "android", "challenge": "q8Xr…", "key_attestation": ["MIIC…", "MIIC…", "MIIF…"] }
// iOS, App Attest, first time on a device (clientDataHash = SHA-256 of the challenge)
{ "platform": "ios", "challenge": "q8Xr…", "key_id": "…", "attestation": "<base64>" }
// iOS, App Attest, after that
{ "platform": "ios", "challenge": "q8Xr…", "key_id": "…", "assertion": "<base64>" }
// Development builds: any body above plus the device debug token
{ "platform": "android", "challenge": "q8Xr…", "integrity_token": "…", "debug_token": "hkdbg_…" }
// Android emulator (Google Play image): Play Integrity plus an emulator token
{ "platform": "android", "challenge": "q8Xr…", "integrity_token": "…", "debug_token": "hkdbg_…" }
// iOS Simulator (no App Attest): emulator token only
{ "debug_token": "hkdbg_…" }Response
{ "app_check_token": "eyJ…", "expires_in": 900, "verified": true }- Every proof must show the registered package name and a registered signing key (Team ID and bundle ID on iOS). APKs installed outside Google Play, for example shared through Google Drive, are accepted; register the key that signed them (usually your upload key).
- Without a debug token, the phone must also pass the device check: Play Integrity's device integrity, or for Key Attestation a hardware-backed key, a locked bootloader and verified boot. Emulators are refused.
- Key Attestation is trusted for Google-certified phones. Phones whose attestation comes from another manufacturer's root are refused and listed in the app's
unknown_attestation_rootsuntil Hikigai adds that root.
A refused exchange returns 401 APP_CHECK_FAILED with the reason, in both enforce and monitor mode (monitor also logs each failure). A device debug token sent without device proof is refused the same way. Too many challenge or exchange requests from one address, or for the app as a whole, return 429; 503 means the check is briefly unavailable (try again).
{gateway_url}/v1/auth/loginSign a user in with email + password. The user must exist in the app's User Management tab (the platform picks that user list; an app_id in the body is ignored).
{ "email": "pat@clinic.com", "password": "…" }
→ 200 { "status": "authenticated", "id_token": "eyJ…", "access_token": "eyJ…", "refresh_token": "eyJ…",
"expires_in": 3600, "token_type": "Bearer", "user_id": "…" }
→ 200 { "status": "challenge", "challenge_name": "SOFTWARE_TOKEN_MFA", "session": "…" } // then POST /v1/auth/mfa/respond { email, session, code }
→ 401 Invalid credentials · 423 account locked · 429 too many attempts from this addressSave all three tokens. Send the ID token as Authorization: Bearer on later calls. ID tokens last 1 hour; refresh tokens 30 days.
{gateway_url}/v1/auth/signupLet a person create their own account in the app's User Management. They confirm it with the emailed code (POST /v1/auth/confirm { email, code }), then sign in.
{ "email": "pat@clinic.com", "password": "…", "first_name": "Pat", "last_name": "Lee",
"profile": { // optional, every field optional
"phone": "+14155550123", "birth_date": "1990-04-02", "gender": "female",
"street": "1 Main St", "city": "Austin", "state": "TX", "country": "USA", "postal_code": "73301",
"emergency_contact_name": "Sam Lee", "emergency_contact_relationship": "Brother",
"emergency_contact_phone": "+14155550199" } }
→ 201 { "user_id": "…", "email": "pat@clinic.com", "confirmed": false }
→ 422 a role, metadata or attributes in the body, or a profile field that isn't validprofile is stored as metadata.profile and shows in /v1/auth/me. Phones are E.164, birth_date is YYYY-MM-DD and not in the future, gender is male, female, other or unknown; other fields are refused. It is only what the person typed: role and the rest of metadata are set by admins in User Management.
{gateway_url}/v1/auth/refreshNew ID and access tokens before the old ones expire (every hour).
{ "refresh_token": "eyJ…" }
→ 200 { "status": "authenticated", "id_token": "eyJ…", "access_token": "eyJ…", "expires_in": 3600 } // keep your existing refresh_token{gateway_url}/v1/auth/meThe signed-in user. Send Authorization: Bearer <id_token>. Role and metadata are what you set in User Management.
→ 200 { "end_user_id": "…", "email": "pat@clinic.com", "first_name": "Pat", "last_name": "Lee",
"role": "Patient", "metadata": { "fhir_id": "…" }, "verified_at": "…" }
→ 401 LOGIN_REQUIRED (no token) · 401 token invalid, expired, or the user was disabled{gateway_url}/v1/auth/me/metadataThe signed-in user updates their own details, stored under user_data in their metadata. Send Authorization: Bearer <id_token>; the user is always the one the token belongs to.
{ "user_data": { "preferences": { "units": "metric" }, "old_key": null } }
→ 200 same shape as GET /v1/auth/me, with the updated metadata, e.g.
"metadata": { "fhir_id": "…", "user_data": { "preferences": { "units": "metric" } } }
→ 401 no or invalid user token · 422 a field other than user_data, or a key name that isn't 1–64 characters
→ 400 the whole metadata would exceed 2048 charactersTop-level keys in user_data are set, null removes a key, and other existing user_data keys are kept (at most 50 keys per call). Only user_data can be changed this way; every other metadata key is set by admins in User Management. The change shows in User Management like an admin edit. Works on already deployed gateways (no redeploy).
{gateway_url}/v1/auth/secrets/setKeep a short-lived private value for the signed-in user, such as a session with another service that should survive an app reinstall. Send Authorization: Bearer <id_token>.
{ "name": "partner.session", "value": "…", "expires_in_seconds": 3600 } // 60–86400, default 3600
→ 200 { "name": "partner.session", "expires_at": "2026-11-11T13:00:00+00:00" } // the value is never echoed
POST {gateway_url}/v1/auth/secrets/get { "name": "partner.session" }
→ 200 { "name": "partner.session", "value": "…", "expires_at": "…" }
→ 404 NOT_FOUND (none, or it expired)
POST {gateway_url}/v1/auth/secrets/delete { "name": "partner.session" }
→ 200 { "success": true } // also when there was noneValues are kept encrypted on the user's own Cognito record (a hidden attribute the app cannot read, so never in metadata or tokens), returned only to the same user of the same app until they expire, and shown in the console by name and expiry only. Names match ^[a-z0-9][a-z0-9_.-]{0,63}$; all of one user's values together must stay under roughly 1,400 characters (400 otherwise, earlier values kept). Expired values are dropped automatically, and deleting the user in User Management deletes their values. Not available when the gateway App's users are in GCP Identity Platform (400).
{gateway_url}/v1/auth/logoutSign the user out everywhere (their refresh tokens stop working). Send Authorization: Bearer <id_token>, then delete the saved tokens.
→ 200 { "success": true, "message": "Logged out" }{gateway_url}/v1/auth/forgot-passwordEmail the user a reset code. Always answers 200, so it never reveals whether an email exists.
{ "email": "pat@clinic.com" }
// then
POST {gateway_url}/v1/auth/reset-password { "email": "pat@clinic.com", "code": "123456", "new_password": "…" } (8+ characters)Also: POST /v1/auth/change-password { access_token, current_password, new_password }, POST /v1/auth/signup { email, password, first_name?, last_name? } (roles and metadata cannot be chosen at sign-up; set them in User Management), /v1/auth/confirm, /v1/auth/mfa/*, /v1/auth/sso/* and /v1/auth/qr-login: same bodies as the App Identity routes, without app_id.
{gateway_url}/v1/agents/{agent}/invokeCall an agent (by slug) and get the full answer. Same request and response as Agent Invocation.
{ "message": "Patient seen for a 30 minute follow-up of hypertension…" }Also: POST {gateway_url}/v1/agents/{agent}/stream (server-sent events, as in Streaming) and POST {gateway_url}/v1/agents/{agent}/live/session (as in Live Sessions).
{gateway_url}/v1/rooms/{room}/tokenGet a 10-minute room token (subscribe + publish) for this device or signed-in user, then join the room as in Rooms → WebSocket.
No body needed for a room of the app's own project.
An App in another project of the same organisation, which the user signed in to: send that App's project and app ID, and the user's sign-in token for it. Nothing is configured: the platform issues a token for that one room only when App Check passes, the sign-in token is valid for that App, the project is in the same organisation, and the room matches the registration's room names (* never counts across projects).
POST {gateway_url}/v1/rooms/visit-1ee722c0/token
X-Hikigai-App-Check: <token>
Authorization: Bearer <the user's sign-in token for that App>
{ "project_id": "<that App's project>", "app_id": "<that App>" }{gateway_url}/v1/webrtc/{room}/media-tokenGet a media token to join a WebRTC call, then connect as in Rooms → WebRTC.
{ "capabilities": ["publish", "subscribe"], "metadata": { "display_name": "Dr. Rao" } } // optional{gateway_url}/v1/mcp/{server}Send an MCP (JSON-RPC) request to one of your MCP servers. The response is the MCP server's own response; pass back Mcp-Session-Id if it returns one.
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }The phone's own X- headers go to the MCP server as that server's per-call credentials, like headers in an agent's connectors: for example x-service-base-url and x-service-token with the user's own token for that service. At most 16, of up to 8 KB each. X-Hikigai-*, X-Project-Id, X-API-Key, X-Forwarded-* and X-Real-IP are never passed on; the gateway sets the platform's own MCP token itself.
{gateway_url}/v1/external/{KEY}/{path}Call a third-party API (weather, air quality, maps…) without shipping its key. In the gateway's Environment tab set KEY (the API key, or a whole Apple .p8 file) and KEY_HOST (the API's address, e.g. api.openweathermap.org). The gateway adds the key and sends the call to KEY_HOST only. GET or POST.
GET {gateway_url}/v1/external/OPENWEATHER_API_KEY/data/2.5/air_pollution/forecast?lat=17.38&lon=78.48
X-Hikigai-App-Check: <token>
X-Hikigai-External-Auth: query appid
X-Hikigai-External-Cache: 600 // optional: keep a successful GET answer this many seconds (max 3600)
GET {gateway_url}/v1/external/WEATHERKIT_PRIVATE_KEY/api/v1/weather/en/17.38/78.48?dataSets=currentWeather
X-Hikigai-External-Auth: apple-jwt <Key ID> <Team ID> <Services ID>
// The answer is the API's own status and body, with the key removed from it.
// Errors from the gateway: see the table below.X-Hikigai-External-Auth says how the API takes the key: query <param>, header <name>, bearer, or apple-jwt <Key ID> <Team ID> <Services ID> (the gateway signs a 1-hour ES256 token with the .p8 key). The key only ever goes to KEY_HOST over https, never to a private address; it is removed from the API's answer and never reaches the phone. A key without a KEY_HOST, platform variables (HIKIGAI_, MOBILE_, NODE_, PORT) and _HOST entries can't be used.
Errors from the gateway
Shape: { "detail": { "code": "…", "message": "…" } }. Anything else comes from the agent or platform, passed through as it is.
| HTTP | Code | Meaning |
|---|---|---|
| 401 | APP_CHECK_REQUIRED | Missing or expired App Check token: get a new one. |
| 401 | APP_CHECK_FAILED | Exchange refused: bad, revoked or proof-less debug token, failed Play Integrity / Key Attestation / App Attest, or a used / expired challenge. |
| 401 | LOGIN_REQUIRED | Sign-in is required: send the user's sign-in token. |
| 403 | NOT_ALLOWED | The agent or MCP server is not allowed for this app. |
| 400 | BAD_PATH | External API path is malformed (e.g. an encoded / or .). |
| 400 | BAD_AUTH | Missing or invalid X-Hikigai-External-Auth. |
| 404 | NOT_FOUND | Unknown route, or the external API key isn't set up (KEY or KEY_HOST missing). |
| 405 | METHOD_NOT_ALLOWED | External APIs take GET or POST. |
| 429 | RATE_LIMITED | More than 120 requests a minute from one device or user, more than 20 sign-in requests a minute from one address, or more than 600 a minute to one external API key. |
| 502 | EXTERNAL_UNREACHABLE | The external API could not be reached. |
| 503 | KEY_INVALID | The key can't sign Apple tokens: paste the whole .p8 file in the Environment tab and Redeploy. |
| 503 | APP_CHECK_FAILED | App Check briefly unavailable: try again. |
Webhooks (Event Bus)
Project-scoped webhook subscriptions for platform CloudEvents (agent deploy/delete, jobs, invocations, storage, streams, rooms, WebRTC, identity verification). Deliveries are HMAC-SHA256 signed. These are runtime routes: call them from a deployed App with its workload token or from your computer with your hikigai login token, or manage subscriptions from the console.
/api/v1/webhooksList webhook subscriptions for the project.
Request Headers
Authorization: Bearer <workload_token>
X-Project-ID: YOUR_PROJECT_ID/api/v1/webhooksCreate a webhook subscription. The signing secret is returned once.
Request Body
{
"url": "https://ci.example.com/hooks/hikigai",
"event_types": ["agent.deployed", "agent.deleted"],
"description": "deploy notifications"
}/api/v1/webhooks/{id}/testSend a synthetic webhook.test ping to verify the endpoint.
Manage, rotate, test and redeliver: see Webhooks: manage & deliveries.
Webhooks: manage & deliveries
After creating a subscription, read it, change it, pause it, rotate its secret, send a test, and see or retry each delivery. Same headers as the other webhook routes: Authorization: Bearer <token> and X-Project-ID. Reads need the read scope and changes the manage scope (otherwise 403); a deployed App's workload token has both. A webhook of another project answers 404 Webhook not found.
SDK methods
client.events on AgentClient or AppClient, in Python and Node.
| Route | Python | Node |
|---|---|---|
POST /api/v1/webhooks | create_webhook(url, event_types, description=None) | createWebhook({ url, eventTypes, description }) |
GET /api/v1/webhooks | list_webhooks() | listWebhooks() |
GET /api/v1/webhooks/{webhook_id} | get_webhook(webhook_id) | getWebhook(webhookId) |
PATCH /api/v1/webhooks/{webhook_id} | update_webhook(webhook_id, url=, event_types=, description=, is_active=) | updateWebhook(webhookId, { url, eventTypes, description, isActive }) |
DELETE /api/v1/webhooks/{webhook_id} | delete_webhook(webhook_id) | deleteWebhook(webhookId) |
POST …/{webhook_id}/rotate-secret | rotate_secret(webhook_id) | rotateSecret(webhookId) |
POST …/{webhook_id}/test | test_webhook(webhook_id) | testWebhook(webhookId) |
GET …/{webhook_id}/deliveries | list_deliveries(webhook_id, status=None, limit=50) | listDeliveries(webhookId, { status, limit }) |
POST …/deliveries/{delivery_id}/redeliver | redeliver(webhook_id, delivery_id) | redeliver(webhookId, deliveryId) |
| Verify a delivery (no network) | verify_webhook_signature, parse_webhook_event | verifyWebhookSignature, parseWebhookEvent |
/api/v1/webhooks/{webhook_id}Get one subscription. The signing secret is never returned here.
curl 'https://backend.hikigaiplatform.io/api/v1/webhooks/WEBHOOK_ID' \
--header 'Authorization: Bearer <token>' \
--header 'X-Project-ID: YOUR_PROJECT_ID'
→ 200 {
"id": "…",
"project_id": "…",
"url": "https://ci.example.com/hooks/hikigai",
"description": "deploy notifications",
"event_types": ["agent.deployed", "agent.deleted"],
"is_active": true,
"created_at": "2026-11-19T10:00:00+00:00",
"updated_at": "2026-11-19T10:00:00+00:00"
}GET /api/v1/webhooks returns { "webhooks": [ … ] } in this shape, oldest first.
/api/v1/webhooks/{webhook_id}Change a subscription. Send only the fields to change; the secret stays the same.
{
"url": "https://ci.example.com/hooks/hikigai-v2", // 8–2000 characters
"event_types": ["agent.*", "job.failed"], // 1–20 patterns
"description": "deploys and failed jobs", // up to 255 characters
"is_active": false // pause deliveries; true resumes
}
→ 200 the updated subscription (same shape as GET)
→ 400 unsupported pattern, or a URL that is not https or resolves to a private address
→ 422 a field outside the limits abovePatterns are * or globs rooted in job, stream, agent, invocation, storage, room, webrtc or identity (for example job.*). The same checks apply at creation, where a project can have up to 20 subscriptions. While a subscription is paused, new events are not queued for it and its due deliveries are marked dead instead of sent.
/api/v1/webhooks/{webhook_id}Delete a subscription. Deliveries still waiting for it are not sent.
→ 200 { "message": "Webhook deleted" }
→ 404 Webhook not found/api/v1/webhooks/{webhook_id}/rotate-secretIssue a new signing secret. It is returned only in this answer; the old secret stops working at once.
→ 200 { "id": "…", "secret": "whsec_…" }Every attempt is signed when it is sent, so retries of older events are signed with the new secret too.
/api/v1/webhooks/{webhook_id}/testSend a synthetic webhook.test event to this endpoint now and wait for the answer.
→ 200 {
"delivered": true, // false when the endpoint answered non-2xx or timed out
"delivery": {
"id": "…", "subscription_id": "…", "event_id": "…", "event_type": "webhook.test",
"status": "success", // or "failed" (retried later) / "dead"
"attempts": 1, "response_status": 200, "last_error": null,
"next_attempt_at": null, "created_at": "…", "delivered_at": "…"
}
}
→ 409 Webhook is paused. Resume it (PATCH is_active=true) first./api/v1/webhooks/{webhook_id}/deliveriesRecent deliveries for one subscription, newest first.
GET /api/v1/webhooks/WEBHOOK_ID/deliveries?status=dead&limit=50
→ 200 { "deliveries": [ { "...": "same shape as delivery above" } ] }limit 1–200 (default 50). status: pending, delivering, success, failed (another try at next_attempt_at) or dead (no more tries). last_error holds the endpoint's status and the start of its answer.
/api/v1/webhooks/{webhook_id}/deliveries/{delivery_id}/redeliverSend one delivery again now, for example a dead one after you fixed the endpoint. Any status except in-flight; a delivered one is sent again too.
→ 200 { "delivered": true, "delivery": { "...": "..." } }
→ 404 Delivery not found
→ 409 Delivery already in flight, or the webhook is paused (resume it first)Receiving deliveries
Each matching event is sent as POST to your URL with the CloudEvents envelope as the JSON body. Answer with any 2xx within 10 seconds. Anything else is retried with growing waits (30 s, 60 s, 120 s…, at most 1 hour) up to 8 attempts by default, then the delivery is dead. Delivery is at least once: skip an id you already handled.
POST https://ci.example.com/hooks/hikigai
Content-Type: application/json
User-Agent: hikigai-webhooks/1.0
X-Hikigai-Event-Id: <event id>
X-Hikigai-Event-Type: agent.deployed
X-Hikigai-Delivery-Id: <delivery id>
X-Hikigai-Timestamp: 1763546400
X-Hikigai-Signature: t=1763546400,v1=<hex HMAC-SHA256 of "1763546400.<raw body>" with the secret>Check the signature on the raw body before parsing it. The SDK helpers reject a bad, missing or older-than-300-seconds signature:
# Python (hikigai.agentsdk or hikigai.appsdk)
from hikigai.appsdk import parse_webhook_event
event = parse_webhook_event(
secret=os.environ["HIKIGAI_WEBHOOK_SECRET"],
signature_header=request.headers["X-Hikigai-Signature"],
body=request.get_data(as_text=True), # raw body, as received
) # raises SignatureVerificationError → answer 400
// Node (@hikigai/agent-sdk or @hikigai/app-sdk)
import { parseWebhookEvent } from '@hikigai/app-sdk'
const event = parseWebhookEvent({
secret: process.env.HIKIGAI_WEBHOOK_SECRET!,
signatureHeader: req.headers['x-hikigai-signature'] as string,
body: rawBody, // raw body string, not re-serialized JSON
})Mobile gateway: more routes
More routes a phone calls on its gateway URL. Send X-Hikigai-App-Check as on every gateway call.
Account, MFA, SSO and QR sign-in
These work before sign-in, also when the app requires it. Bodies are JSON; an app_id in them is ignored, because users always come from the app's User Management. All /v1/auth/* calls share a limit of 20 a minute per address (429 RATE_LIMITED). Errors: 400 invalid request · 401 wrong code or credentials · 404 no such user · 409 other sign-in errors · 423 account locked (with Retry-After) · 503 identity provider unavailable · 422 a missing or invalid field.
{gateway_url}/v1/auth/confirmConfirm a self-sign-up account with the emailed code.
{ "email": "pat@clinic.com", "code": "123456" }
→ 200 { "success": true, "message": "Account confirmed" }{gateway_url}/v1/auth/change-passwordThe signed-in user changes their password. Send the access_token from sign-in (not the ID token).
{ "access_token": "eyJ…", "current_password": "…", "new_password": "…" } // new_password: 8+ characters
→ 200 { "success": true, "message": "Password changed successfully" }{gateway_url}/v1/auth/mfa/respondFinish a sign-in that answered status 'challenge' with the user's authenticator code.
{ "email": "pat@clinic.com", "session": "<session from /v1/auth/login>", "code": "123456" }
→ 200 { "status": "authenticated", "id_token": "eyJ…", "access_token": "eyJ…", "refresh_token": "eyJ…",
"expires_in": 3600, "token_type": "Bearer", "user_sub": "…", "user_id": "…" }{gateway_url}/v1/auth/mfa/associateStart authenticator-app (TOTP) setup for the signed-in user. Show secret_code as an otpauth:// QR code.
{ "access_token": "eyJ…" }
→ 200 { "secret_code": "JBSWY3DP…", "session": "…" }
// then
POST {gateway_url}/v1/auth/mfa/verify { "access_token": "eyJ…", "code": "123456", "device_name": "Pat's phone", "session": "…" }
→ 200 { "status": "SUCCESS" } // device_name and session are optional
POST {gateway_url}/v1/auth/mfa/set-preference { "access_token": "eyJ…", "enabled": true } // false turns MFA off
→ 200 { "success": true, "message": "MFA preference updated" }{gateway_url}/v1/auth/sso/authorize-urlGet the hosted sign-in page URL (for example Google) to open in the system browser.
{ "redirect_uri": "https://acmecare.example.com/auth/callback", "provider": "Google", "scopes": ["openid", "email", "profile"] }
→ 200 { "authorize_url": "https://…/oauth2/authorize?…" } // provider and scopes are optional
// after the browser returns to redirect_uri with ?code=…
POST {gateway_url}/v1/auth/sso/token { "code": "<code>", "redirect_uri": "https://acmecare.example.com/auth/callback" }
→ 200 same tokens as /v1/auth/login{gateway_url}/v1/auth/qr-loginSign in by scanning a QR badge issued to the user from User Management.
{ "qr_payload": "HKG2…" }
→ 200 same tokens as /v1/auth/loginNotification topics, user facts, unregister
Same headers as the other mobile notification routes, including X-Hikigai-Installation-Id (400 BAD_INSTALLATION_ID without it) and Authorization: Bearer <id_token> when the app requires sign-in. Register first: an unknown install gets 404 DEVICE_NOT_REGISTERED, and an install registered by another user gets 403 DEVICE_OF_OTHER_USER.
{gateway_url}/v1/notifications/topicsTopics this install is on, and every topic in the organization that lets phones join.
→ 200 {
"subscribed": ["lab-results"],
"available": [ { "name": "lab-results", "description": "…" }, { "name": "news", "description": "…" } ]
}{gateway_url}/v1/notifications/topics/{name}/subscribeJoin a topic (or leave it with /unsubscribe). No body. Only topics set to let phones join or leave.
POST {gateway_url}/v1/notifications/topics/lab-results/subscribe
POST {gateway_url}/v1/notifications/topics/lab-results/unsubscribe
→ 200 { "topics": ["lab-results"] } // the install's topics afterwards
→ 403 SUBSCRIBE_NOT_ALLOWED · 404 TOPIC_NOT_FOUNDNames are 1–100 lowercase letters, digits, ., _ or -, starting with a letter or digit; other names get 404 NOT_FOUND from the gateway.
{gateway_url}/v1/notifications/propertiesFacts about the signed-in user for message placeholders and segments. Merged into what is there; null removes a fact.
{ "properties": { "first_name": "Pat", "plan": "premium", "old_fact": null } }
→ 200 { "properties": { "first_name": "Pat", "plan": "premium" } } // all facts after the change
→ 400 BAD_PROPERTIES a name that isn't 1–64 characters or contains ".", or more than 8192 bytes in all
→ 403 LOGIN_REQUIRED the mobile app does not require sign-inA phone cannot replace all facts at once; that is the server-side PUT /api/v1/notifications/users/{user_id}/properties.
{gateway_url}/v1/notifications/devicesStop notifications to this install, for example on sign-out. POST /v1/notifications/devices turns it back on.
→ 200 { "success": true }Notifications
Send notifications to phones (iOS and Android), browsers (web push) and other apps (topic webhooks), now or on a schedule. No Firebase account is needed: iPhones go through Apple with your own key, Android phones use your Google key if you add one (or fetch their messages from the gateway), and browsers use web push with a key the platform makes for your organization. These are runtime routes: call them from a deployed App with its workload token or from your computer with your hikigai login token. The console has the same features on the project's Notifications tab.
- Topic: a named channel shared by every project of the organization (e.g.
lab-results). It lists which Apps may publish (app:<app_id>or*) and whether apps may subscribe their users' devices. A deployed App must publish to a topic that lists it; console users andhikigai loginmay also send without a topic. - Device: one phone install or one browser, with its user, channel (
apns,fcm,directorwebpush), time zone and language. - User facts: properties you set about a user (
plan,first_name), used by{{ placeholders }}and segments. User links say two user IDs are the same person, so a message to one reaches both. - Topics, topic webhooks, segments, test sends and resends are managed in the console or with a CLI login; an App gets
403 CONSOLE_ONLYfor those.
Request Headers
Authorization: Bearer <workload_token> // or your hikigai login token
X-Project-ID: YOUR_PROJECT_ID
Content-Type: application/json/api/v1/notifications/publishQueue a message. Returns 202 with the notification; delivery runs in the background.
Request Body
{
"topic": "lab-results",
"title": "Your result is ready, {{ first_name | there }}",
"body": "Open the app to see it.",
"data": { "screen": "results", "id": "456" },
"options": { "private": true, "priority": "high", "ttl_seconds": 86400 },
"target": { "users": ["patient-123"] }, // users, devices, app_id, segment_id
"conversion_event": "viewed_result", // optional: counted by receipts
"idempotency_key": "result-456" // optional: the same key returns the first message
}
→ 202 { "id": "…", "topic": "lab-results", "status": "queued", "target": { … }, "stats": {}, … }- Target:
users,devicesandapp_id(a web App or mobile app) add up. With none of them the message goes to the topic's subscribers.segment_idalone reaches every matching device in the organization; with the others it filters them.usersalso reaches linked user IDs. - Placeholders:
{{ name }}in title and body comes from the user's facts, then fromdata.{{ user.plan }}and{{ data.id }}pick the source;{{ name | fallback }}gives a default. Nothing else is evaluated. - Options:
sound,badge,priority(highornormal),android_channel,ttl_seconds(default 7 days, up to 28),collapse_key,private,private_title, and for browsersurlandicon. private: truekeeps title, body, image and data off Apple, Google and the browser push service: they get onlyprivate_title(default "New notification"), and the app reads the real message from its inbox. Use it for health information.- Limits: title 256 and body 4,000 characters,
data4 KB of JSON, 1,000 IDs inusersordevices.
/api/v1/notifications/schedulesSend later or on repeat, at a fixed time or at the same wall time in each user's own time zone. The message is checked when you save it and again at every run.
{
"name": "Evening reminder",
"message": { "topic": "reminders", "title": "Time to log your blood sugar" }, // what /publish takes
"kind": "recurring", // "once" | "recurring"
"recurrence": { "frequency": "daily", "time": "20:00" },
"timezone_mode": "user_local", // "fixed" (in "timezone") | "user_local"
"timezone": "UTC", // fixed mode, and devices with no time zone
"start_date": "2026-12-01"
}
// once: "kind": "once", "run_at": "2026-12-01T09:00:00" (no offset: read in "timezone")
// weekly: "recurrence": { "frequency": "weekly", "time": "08:30", "days_of_week": [0, 3] } (0 = Monday)Also: GET /schedules, GET / PUT / DELETE /schedules/{id}, POST /schedules/{id}/pause and /resume (missed runs are not sent). Each run is sent once. If the topic is deleted or the App loses permission, the schedule turns itself off.
/api/v1/notifications/messages/{id}One message with delivery counts by status (stats). An App sees only its own messages.
Also: GET /messages (?topic=, status=, limit=), GET /messages/{id}/deliveries (one row per device or webhook, with status, attempts, sent_at, delivered_at, opened_at, last_error) and POST /messages/{id}/cancel (stop deliveries that have not gone out). Delivery statuses: pending, sent, delivered, failed (retried), dead, expired, cancelled.
/api/v1/notifications/devices/webRegister a browser for web push, from your web app's backend, for its signed-in user. The browser gets the subscription with enableWebPush from @hikigai/app-sdk/browser.
{
"subscription": { "endpoint": "https://…", "keys": { "p256dh": "…", "auth": "…" } }, // PushSubscription.toJSON()
"user_id": "patient-123",
"timezone": "Europe/London", "language": "en",
"topics": ["lab-results"]
}
→ 201 { "id": "…", "platform": "web", "channel": "webpush", "user_id": "patient-123", "topics": ["lab-results"], … }The browser subscribes with the organization's public key: GET /api/v1/notifications/web-push/public-key → { "public_key": "…" }. Also: GET /devices?user_id= (an App must name a user), GET /devices/{id}, DELETE /devices/{id} (turn a device off; an App removes only devices it registered).
/api/v1/notifications/topics/{name}/subscribeSubscribe devices to a topic: by ID, or all of one user's devices. Apps can do this only on topics that allow it.
{ "user_id": "patient-123" } // or { "device_ids": ["…"] }
→ 200 { "subscribed": 2, "devices": 2 }Also: POST /topics/{name}/unsubscribe (same body) and GET /topics (an App also gets can_publish for each topic).
/api/v1/notifications/users/{user_id}/propertiesSet facts about a user for placeholders and segments. Merged into what is there; null removes a fact; replace: true overwrites all (console or CLI login only). Up to 8 KB per user.
{ "properties": { "first_name": "Pat", "plan": "premium", "old_fact": null }, "replace": false }
→ 200 { "user_id": "patient-123", "properties": { "first_name": "Pat", "plan": "premium" } }
// Linking IDs is done from the console or a CLI login (Apps get CONSOLE_ONLY)
POST /api/v1/notifications/users/links { "alias": "portal-881", "user_id": "patient-123" } // same person
DELETE /api/v1/notifications/users/links/{alias}/api/v1/notifications/users/{user_id}/inboxA user's recent notifications, one per message, for an in-app inbox. Also returns the room an open app joins to get new ones live.
→ 200 { "user_id": "patient-123", "room": "notifications.user.patient-123",
"items": [ { "delivery_id": "…", "notification_id": "…", "topic": "lab-results",
"title": "…", "body": "…", "data": { … }, "status": "sent",
"created_at": "…", "opened_at": null } ] }?limit= (up to 200), ?app_id= to keep one app's devices. User IDs with characters other than letters, digits and _ . : - get a hashed room name; the SDKs' user_room / userRoom compute it.
/api/v1/notifications/receiptsReport what happened to a delivery: received, opened, or the message's conversion_event. Web apps report for their browsers (the service worker gives the page the delivery_id on click).
{ "delivery_id": "…", "event": "opened" }Topic webhooks
An app that should receive every message on a topic adds a webhook on the topic in the console (up to 10 per topic; the secret is shown once). Each call is a POST with X-Hikigai-Event-Type: notification.published and the same signature as project webhooks; the body has type, id, delivery_id, topic, publisher, title, body, data and target. Answer 2xx; 408, 429 and 5xx are retried.
Mobile notifications (through the gateway)
Phones call their mobile app's {gateway_url}, never the platform. Send the same headers as other gateway calls, plus X-Hikigai-Installation-Id: a random ID (16 to 128 letters, digits, - or _) the app makes once and keeps. Every call is limited to that install. A phone has a user only when the mobile app requires sign-in; otherwise it gets topic, app and device messages.
X-Hikigai-App-Check: <app_check_token>
Authorization: Bearer <id_token> // when the app requires sign-in
X-Hikigai-Installation-Id: 3f9c2a7e0b1d4c559e0a6d2f81c4b7aa
POST /v1/notifications/devices register or refresh this install
DELETE /v1/notifications/devices stop notifications to this install
GET /v1/notifications/topics topics it is on, and those it may join
POST /v1/notifications/topics/{name}/subscribe (or /unsubscribe)
PUT /v1/notifications/properties { "properties": { … } } facts about the signed-in user
GET /v1/notifications/stream live messages while the app is open (server-sent events)
GET /v1/notifications/inbox recent messages (?limit=, ?after=)
POST /v1/notifications/receipts { "delivery_id": "…", "event": "opened" }{gateway_url}/v1/notifications/devicesRegister this install at every app start (and when the push token changes). Registering again updates the same device.
{
"push_token": "…", // iOS: the APNs device token. Android with Google: the FCM token.
"push_provider": "apns", // optional: "apns" on iOS, "fcm" on Android. Without Google, send neither
"apns_environment": "production", // optional: "sandbox" by default on development registrations
"timezone": "America/Chicago", "language": "en", "app_version": "2.4.0",
"topics": ["lab-results"] // only topics that let phones join
}
→ 200 { "device_id": "…", "channel": "apns", "user_id": "…", "topics": ["lab-results"],
"room": "notifications.user.…" }{gateway_url}/v1/notifications/streamServer-sent events while the app is open: messages arrive at once. The stream ends after about 280 seconds; reconnect.
event: notification
data: { "delivery_id": "…", "notification_id": "…", "topic": "lab-results", "title": "…",
"body": "…", "data": { … }, "options": { … }, "status": "sent", "created_at": "…" }
event: closed // the device was turned off: register againA message the stream delivers is not also sent through Apple or Google, so an open app never shows it twice. GET /v1/notifications/inbox returns the same items as { "items": [ … ] }; call it when the app starts or wakes to pick up what it missed.
How a phone is reached while the app is closed
- iPhone: through Apple. Add
PUSH_APNS_KEY(the whole .p8 file),PUSH_APNS_KEY_IDandPUSH_APNS_TEAM_IDin the gateway's Environment tab and redeploy. - Android with a Google key (optional): add
PUSH_FCM_SERVICE_ACCOUNT(the whole service account JSON from Firebase) and redeploy; phones that send an FCM token are woken at once. - Android without Google: messages wait until the app fetches its inbox, usually within 1 to 9 minutes when it wakes on its own timer.
- The keys stay in the gateway, in your own cloud. The Notifications tab shows whether each gateway has them. Tokens Apple or Google reject turn the device off until it registers again.
Even Realities G2 Glasses
Architecture
Even Realities G2 glasses have a 640×350 green monochrome display, mic, and touch temples — but no browser. The Even phone app loads your page in a WebView and drives the lenses over Bluetooth via @evenrealities/even_hub_sdk. Hikigai deploys that page like any other app (framework even-g2), builds the Even Hub .ehpk package, and exposes console APIs for info, QR testing, package download, and manifest validation.
- Dev mode: scan the QR (live URL) in the Even app — no store review.
- Even Hub store: download the
.ehpkand upload it manually in the Even Hub portal (no public upload API). - Agent calls: go through a server proxy deployed as a Hikigai App (see
templates/even-g2); the SDK inside it uses the platform-managed Deploy key. Use normal agent invoke — not a separate glasses runtime API. - Voice: agent must allow audio in its input modalities; list/text questions work with any text agent.
Proxy environment (your app server)
Not console API fields — these are what the deployed G2 proxy reads:
HIKIGAI_API_KEY/HIKIGAI_PROJECT_ID/HIKIGAI_APP_ID/HIKIGAI_PLATFORM_URL/HIKIGAI_PUBLIC_PLATFORM_URL— set by the platform on deploy (managed, cannot be overridden). Agent calls work from the deployed App, or from your computer afterhikigai login.HIKIGAI_AGENT_ID— required; set under Environment in the console (slug or id).GLASSES_PAGE_CHARS(optional) — page size for answers (starter default 420).
app.json: name ≤ 20, tagline ≤ 50; unique reverse-DNS package_id; typical permissions network + g2-microphone. Starter: templates/even-g2 (check / qr / pack).
Base path: /api/v1/projects/{project_id}/apps/{app_id}/even-g2
Permission: apps:read on all four endpoints.
Auth: console session or your hikigai token (hikigai login) for the project. Project API keys and App Deploy keys are refused.
Detection: framework is even-g2 when the repo has both app.json and @evenrealities/even_hub_sdk. SDK helpers: Node AppSDK · Python AppSDK.
/api/v1/projects/{project_id}/apps/{app_id}/even-g2Console panel payload: whether the app is even-g2, live URL, QR payload, validated manifest, package state, and Even Hub package/portal links.
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/even-g2' \
--header "Authorization: Bearer $(hikigai token)"Response (200)
{
"app_id": "app_...",
"enabled": true,
"framework": "even-g2",
"live_url": "https://your-app.example.com",
"dev_mode_qr_payload": "https://your-app.example.com",
"manifest": {
"package_id": "ai.hikigai.demo",
"edition": "g2",
"name": "Demo",
"version": "0.1.0",
"min_sdk_version": "0.0.15",
"entrypoint": "index.html",
"permissions": [{ "name": "network", "desc": "...", "whitelist": [] }],
"supported_languages": ["en"]
},
"deployment_id": "dep_...",
"deployment_status": "active",
"package_available": true,
"package_size_bytes": 184320,
"package_filename": "ai.hikigai.demo-0.1.0.ehpk",
"package_error": null,
"cli_version": "0.1.14",
"portal_url": "https://hub.evenrealities.com",
"docs_url": "https://hub.evenrealities.com/docs/get-started/overview",
"sdk_package": "@evenrealities/even_hub_sdk",
"cli_package": "@evenrealities/evenhub-cli",
"simulator_package": "@evenrealities/evenhub-simulator"
}enabled is true only when framework == "even-g2".dev_mode_qr_payload is the live URL string (same as evenhub qr --url). Package fields come from artifacts.even_g2 on the latest active deployment.
/api/v1/projects/{project_id}/apps/{app_id}/even-g2/qr.pngDev-mode QR as PNG. Scanning it in the Even phone app opens the live URL on the glasses.
Query Parameters
| Param | Type | Description |
|---|---|---|
scale | int 2–20 | Pixel scale for the QR modules. Default 8. |
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/even-g2/qr.png?scale=8' \
--header "Authorization: Bearer $(hikigai token)" \
--output even-g2-dev-mode.pngResponse
200 — image/png, Cache-Control: no-store.
409 — app has no live URL yet (deploy first). 404 — app not found.
/api/v1/projects/{project_id}/apps/{app_id}/even-g2/packageStream the packed .ehpk for manual upload in the Even Hub developer portal. The backend fetches it from the live host under an unguessable path.
Query Parameters
| Param | Type | Description |
|---|---|---|
deployment_id | string | Optional. Defaults to the latest active deployment with an even_g2 artifact. |
cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/even-g2/package' \
--header "Authorization: Bearer $(hikigai token)" \
--output ai.hikigai.demo-0.1.0.ehpkResponse
200 — application/octet-stream with Content-Disposition: attachment; filename="…ehpk".
400 — not an even-g2 app. 404 — no package built yet.413 — over size cap. 502 — live host did not return the package.
/api/v1/projects/{project_id}/apps/{app_id}/even-g2/validate-manifestValidate a parsed app.json with the same rules the deploy pipeline (and Even Hub CLI) apply. Always returns 200; check valid.
Request Body
{
"manifest": {
"package_id": "ai.hikigai.demo",
"edition": "g2",
"name": "Demo",
"version": "0.1.0",
"min_sdk_version": "0.0.15",
"entrypoint": "index.html",
"permissions": [
{ "name": "network", "desc": "Talk to your Hikigai agent", "whitelist": [] },
{ "name": "g2-microphone", "desc": "Capture voice questions" }
],
"supported_languages": ["en"],
"tagline": "Ask an agent from your glasses",
"description": "Optional longer description (max 1024 chars)."
}
}cURL Example
curl --location 'https://backend.hikigaiplatform.io/api/v1/projects/YOUR_PROJECT_ID/apps/YOUR_APP_ID/even-g2/validate-manifest' \
--header "Authorization: Bearer $(hikigai token)" \
--header 'Content-Type: application/json' \
--data @manifest-body.jsonResponse (200)
{ "valid": true, "error": null, "manifest": { /* normalised */ } }
// or
{ "valid": false, "error": "app.json: name must be 1 to 20 characters", "manifest": null }Required fields: package_id, edition, name (≤20), version (x.y.z), min_sdk_version, entrypoint, permissions[], supported_languages[]. Permissions: network, g2-microphone, phone-microphone, album, location, camera (whitelist only on network). Languages: en, de, fr, es, it, zh, ja, ko.
Talking to agents from a G2 app
There is no glasses-specific invoke route. Your WebView talks to your proxy (credentials never ship in the public page). The proxy uses the standard agent invoke API. For voice, send WAV as an attachments entry — the agent must allow audio in its input modalities; list/text questions work with any text agent.
# Text question (from your proxy)
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agents/YOUR_AGENT_SLUG/invoke" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "X-Project-ID: $HIKIGAI_PROJECT_ID" \
--header 'Content-Type: application/json' \
--data '{
"input": "What are the contraindications?",
"session_id": "wearer-123"
}'
# Voice (WAV attachment — same shape the starter template uses)
curl --location "$HIKIGAI_PLATFORM_URL/api/v1/agents/YOUR_AGENT_SLUG/invoke" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "X-Project-ID: $HIKIGAI_PROJECT_ID" \
--header 'Content-Type: application/json' \
--data '{
"input": "Answer the question in this recording.",
"session_id": "wearer-123",
"attachments": [
{ "data_base64": "<BASE64_WAV>", "mime_type": "audio/wav" }
]
}'Paginate the answer for the 640×350 display with the SDK helpers (default char budget is 2000; the starter template uses 420 via GLASSES_PAGE_CHARS):
import { normalizeForGlasses, paginateForGlasses } from '@hikigai/app-sdk'
const pages = paginateForGlasses(response.content, { maxChars: 420 })
// pages → string[] ready for TextContainerProperty on the glassesNeed more help? Check the Getting Started guide or review the Platform API Reference.