GET /api/admin/support/tickets/:id/link?q= (support.assign): exact-match customer search for the link
dialog (masked emails). POST {sub | null} links or unlinks the ticket's customer account. Audited support.link.
Staff cookie session; permission support.assign.
This is the private staff console on https://admin.handwrites.io. A personal API key, organisation token, student login or isolated app-testing credential does not authenticate this route.
| Location | Name | Required | Meaning |
|---|---|---|---|
| path | id | Yes | Use the ID from an authorized staff response; source validators reject malformed IDs. |
| query | q | Conditional / optional | {"type":"string"} |
This operation does not define a JSON payload. Staff writes still require Content-Type: application/json and the session-bound CSRF header.
Success: 200. GET /api/admin/support/tickets/:id/link?q= (support.assign): exact-match customer search for the link
dialog (masked emails). POST {sub | null} links or unlinks the ticket's customer account. Audited support.link.
The wrapper returns {error:{code,message}} for CloudError failures, attaches Request-Id, and disables caching. Handle 401 by signing in; show role refusal for 403 forbidden, reauthenticate only for step_up_required, and collect a reason for 400 reason_required. A CSRF failure needs a current page/session token, not blind retries. Operation-specific 404/409/413/422/502/503 errors retain their status. Honor Retry-After on 429.
Source snapshot: admin/src/app/api/admin/support/tickets/[id]/link/route.ts. This reference describes the current working tree, not proof of deployment. The response service types and validators remain authoritative. The exact exported handler below makes conditional behavior reviewable. For helpers such as customer-routes or cloudRoute, see the shared API specification notes and the named service module.
/**
* GET /api/admin/support/tickets/:id/link?q=<email or sub> (support.assign): exact-match customer search for the link
* dialog (masked emails). POST {sub | null} links or unlinks the ticket's customer account. Audited support.link.
*/
export const GET = adminRoute("support.assign", async (request, _ctx, { params }: Context) => {
ticketIdParam((await params).id);
const q = new URL(request.url).searchParams.get("q");
if (!q) throw invalid("Search by the customer's full email address or account id.");
return adminJson({ items: await findCustomers(q) });
}, { rateLimit: "support-link-search" });
Do not use production customer data to test this operation. Use an authorized staff test account and a disposable target in an appropriate environment; email, deletion, role and credential mutations have real effects.