createApiKey method

Future<String> createApiKey({
  1. required String orgId,
  2. required String name,
  3. List<String> scopes = const ['scim:read', 'scim:write'],
  4. DateTime? expiresAt,
})

Creates a new API key via RPC and returns the raw key (shown only once).

Implementation

Future<String> createApiKey({
  required String orgId,
  required String name,
  List<String> scopes = const ['scim:read', 'scim:write'],
  DateTime? expiresAt,
}) async {
  final result = await _client.rpc(
    'create_org_api_key',
    params: {
      'p_org_id': orgId,
      'p_name': name,
      'p_scopes': scopes,
      'p_expires_at': expiresAt?.toUtc().toIso8601String(),
    },
  );
  return result as String;
}