Skip to content
中文

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.

GoalActionSubsequent access
End existing sign-insRevoke tokensEnds all of the customer’s sign-ins; your backend can still issue a new grant code
Continue refusing accessBlockEnds existing sign-ins and refuses new grant codes, sign-ins, renewals and sessions
Restore accessUnblockAllows signing in again; previously revoked tokens remain revoked
The customer asks for their data to be deletedDelete dataIrreversible; 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

  1. Open Service agents → Select agent → Customers (客户). Labels describe the current Chinese Dashboard.
  2. 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> (已合并到).
  3. Select a customer ID to open details. Use Recent sessions (最近会话) to confirm you selected the right customer.
  4. 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.

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 knowDetail
Recovery snapshotKept 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
AttachmentsOnly attachment metadata is recorded; the attachment files themselves are not deleted
Block stateA block that existed before the deletion stays; the temporary block added by the task is removed on success
Failure and retryAfter failed the customer stays blocked; send the same DELETE with the same confirm again to resume. Concurrent duplicate requests reuse the unfinished task
CostDeletion is not charged
AfterwardsThe status endpoint is the only record. The same customer ID can sign in again and starts from scratch
Archived agentEvery 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