Users
Manage end-users within an application.
| Operation | GraphQL |
|---|---|
| List users | users(where: {application_id: {_eq: $appId}, active: {_eq: true}}, order_by: {created_at: desc}) |
| List all users | users(where: {application_id: {_eq: $appId}}, order_by: {created_at: desc}) |
| Search users | users(where: {application_id: {_eq: $appId}, handler: {_ilike: $searchPattern}}, limit: $limit, offset: $offset) |
| User count | users_aggregate(where: {application_id: {_eq: $appId}}) { aggregate { count } } |
| Ban/unban user | update_users_by_pk(pk_columns: {id: $userId}, _set: {active: false}) |
| User usage events | usage_events(where: {application_id: {_eq: $appId}, user_id: {_eq: $userId}, created_at: {_gte: $start, _lte: $end}}) |
| User usage stats | usage_events_aggregate(where: {application_id: {_eq: $appId}, user_id: {_eq: $userId}, created_at: {_gte: $windowStart}}) { aggregate { count, sum { tokens_in, tokens_out, cost_pusd } } } |
| Assign plan | insert_user_plan_assignments_one(object: {organization_id, application_id, billing_plan_id, user_id, status: "active"}) |
| Cancel plan assignment | update_user_plan_assignments(where: {organization_id: {_eq: $orgId}, application_id: {_eq: $appId}, user_id: {_eq: $userId}, status: {_eq: "active"}}, _set: {status: "canceled", ends_at: $now}) |
| Get assignable plans | billing_plans(where: {organization_id: {_eq: $orgId}, deleted: {_neq: true}, is_active: {_eq: true}}) |
Last updated on