Skip to content

Model-bound captures

Model-bound captures use attributes to declare source, key, append conditions, and field mappings.

Apply one source attribute and one key attribute on the capture type:

  • [ApiCapture(api, Poll = ..., Route = ...)]
  • [WebhookCapture(path)]
  • [MessageCapture(topic)]
  • [CaptureKey(property)]
[ApiCapture("InvoicingApi", Poll = "10m", Route = "/invoices")]
[CaptureKey("id")]
public class InvoiceCapture;

ApiCapture references a named API configuration. If Route is not set, the configured API base URL is used directly.

Use one condition attribute on each event type:

  • [WhenPropertyChanged(property)]
  • [WhenAnyOf(properties...)]
  • [WhenAllOf(properties...)]
  • [WhenTransition(property, from, to)]
  • [WhenAdded]
  • [WhenRemoved]
[WhenPropertyChanged("status")]
public record InvoiceStatusChanged(
[MapFrom("$.status")] string Status,
[MapFromContext("occurred")] DateTimeOffset ChangedAt);

Use on event properties (or primary-constructor parameters):

  • [MapFrom(sourcePath)] maps from capture payload values
  • [MapFromContext(contextProperty)] maps from capture runtime context

Use this approach when:

  • Capture intent should live close to event contracts
  • Mapping is mostly direct and attribute-friendly
  • You want concise definitions with minimal fluent code