Extension Fields and Context
Overview
AdCP provides two mechanisms for adding custom data to requests and responses:ext- Platform-specific extensions that MAY affect behavior (vendor-namespaced)context- Opaque correlation data that is echoed unchanged
Key Differences
| Aspect | ext | context |
|---|---|---|
| Purpose | Platform-specific parameters | Opaque correlation data |
| Affects behavior | MAY | NEVER |
| Namespaced | Yes (vendor keys required) | No |
| Parsed by agents | MAY be | NEVER |
| Example | ext.gam.test_mode | context.ui_session_id |
Extension Fields (ext)
Extension fields enable platform-specific functionality, private publisher-buyer agreements, experimental features, and forward compatibility. Extensions follow industry conventions established by IAB standards like OpenRTB.
Schema Pattern
Extensions appear in the same pattern everywhere they’re used (requests, responses, and domain objects):ext object:
- Is always optional (never required)
- Accepts any valid JSON structure
- Must be preserved by implementations (even unknown fields)
- Is not validated by AdCP schemas (implementation-specific validation allowed)
Use Cases by Layer
Request extensions - Platform-specific parameters, vendor configuration, custom capabilities:Context Field (context)
Context provides opaque correlation data that is echoed unchanged in responses and webhooks. Agents NEVER parse or use context to affect behavior - it exists solely for the initiator’s internal tracking needs.
Schema Pattern
context object:
- Is always optional (never required)
- Accepts any valid JSON structure
- Is echoed unchanged in responses and webhook payloads
- NEVER affects agent behavior or processing
- Is not interpreted by agents (completely opaque)
Common Context Patterns
Context is typically used for:- UI/Session tracking - Maintaining state across async operations
- Request correlation - Tracing requests through distributed systems
- Internal identifiers - Mapping to initiator’s internal data structures
- Organization context - Multi-tenant tracking
Context in Responses
Responses echo context from the request, enabling correlation between async operations:Namespacing Conventions
CRITICAL: All Extensions Must Be Namespaced
Extensions MUST use vendor/platform namespacing to avoid naming collisions: ✅ Correct - Namespaced:Namespace Guidelines
- Use reverse-domain format for custom namespaces:
com.example.feature - Use common platform short names:
gam,roku,ttd,magnite,nielsen,comscore - Consistent naming: Same namespace across all usage (don’t mix
gamandgoogle_ad_manager) - Documented namespaces: Maintain internal registry of your organization’s namespaces
Why Namespacing Matters
Without namespacing:- Name collisions between platforms are inevitable
- Extensions become ambiguous (whose
test_mode?) - Impossible to support multiple platforms simultaneously
- Harder to deprecate platform-specific features
Proposing Spec Additions
If your extension field represents common ad tech functionality that would benefit all AdCP implementations:- Use extensions first - Validate the feature in production
- Gather evidence - Document actual usage patterns and adoption
- Propose standardization - Submit RFC to standardize as core field
- Dual support period - Support both ext and core field during transition
- Eventual deprecation - Once standardized, deprecate the extension version
Validation Rules
Extension Field Requirements
AdCP implementations MUST:- Accept
extfields on all schemas that define them - Preserve
extvalues even if not understood - Not reject requests solely due to unknown
extcontents - Pass through
extvalues in responses when echoing objects
- Parse and validate known
extfields - Use
extvalues to modify behavior (document this clearly) - Add their own
extfields to responses - Reject requests if KNOWN
extvalues are invalid
- Require
extfields (always optional) - Reject unknown/unexpected
extfields - Modify
extvalues from requests (except to add platform-specific response data)
Context Field Requirements
AdCP implementations MUST:- Echo
contextunchanged in responses (exact JSON preservation) - Echo
contextunchanged in webhook payloads - Never parse or interpret
contextcontents - Never use
contextto affect behavior
- Require
contextfields (always optional) - Modify
contextvalues in any way - Use
contextfor operational decisions
Extension Examples
Comprehensive Multi-Platform Example
Best Practices
When to Use Extensions vs Context
Useext when:
- Platform needs to parse the data
- Data MAY affect operational behavior
- Data represents platform-specific configuration
- Data should persist across operations (on objects)
context when:
- Data is only for caller’s internal use
- Data should never affect agent behavior
- Data is for correlation/tracking only
- Data needs to be echoed unchanged
Extension Design Guidelines
- Always namespace - Every extension must be under a vendor key
- Document extensively - Extensions are implementation-specific, not self-documenting
- Version carefully - Breaking changes in extensions affect integrations
- Use JSON Schema - Define schemas for your extensions
- Monitor usage - Track which extensions are actually used
- Consider standardization - Popular extensions should become core fields
Context Design Guidelines
- Keep it opaque - Don’t structure context for agents to parse
- Avoid large payloads - Context is echoed in every response
- Don’t rely on preservation - While agents MUST echo context, plan for edge cases
- Use for correlation only - Never use context for operational data