Scanning Text
Example showing how to scan text for sensitive data using the Nightfall AI API.
This example assumes using NightfallAI; is in scope and apiKey contains your NightfallAI API key.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 | using var client = new NightfallAIClient(apiKey);
// Create a scan request with inline detection rules
var request = new ScanTextRequest
{
Payload = ["My email is test@example.com and my SSN is 123-45-6789"],
Policy = new ScanPolicy
{
DetectionRules =
[
new DetectionRule
{
Detectors =
[
new Detector
{
DetectorType = DetectorType.NightfallDetector,
NightfallDetector = "EMAIL_ADDRESS",
MinConfidence = Confidence.Possible,
},
new Detector
{
DetectorType = DetectorType.NightfallDetector,
NightfallDetector = "US_SOCIAL_SECURITY_NUMBER",
MinConfidence = Confidence.Possible,
},
],
LogicalOp = LogicalOp.Any,
},
],
},
};
// Send the scan request
var response = await client.Scanning.ScanTextAsync(
request: request);
|