Handling Added SMS Webhook Fields: A Contract Example and Test Matrix

Published: · Updated:
Share

An added webhook field is a compatibility question governed by the event contract. Permit documented optional extensions, but give missing required data, invalid types and unsupported versions explicit handling paths.

Start with a fictional event

The fields event_id, message_id, status and region_hint below are teaching examples, not this site’s interface. The new event adds region_hint to three original fields. A handler using only the original fields can accept that extension only under the applicable contract.

{
  "event_id": "example-event-001",
  "message_id": "example-message-001",
  "status": "received",
  "region_hint": "example-region"
}
Expansion and arbitrary assignment are different

Declare required data and extension behavior

This illustrative JSON Schema requires three fields, restricts status and explicitly permits additional properties. Replace the fictional names and values with the real service specification before implementation.

{
  "type": "object",
  "properties": {
    "event_id": {
      "type": "string"
    },
    "message_id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "received",
        "failed"
      ]
    }
  },
  "required": [
    "event_id",
    "message_id",
    "status"
  ],
  "additionalProperties": true
}

properties describes named fields, required makes fields mandatory, and additionalProperties defines treatment of undeclared properties. Setting it to false rejects an undeclared field; true permits extensions. Different contracts can therefore give the same added field different validation outcomes.

JSON Schema official object reference

Define an expected result for each change

ChangeIllustrative result
Add region_hintAccept structure and read only validated known fields
Remove message_idReject missing required data
Make event_id an objectReject incorrect type
Use another status valueReject unsupported enum value
Provider announces a new versionCompare the new contract before deciding compatibility

Avoid assigning an entire external object into an internal business model. Select validated fields and separately apply the documented authentication, ownership and authorization checks. Structure validation concerns format rather than those permissions.

Compatibility needs explicit fixture outcomes

Exercise the deployed processing path

Keep fictional fixtures for the normal event, allowed extension, missing property, wrong type and unknown state. Run the serializer, validator and business handler together rather than merely checking that a schema file exists.

Test in isolation before a controlled deployment. Retain a redacted event reference and reason for unsupported inputs, using bounded handling rather than repeatedly retrying an event that cannot satisfy the contract.

Need help?

Click here and start chatting with us!