Tutorials/Advanced
Advanced55 minREST

Consume Mappls events exactly once in effect

Verify signatures, deduplicate deliveries, order per aggregate, retry, and replay safely.

By the endA production webhook ingestion pipeline.

Build against an explicit contract

A consumer must apply each Mappls event once in business effect even when delivery is duplicated, delayed, reordered, or retried.

A Mappls developer projectA restricted REST applicationFixture data with no production credentialsA request, aggregate, or correlation ID strategy
Step 1

Define the user and system contract

A consumer must apply each Mappls event once in business effect even when delivery is duplicated, delayed, reordered, or retried. Record the region, data freshness, latency budget, privacy purpose, credential owner, and fallback before choosing an SDK or endpoint.

Step 2

Expose one safe receiver

Deploy a public DNS hostname on HTTPS port 443 with a bounded path and no URL credential, query, redirect, fragment, IP literal, private name, or alternate port. Keep every A and AAAA answer public; Mappls validates and pins all answers on every attempt.

InTouch Telematics · SDK or product slice
type AssetEvent = {
  id: string;
  assetId: string;
  occurredAt: string;
  type: "position" | "ignition" | "geofence.entered" | "geofence.exited";
  position?: { latitude: number; longitude: number; speedKph?: number };
};

export async function handleAssetEvent(event: AssetEvent) {
  // Idempotency matters: delivery may be retried.
  if (await events.exists(event.id)) return;
  await events.transaction(async () => {
    await events.record(event);
    await assets.apply(event.assetId, event);
  });
}
Step 3

Prove destination ownership

Create the endpoint in pending state, validate the signed webhook.endpoint_verification.v1 envelope, compute the versioned challenge proof with the endpoint secret, and return it in x-mappls-verification-response before requesting business or synthetic events.

Step 4

Verify before parsing

Read the exact raw body, validate timestamp freshness, event identity, and HMAC in constant time, then reject unknown versions or oversized payloads.

Step 5

Commit inbox and effect together

Insert the event ID/content hash, validate aggregate version, apply the domain transition, and append downstream work in one transaction.

Step 6

Recover deliberately

Return 2xx only after commit, retry transient dependencies out of band, quarantine conflicts, and replay from immutable evidence with an attributable operator reason. Issue a fresh ownership challenge after expiry; never replay one.

Step 7

Prove the production behavior

Automate the happy path and every named failure. The release is ready only when every dns answer stays public and the receiver does not redirect; destination ownership is proven before business fan-out; the same event id and body is a replay; changed content under one id is rejected; out-of-order transitions do not regress state. Capture provider request identity without logging credentials or unnecessary precise location.

Failure modes you must exercise

DNS changes to any non-public address

Fail fast with a typed, user-safe outcome and preserve the original request identity.

receiver returns a redirect

Keep the last verified state, mark freshness honestly, and retry only within the documented idempotency boundary.

ownership challenge expires or is superseded

Reconcile durable local and provider evidence before declaring success or issuing a compensating command.

signature is stale or invalid

Reconcile durable local and provider evidence before declaring success or issuing a compensating command.

database commits but response is lost

Reconcile durable local and provider evidence before declaring success or issuing a compensating command.

event arrives before its prerequisite

Reconcile durable local and provider evidence before declaring success or issuing a compensating command.

Never turn uncertainty into success

Timeout after a stateful command is an unknown outcome. Query by provider/idempotency identity or wait for authoritative events; do not blindly retry a new command.

Definition of done

every DNS answer stays public and the receiver does not redirectdestination ownership is proven before business fan-outthe same event ID and body is a replaychanged content under one ID is rejectedout-of-order transitions do not regress state

REST production checks

Credentials never reach a browser or mobile bundleTimeout, retry, and idempotency policies are explicitCoordinates, addresses, and identifiers have data-retention rulesEvery operation is attributable in logs and usage reporting

Continue from source, contracts, and a full app

These links resolve to repository-derived evidence; unsupported package names and endpoints are not filled in from guesswork.

Study the complete Field-service task lifecycle state machine

Run it, break it, then observe it

Start with fixture credentials, execute the failure plan, and use request logs, usage, webhook evidence, and operational metrics before promoting traffic.