Manage customers
Customers are the people who use your service agent: identified customers your backend signs in with a grant code, and visitors admitted with the publishable key. Find a customer by ID and end or restore their access when needed. Each action applies to that customer within the current organization and agent.
When to use it
An agent published for customers or colleagues to chat with.
Use it when
- Each request follows one process: support, triage, a course assistant.
Not for, use instead
- Open-ended work →
agent - Steps that never vary →
automation
How it behaves
- Fresh machine per session; host-scoped secrets are not injected; the UI is the Kit
<praxis-agent>.
Combines with
- Customer decides who may chat.
Entry: praxis.agent.* · docs developers/agent/end-users · recipes cookbook/scenarios/ai-twin
Prepare and choose an action
You need a service agent, an organization API key (or a Dashboard member sign-in), and the customer ID: for an identified customer, the customer_id your backend sent when it issued the grant code; for a visitor, an ID starting with anon_. Verify actions with an isolated test customer first. Revocation and blocking interrupt that customer’s ongoing conversations.
| Goal | Action | Subsequent access |
|---|---|---|
| End existing sign-ins | Revoke tokens | Ends all of the customer’s sign-ins; your backend can still issue a new grant code |
| Continue refusing access | Block | Ends existing sign-ins and refuses new grant codes, sign-ins, renewals and sessions |
| Restore access | Unblock | Allows signing in again; previously revoked tokens remain revoked |
| The customer asks for their data to be deleted | Delete data | Irreversible; sessions and conversation data are deleted and a recovery snapshot is kept for 7 days |
When a visitor signs in and your backend passes anonymous_access_token while issuing the grant code, the visitor is merged into the identified customer: its merged_into is that customer’s ID, and its sessions count toward that customer’s session count, cost and recent sessions.
Find and manage a customer
- Open Service agents → Select agent → Customers (客户). Labels describe the current Chinese Dashboard.
- Enter an ID in Search by customer ID prefix (按客户 ID 前缀搜索). The table shows type (visitor 访客 / identified 已识别), first seen, last active, session count, cost and status; a merged visitor shows Merged into <customer ID> (已合并到).
- Select a customer ID to open details. Use Recent sessions (最近会话) to confirm you selected the right customer.
- In the row or details, select Revoke tokens (吊销令牌), Block (封禁), or Unblock (解封). Check the customer ID in the confirmation dialog, then confirm.
Expected: Revocation shows Revoked N (已吊销 N 张). Blocking sets the status to Blocked (已封禁). Unblocking sets it to Active (正常). These actions do not delete cost or session data.
Use Node.js with native fetch on your server. Set PRAXIS_API_BASE to the API origin, PRAXIS_API_KEY to an organization API key, and PRAXIS_AGENT to the public agent_… ID. Keep the key on your server. Save this as customers.mjs.
import assert from 'node:assert/strict';
const { PRAXIS_API_BASE, PRAXIS_API_KEY, PRAXIS_AGENT } = process.env;assert(PRAXIS_API_BASE && PRAXIS_API_KEY && PRAXIS_AGENT, 'Set the three environment variables');assert(PRAXIS_AGENT.startsWith('agent_'), 'Use the public agent ID');const [action = 'list', customer = ''] = process.argv.slice(2);assert(['list', 'get', 'revoke', 'block', 'unblock'].includes(action), 'Unknown action');const root = `${PRAXIS_API_BASE.replace(/\/$/, '')}/agent/v1/agents/${encodeURIComponent(PRAXIS_AGENT)}/customers`;async function request(url, method = 'GET') { const response = await fetch(url, { method, headers: { Authorization: `Bearer ${PRAXIS_API_KEY}` } }); if (!response.ok) throw new Error(`Customer request failed: HTTP ${response.status}`); return response.json();}if (action === 'list') { let page; do { const query = new URLSearchParams({ q: customer, limit: '20' }); if (page) query.set('page', page); const result = await request(`${root}?${query}`); console.log(result.data); page = result.next_page; } while (page);} else { assert(/^[A-Za-z0-9_.:@-]{1,128}$/.test(customer), 'Provide the exact customer ID'); const url = `${root}/${encodeURIComponent(customer)}`; const suffix = { revoke: 'revoke_tokens', block: 'block', unblock: 'unblock' }[action]; const result = await request(suffix ? `${url}/${suffix}` : url, suffix ? 'POST' : 'GET'); if (action === 'block') assert.equal(result.blocked, true); if (action === 'unblock') assert.equal(result.blocked, false); if (action === 'revoke') assert(Number.isInteger(result.revoked)); console.log(result);}Run node customers.mjs list cus_ to search by case-sensitive ID prefix, then node customers.mjs get cus_42 for details. Replace the ID with your test customer. To end access, run either node customers.mjs revoke cus_42 or node customers.mjs block cus_42. To restore it, run node customers.mjs unblock cus_42.
The list also filters by type (identified or anonymous) and blocked (true or false), ordered by last_seen_at, newest first. The write operations call POST /agent/v1/agents/{agent_id}/customers/{customer_id}/revoke_tokens, POST …/block, and POST …/unblock. None requires a request body, and repeating one changes nothing further.
Expected: Success returns HTTP 200. Revocation returns the revoked count of tokens this request revoked. Block and unblock return blocked: true and blocked: false, respectively. A customer has id, type, merged_into, blocked, first_seen_at, last_seen_at, session_count and cost; details add recent_sessions to verify identity. cost is {amount, currency: "USD"}; amount is in US dollars, with exactly 6 decimals (for example "0.000345"). It is the model usage of the customer’s sessions plus their runtime. An unknown customer returns 404 CUSTOMER_NOT_FOUND.
Delete a customer’s data
When a customer asks for their data to be deleted, delete everything that customer has under this agent through the API. The operation cannot be undone and is not yet available in production; contact support if you need a deletion before then; try it on an isolated test customer first.
DELETE /agent/v1/agents/{agent_id}/customers/{customer_id}?confirm={customer_id}: confirm must equal the customer ID in the path exactly; a missing or different value returns 400 with a message naming the value to send. Success returns 202 and a task { "id": "eud_…", "status": "pending" }. That only means the task was accepted, not that it is complete.
The task runs in a fixed order: end all of the customer’s sign-ins and block the customer, create and verify a recovery snapshot, then delete sessions (including child sessions), conversation data, grants and feedback. Poll GET /agent/v1/agents/{agent_id}/customers/{customer_id}/deletion for the latest task. status moves through pending, snapshotting and deleting and ends as done or failed. counts is empty until the snapshot exists and afterwards reports the deleted sessions, events, messages and so on.
| What to know | Detail |
|---|---|
| Recovery snapshot | Kept for 7 days and holds a full copy of the customer’s conversations. snapshot_key in the response is an internal operator reference, not a download URL |
| Attachments | Only attachment metadata is recorded; the attachment files themselves are not deleted |
| Block state | A block that existed before the deletion stays; the temporary block added by the task is removed on success |
| Failure and retry | After failed the customer stays blocked; send the same DELETE with the same confirm again to resume. Concurrent duplicate requests reuse the unfinished task |
| Cost | Deletion is not charged |
| Afterwards | The status endpoint is the only record. The same customer ID can sign in again and starts from scratch |
| Archived agent | Every customer endpoint returns 404 Agent not found. If the agent is archived when a deletion request arrives, call POST /agent/v1/agents/{agent_id}/unarchive first (this creates no version), then decide whether to archive it again |
The script below starts the deletion and waits for it to finish; run node delete-customer.mjs cus_42. Set the three environment variables as earlier on this page.
import assert from 'node:assert/strict';import { setTimeout as delay } from 'node:timers/promises';
const { PRAXIS_API_BASE, PRAXIS_API_KEY, PRAXIS_AGENT } = process.env;assert(PRAXIS_API_BASE && PRAXIS_API_KEY && PRAXIS_AGENT, 'Set the three environment variables');const customer = process.argv[2];assert(/^[A-Za-z0-9_.:@-]{1,128}$/.test(customer ?? ''), 'Provide the exact customer ID');const root = `${PRAXIS_API_BASE.replace(/\/$/, '')}/agent/v1/agents/${encodeURIComponent(PRAXIS_AGENT)}/customers/${encodeURIComponent(customer)}`;async function request(url, method = 'GET') { const response = await fetch(url, { method, headers: { Authorization: `Bearer ${PRAXIS_API_KEY}` } }); if (!response.ok) throw new Error(`HTTP ${response.status}; request=${response.headers.get('X-Request-Id')}`); return response.json();}const started = await request(`${root}?confirm=${encodeURIComponent(customer)}`, 'DELETE');console.log({ task: started.id, status: started.status });let task = started;for (let i = 0; i < 60 && !['done', 'failed'].includes(task.status); i += 1) { await delay(2000); task = await request(`${root}/deletion`);}assert.equal(task.status, 'done', `Deletion ended as ${task.status}; run the script again to resume`);console.log({ status: task.status, counts: task.counts });Expected: the task ID with pending first, then status: "done" with the deletion counts.
Verify the access boundary
After revocation, access with an old token must fail with ACCESS_TOKEN_REVOKED. Your backend can issue a new grant code after checking the customer’s login again. After blocking, issuing a grant code, exchanging it and renewing must all return CUSTOMER_BLOCKED (HTTP 403). After unblocking, sign in again and send a message. A revoked token must not become valid again.
Check that another customer’s access to this agent remains unaffected. A customer access token cannot read or manage customers; the customer endpoints return 404 to it. Derive identity from your backend’s authenticated session, not an arbitrary ID submitted by the browser.
Handle failures
If a customer cannot be found, verify the organization, public agent ID and complete customer ID used when issuing the grant code. Dashboard Playground members are excluded from the customer list. Similar ID prefixes do not establish identity.
If blocking fails, read the state again before retrying. The blocked state may already be saved while token revocation remains incomplete. Do not report the operation as complete in that case. Record the HTTP status and request ID, then use Limits and errors.
Next steps
Inspect sessions and usage · Test your embed · Agent API · Cookbook