Handle webhook from agent (async task completion)
Accepts either:
For A2A payloads, extracts the ADCP response from artifacts[0].parts[].data so handlers receive the unwrapped response, not the raw protocol structure.
Webhook payload from agent (WebhookPayload or raw A2A task)
Optionalsignature: stringX-ADCP-Signature header (format: "sha256=...")
Optionaltimestamp: string | numberX-ADCP-Timestamp header (Unix timestamp)
OptionaltaskType: stringTask type override (useful when not in payload, e.g., from URL path)
Whether webhook was handled successfully
app.post('/webhook/:taskType', async (req, res) => {
const signature = req.headers['x-adcp-signature'];
const timestamp = req.headers['x-adcp-timestamp'];
try {
const handled = await client.handleWebhook(req.body, signature, timestamp, req.params.taskType);
res.status(200).json({ received: handled });
} catch (error) {
res.status(401).json({ error: error.message });
}
});
Generate webhook URL using macro substitution
Type of task (e.g., 'get_products', 'media_buy_delivery')
Operation ID for this request
Full webhook URL with macros replaced
// With template: "https://myapp.com/webhook/{task_type}/{agent_id}/{operation_id}"
const webhookUrl = client.getWebhookUrl('sync_creatives', 'op_123');
// Returns: https://myapp.com/webhook/sync_creatives/agent_x/op_123
// With template: "https://myapp.com/webhook?agent={agent_id}&op={operation_id}"
const webhookUrl = client.getWebhookUrl('sync_creatives', 'op_123');
// Returns: https://myapp.com/webhook?agent=agent_x&op=op_123
Create an HTTP webhook handler that automatically verifies signatures
This helper creates a standard HTTP handler (Express/Next.js/etc.) that:
HTTP handler function compatible with Express, Next.js, etc.
Verify webhook signature using HMAC-SHA256 per AdCP PR #86 spec
Signature format: sha256={hex_signature} Message format: {timestamp}.{json_payload}
Webhook payload object
X-ADCP-Signature header value (format: "sha256=...")
X-ADCP-Timestamp header value (Unix timestamp)
true if signature is valid
Discover available advertising products
Product discovery parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
List available creative formats
Format listing parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Create a new media buy
Media buy creation parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Update an existing media buy
Media buy update parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Sync creative assets
Creative sync parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
List creative assets
Creative listing parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Preview a creative
Preview creative parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Get media buy delivery information
Delivery information parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
List authorized properties
Property listing parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Provide performance feedback
Performance feedback parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Get audience signals
Signals request parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Activate audience signals
Signal activation parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Execute any task by name with type safety
Name of the task to execute
Task parameters
OptionalinputHandler: InputHandlerHandler for clarification requests
Optionaloptions: TaskOptionsTask execution options
Resume a deferred task using its token
Deferred task token
Handler to provide the missing input
Continue an existing conversation with the agent
Message to send to the agent
Conversation context ID to continue
OptionalinputHandler: InputHandlerHandler for any clarification requests
Clear conversation history for a task
Get the agent configuration
Get the agent ID
Get the agent name
Get the agent protocol
Get active tasks for this agent
Get detailed information about a specific task
ID of the task to get information for
Promise resolving to task information
Subscribe to task notifications for this agent
Function to call when task status changes
Unsubscribe function
Subscribe to all task events (create, update, complete, error)
Event callbacks for different task events
Unsubscribe function
Register webhook URL for receiving task notifications
URL to receive webhook notifications
OptionaltaskTypes: string[]Optional array of task types to watch (defaults to all)
Unregister webhook notifications
Get comprehensive agent information including name, description, and available tools/skills
Works with both MCP (tools) and A2A (skills) protocols to discover what the agent can do.
Promise resolving to agent information including tools
StaticdiscoverQuery a creative agent to discover available creative formats
This is a static utility method that allows you to query any creative agent (like creative.adcontextprotocol.org) to discover what formats are available before creating a media buy.
URL of the creative agent (e.g., 'https://creative.adcontextprotocol.org/mcp')
Protocol to use ('mcp' or 'a2a'), defaults to 'mcp'
Promise resolving to the list of available formats
// Discover formats from the standard creative agent
const formats = await SingleAgentClient.discoverCreativeFormats(
'https://creative.adcontextprotocol.org/mcp'
);
// Find a specific format
const banner = formats.find(f => f.format_id.id === 'display_300x250_image');
// Use the format in a media buy
await salesAgent.createMediaBuy({
packages: [{
format_ids: [{
agent_url: banner.format_id.agent_url,
id: banner.format_id.id
}]
}]
});
Internal single-agent client implementation
This is an internal implementation detail used by AgentClient and ADCPMultiAgentClient. External users should use AdCPClient (alias for ADCPMultiAgentClient) instead.
Key features: