Skip to content

AWS.FraudDetector reference

Source: src/AWS/FraudDetector/DeleteEvent.ts

Delete a stored event from Amazon Fraud Detector — the effectful erasure call made from a deployed Lambda or Task, e.g. to honor a data-deletion request. Set deleteAuditHistory to also remove the event’s prediction history.

Provide the DeleteEventHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:DeleteEvent on the event type and injects its eventTypeName automatically.

// init
const deleteEvent = yield* FraudDetector.DeleteEvent(eventType);
return {
fetch: Effect.gen(function* () {
// runtime
yield* deleteEvent({ eventId: "order-123", deleteAuditHistory: true });
return HttpServerResponse.json({ ok: true });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.DeleteEventHttp))

Source: src/AWS/FraudDetector/DeleteEventsByEventType.ts

Start an asynchronous bulk delete of ALL events stored for a bound Amazon Fraud Detector event type — the effectful cleanup call (e.g. a data-privacy purge) made from a deployed Lambda or Task. Track progress with the companion GetDeleteEventsByEventTypeStatus binding.

DeleteEventsByEventType: Purging Stored Events

Section titled “DeleteEventsByEventType: Purging Stored Events”

Provide the DeleteEventsByEventTypeHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:DeleteEventsByEventType on the event type and injects its eventTypeName automatically.

// init
const deleteEventsByEventType =
yield* FraudDetector.DeleteEventsByEventType(eventType);
const getDeleteStatus =
yield* FraudDetector.GetDeleteEventsByEventTypeStatus(eventType);
return {
fetch: Effect.gen(function* () {
// runtime
yield* deleteEventsByEventType({});
const { eventsDeletionStatus } = yield* getDeleteStatus({});
return HttpServerResponse.json({ status: eventsDeletionStatus });
}),
};
// on the Function effect:
// .pipe(Effect.provide(Layer.mergeAll(
// FraudDetector.DeleteEventsByEventTypeHttp,
// FraudDetector.GetDeleteEventsByEventTypeStatusHttp,
// )))

Source: src/AWS/FraudDetector/Detector.ts

An Amazon Fraud Detector detector — the container that binds an event type to versioned rule sets and models used to evaluate fraud. Creating the detector is cheap; the rules, models, and detector versions that produce predictions are provisioned separately.

Basic Detector

const detector = yield* FraudDetector.Detector("checkout", {
eventTypeName: purchase.name,
});

Detector with an Active Version

const detector = yield* FraudDetector.Detector("checkout", {
eventTypeName: purchase.name,
});
const version = yield* FraudDetector.DetectorVersion("v1", {
detectorId: detector.detectorId,
status: "ACTIVE",
rules: [
{
ruleId: "high_risk",
expression: '$email == "fraud@example.com"',
outcomes: [review.name],
},
],
});

Bind GetEventPrediction in the init phase (providing the GetEventPredictionHttp layer on the Function effect) and score events at runtime against the detector’s ACTIVE version.

// init
const getEventPrediction = yield* FraudDetector.GetEventPrediction(detector);
// runtime
const { ruleResults } = yield* getEventPrediction({
eventId: "order-123",
eventTypeName: "purchase",
eventTimestamp: new Date().toISOString(),
entities: [{ entityType: "customer", entityId: "cust-1" }],
eventVariables: { email: "buyer@example.com", ip: "1.2.3.4" },
});

Source: src/AWS/FraudDetector/DetectorVersion.ts

An Amazon Fraud Detector detector version — the deployable revision of a detector. It bundles a set of rules (owned inline here) over the detector’s event type and, when ACTIVE, serves real-time predictions via getEventPrediction. Rules and the version are cheap, rule-based configuration objects — no model training is involved.

DetectorVersion: Creating a Detector Version

Section titled “DetectorVersion: Creating a Detector Version”
const version = yield* FraudDetector.DetectorVersion("v1", {
detectorId: detector.detectorId,
status: "ACTIVE",
ruleExecutionMode: "FIRST_MATCHED",
rules: [
{
ruleId: "high_risk",
expression: '$email == "fraud@example.com"',
outcomes: ["review"],
},
],
});

Source: src/AWS/FraudDetector/EntityType.ts

An Amazon Fraud Detector entity type — the classification of who or what an event is about (e.g. customer, merchant). Event types reference entity types; they are cheap metadata objects.

const customer = yield* FraudDetector.EntityType("customer", {
description: "the buyer placing an order",
});

Source: src/AWS/FraudDetector/EventType.ts

An Amazon Fraud Detector event type — the schema of an event (its variables, labels, and entity types) that detectors evaluate. Event types are cheap metadata objects.

const purchase = yield* FraudDetector.EventType("purchase", {
eventVariables: ["email", "ip"],
entityTypes: ["customer"],
labels: ["fraud", "legit"],
});

Source: src/AWS/FraudDetector/GetDeleteEventsByEventTypeStatus.ts

Check the status of an asynchronous bulk event delete started by DeleteEventsByEventType on a bound Amazon Fraud Detector event type — the effectful status poll made from a deployed Lambda or Task.

GetDeleteEventsByEventTypeStatus: Purging Stored Events

Section titled “GetDeleteEventsByEventTypeStatus: Purging Stored Events”

Provide the GetDeleteEventsByEventTypeStatusHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetDeleteEventsByEventTypeStatus on the event type and injects its eventTypeName automatically.

// init
const getDeleteStatus =
yield* FraudDetector.GetDeleteEventsByEventTypeStatus(eventType);
return {
fetch: Effect.gen(function* () {
// runtime
const { eventsDeletionStatus } = yield* getDeleteStatus({});
return HttpServerResponse.json({ status: eventsDeletionStatus });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetDeleteEventsByEventTypeStatusHttp))

Source: src/AWS/FraudDetector/GetEvent.ts

Read a stored event (its entities and variable values) back from Amazon Fraud Detector — the effectful lookup call made from a deployed Lambda or Task. Events are stored by SendEvent or by predictions on an event type with ingestion enabled.

Provide the GetEventHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetEvent on the event type and injects its eventTypeName automatically.

// init
const getEvent = yield* FraudDetector.GetEvent(eventType);
return {
fetch: Effect.gen(function* () {
// runtime
const { event } = yield* getEvent({ eventId: "order-123" });
return HttpServerResponse.json({ variables: event?.eventVariables });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetEventHttp))

Source: src/AWS/FraudDetector/GetEventPrediction.ts

Submit an event to a bound Amazon Fraud Detector detector and receive the real-time model scores and rule outcomes for it — the effectful prediction call made from a deployed Lambda or Task.

Provide the GetEventPredictionHttp implementation layer on the Function effect, bind the detector in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetEventPrediction on the detector and injects its detectorId automatically.

// init
const getEventPrediction = yield* FraudDetector.GetEventPrediction(detector);
return {
fetch: Effect.gen(function* () {
// runtime
const { ruleResults } = yield* getEventPrediction({
eventId: "order-123",
eventTypeName: "purchase",
eventTimestamp: new Date().toISOString(),
entities: [{ entityType: "customer", entityId: "cust-1" }],
eventVariables: { email: "fraud@example.com", ip: "1.2.3.4" },
});
const outcomes = ruleResults?.flatMap((r) => r.outcomes ?? []);
return HttpServerResponse.json({ outcomes });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetEventPredictionHttp))

Source: src/AWS/FraudDetector/GetEventPredictionMetadata.ts

Read the full evaluation details of a past prediction made by a bound Amazon Fraud Detector detector — the variables, rule evaluations, and model scores recorded for the prediction — the effectful audit call made from a deployed Lambda or Task.

GetEventPredictionMetadata: Auditing Predictions

Section titled “GetEventPredictionMetadata: Auditing Predictions”

Provide the GetEventPredictionMetadataHttp implementation layer on the Function effect, bind the detector in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetEventPredictionMetadata on the detector and injects its detectorId automatically. Find predictionTimestamp values via the ListEventPredictions binding.

// init
const getPredictionMetadata =
yield* FraudDetector.GetEventPredictionMetadata(detector);
return {
fetch: Effect.gen(function* () {
// runtime
const metadata = yield* getPredictionMetadata({
eventId: "order-123",
eventTypeName: "purchase",
detectorVersionId: "1",
predictionTimestamp: "2026-01-01T00:00:00Z",
});
return HttpServerResponse.json({ rules: metadata.rules });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetEventPredictionMetadataHttp))

Source: src/AWS/FraudDetector/GetListElements.ts

Read the elements of a bound Amazon Fraud Detector list — the effectful lookup call made from a deployed Lambda or Task, e.g. to check an incoming value against a deny-list outside of a detector evaluation.

Elements decode as sensitive values (string | Redacted<string>); unwrap with Redacted.value where needed.

Provide the GetListElementsHttp implementation layer on the Function effect, bind the list in the init phase, then call the returned client at runtime. The binding grants frauddetector:GetListElements on the list and injects its name automatically.

// init
const getListElements = yield* FraudDetector.GetListElements(blockedIps);
return {
fetch: Effect.gen(function* () {
// runtime
const { elements } = yield* getListElements({});
return HttpServerResponse.json({ count: elements?.length ?? 0 });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.GetListElementsHttp))

Source: src/AWS/FraudDetector/Label.ts

An Amazon Fraud Detector label — a classification (e.g. fraud, legit) used to tag stored events for supervised model training. Event types reference labels; they are cheap metadata objects.

const fraud = yield* FraudDetector.Label("fraud", {
description: "confirmed fraudulent event",
});
const legit = yield* FraudDetector.Label("legit", {});

Source: src/AWS/FraudDetector/List.ts

An Amazon Fraud Detector list — a set of input values for a variable (an allow-list or deny-list, e.g. known-fraud IP addresses) referenced from detector rule expressions.

const blockedIps = yield* FraudDetector.List("BlockedIps", {
variableType: "IP_ADDRESS",
description: "known-fraud source addresses",
elements: ["203.0.113.7", "198.51.100.9"],
});
// init
const updateList = yield* FraudDetector.UpdateList(blockedIps);
const getListElements = yield* FraudDetector.GetListElements(blockedIps);
// runtime
yield* updateList({ elements: ["192.0.2.44"], updateMode: "APPEND" });
const { elements } = yield* getListElements({});
// on the Function effect:
// .pipe(Effect.provide(Layer.mergeAll(
// FraudDetector.UpdateListHttp,
// FraudDetector.GetListElementsHttp,
// )))

Source: src/AWS/FraudDetector/ListEventPredictions.ts

List the past predictions made by a bound Amazon Fraud Detector detector — the effectful search call made from a deployed Lambda or Task, e.g. to find the predictionTimestamp needed by GetEventPredictionMetadata.

ListEventPredictions: Auditing Predictions

Section titled “ListEventPredictions: Auditing Predictions”

Provide the ListEventPredictionsHttp implementation layer on the Function effect, bind the detector in the init phase, then call the returned client at runtime. The binding grants frauddetector:ListEventPredictions (the action supports no resource-level scoping) and filters results to the bound detector automatically.

// init
const listEventPredictions =
yield* FraudDetector.ListEventPredictions(detector);
return {
fetch: Effect.gen(function* () {
// runtime
const { eventPredictionSummaries } = yield* listEventPredictions({
eventId: { value: "order-123" },
});
return HttpServerResponse.json({
predictions: eventPredictionSummaries ?? [],
});
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.ListEventPredictionsHttp))

Source: src/AWS/FraudDetector/Outcome.ts

An Amazon Fraud Detector outcome — the result a rule produces when it matches (e.g. approve, review, block). Detector rules reference outcomes; they are cheap metadata objects.

const approve = yield* FraudDetector.Outcome("approve", {
description: "let the transaction through",
});
const review = yield* FraudDetector.Outcome("review", {});

Source: src/AWS/FraudDetector/SendEvent.ts

Store an event in Amazon Fraud Detector without generating a prediction — the effectful ingestion call made from a deployed Lambda or Task. Stored events build the historical dataset used to train models and can be labeled later via UpdateEventLabel. The bound event type must have eventIngestion: "ENABLED".

Provide the SendEventHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:SendEvent on the event type and injects its eventTypeName automatically.

// init
const sendEvent = yield* FraudDetector.SendEvent(eventType);
return {
fetch: Effect.gen(function* () {
// runtime
yield* sendEvent({
eventId: "order-123",
eventTimestamp: new Date().toISOString(),
entities: [{ entityType: "customer", entityId: "cust-1" }],
eventVariables: { email: "buyer@example.com", ip: "1.2.3.4" },
});
return HttpServerResponse.json({ ok: true });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.SendEventHttp))

Source: src/AWS/FraudDetector/UpdateEventLabel.ts

Label a stored event in Amazon Fraud Detector — the effectful feedback call made from a deployed Lambda or Task when ground truth arrives (e.g. a chargeback confirms fraud). Labeled events improve future model training.

Provide the UpdateEventLabelHttp implementation layer on the Function effect, bind the event type in the init phase, then call the returned client at runtime. The binding grants frauddetector:UpdateEventLabel on the event type and injects its eventTypeName automatically.

// init
const updateEventLabel = yield* FraudDetector.UpdateEventLabel(eventType);
return {
fetch: Effect.gen(function* () {
// runtime — a chargeback arrived for this order
yield* updateEventLabel({
eventId: "order-123",
assignedLabel: "fraud",
labelTimestamp: new Date().toISOString(),
});
return HttpServerResponse.json({ ok: true });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.UpdateEventLabelHttp))

Source: src/AWS/FraudDetector/UpdateList.ts

Mutate the elements of a bound Amazon Fraud Detector list at runtime — the effectful write call made from a deployed Lambda or Task, e.g. to append a newly-confirmed fraudulent IP to a deny-list the detector’s rules reference.

Note that the List resource reconciles elements declaratively on every deploy (a REPLACE update), so elements appended at runtime are removed by the next deploy unless they are also added to the resource’s props.

Provide the UpdateListHttp implementation layer on the Function effect, bind the list in the init phase, then call the returned client at runtime. The binding grants frauddetector:UpdateList on the list and injects its name automatically.

// init
const updateList = yield* FraudDetector.UpdateList(blockedIps);
return {
fetch: Effect.gen(function* () {
// runtime
yield* updateList({ elements: ["192.0.2.44"], updateMode: "APPEND" });
return HttpServerResponse.json({ ok: true });
}),
};
// on the Function effect:
// .pipe(Effect.provide(FraudDetector.UpdateListHttp))

Source: src/AWS/FraudDetector/Variable.ts

An Amazon Fraud Detector variable — a named input to fraud-detection models and rules, typed and sourced from event data or model scores. Variables are cheap metadata objects.

const email = yield* FraudDetector.Variable("email", {
dataType: "STRING",
dataSource: "EVENT",
defaultValue: "unknown",
variableType: "EMAIL_ADDRESS",
});