# Webhooks ## `client.Webhooks.Unwrap(ctx) error` **** `` ### Example ```go package main import ( "context" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) err := client.Webhooks.Unwrap(context.TODO()) if err != nil { panic(err.Error()) } } ``` ## `client.Webhooks.UnsafeUnwrap(ctx) error` **** `` ### Example ```go package main import ( "context" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) err := client.Webhooks.UnsafeUnwrap(context.TODO()) if err != nil { panic(err.Error()) } } ``` ## Domain Types ### Unsafe Unwrap Webhook Event - `type UnsafeUnwrapWebhookEvent struct{…}` The envelope for an objective event webhook delivery. Contains timestamp, event type, and the webhook data payload. - `Data UnsafeUnwrapWebhookEventData` The webhook data payload with flat top-level keys for agent, variation, objective, and event. - `Agent ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "agent_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `CreatedAt Time` Timestamp when this resource was created - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` ID of the actor (user or service account) that created this resource - `WorkspaceID string` Workspace this resource belongs to for organizational grouping (prefixed ULID) - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `AgentVariation ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `Objective OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ID string` Unique identifier for the operation (prefixed ULID, e.g., "obj_01HXK...") - `AccountID string` Account this operation belongs to for multi-tenant isolation (prefixed ULID) - `CreatedAt Time` Timestamp when this operation was created ULID includes timestamp information, but this explicit field enables easier querying - `ProfileID string` ID of the actor (user or service account) that created this operation - `WorkspaceID string` Workspace this operation belongs to for organizational grouping (prefixed ULID) - `ExternalID string` External ID for the operation (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"priority": "high", "source": "api", "workflow": "onboarding"} - `ObjectiveEvent UnsafeUnwrapWebhookEventDataObjectiveEvent` - `Data ObjectiveEventData` - `AssistantMessage AssistantMessage` - `Content string` - `ToolCalls []AssistantToolCall` - `Arguments string` - `FunctionName string` - `Tool CallableTool` CallableTool is a union that represents a tool that can be called by an agent. In Cadenya, a tool that is used within an agent objective might be a user-defined tool (IE: MCP, HTTP), another Agent (useful to separate context), or a Cadenya Tool (one Cadenya provides). - `Agent ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `CadenyaProvidedTool ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `Tool ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `ContextWindowCompacted ContextWindowCompacted` - `MessagesCompacted int64` Number of messages that were compacted - `NewContextWindow ObjectiveContextWindowData` The new context window created by this compaction - `CompletionTokens int64` A calculated value for how many completion tokens (output tokens) have been used in this context window - `ObjectiveID string` The objective's ID that this window belongs to - `PreviousWindowContinueInstructions string` The instructions for this window to continue from a previous window's chat history. - `PromptTokens int64` A calculated value for how many prompt tokens (input tokens) have been used in this context window - `Sequence int64` sequence is a numeric representation of which context window this is. Sequences are useful to perform a max(sequence) on in order to calculate how many context windows an objective has. - `Strategies []string` The strategies that were applied during this compaction - `Summary string` The summary generated by the summarization strategy, if used. - `Error ObjectiveError` - `Message string` - `Type string` - `SubObjectiveCreated SubObjectiveCreated` - `Metadata OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ToolApprovalRequested ToolApprovalRequested` - `ToolCallID string` The ID of the objective tool call record. Use this ID with the ApproveToolCall or DenyToolCall RPCs to approve or deny the tool call. - `ToolApproved ToolApproved` - `ToolCallID string` The ID of the objective tool call record that was approved via the ApproveToolCall RPC. - `ToolCalled ToolCalled` - `ToolCallID string` The ID of the objective tool call record that was executed. - `ToolDenied ToolDenied` - `Memo string` The memo provided by the reviewer when denying the tool call. This is passed to the agent to provide further instructions. - `ToolCallID string` The ID of the objective tool call record that was denied via the DenyToolCall RPC. - `ToolError ToolError` - `Message string` - `ToolCallID string` The ID of the objective tool call record that encountered an error during execution. - `ToolResult ToolResult` - `Content string` - `ToolCallID string` - `Type string` - `UserMessage UserMessage` - `Content string` - `Metadata OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ContextWindowID string` - `Info ObjectiveEventInfo` - `CreatedBy Profile` Profile represents a human user at the account level. Profiles are account-scoped resources that can be associated with multiple workspaces through the Actor model. Authentication for profiles is handled via SSO/OAuth (WorkOS). - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec ProfileSpec` ProfileSpec contains the profile-specific fields - `Type ProfileSpecType` Type is the type of profile. User's are humans, API keys are computers. You know the deal. - `const ProfileSpecTypeProfileTypeUser ProfileSpecType = "PROFILE_TYPE_USER"` - `const ProfileSpecTypeProfileTypeAPIKey ProfileSpecType = "PROFILE_TYPE_API_KEY"` - `const ProfileSpecTypeProfileTypeSystem ProfileSpecType = "PROFILE_TYPE_SYSTEM"` - `Email string` Email address of the user (required, unique per account) - `Name string` Display name for the user (e.g., "Bobby Tables") - `Objective OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `Timestamp Time` - `Type string` The event type, prefixed with objective_event. (e.g., objective_event.tool_result) ### Unwrap Webhook Event - `type UnwrapWebhookEvent struct{…}` The envelope for an objective event webhook delivery. Contains timestamp, event type, and the webhook data payload. - `Data UnwrapWebhookEventData` The webhook data payload with flat top-level keys for agent, variation, objective, and event. - `Agent ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "agent_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `CreatedAt Time` Timestamp when this resource was created - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` ID of the actor (user or service account) that created this resource - `WorkspaceID string` Workspace this resource belongs to for organizational grouping (prefixed ULID) - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `AgentVariation ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `Objective OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ID string` Unique identifier for the operation (prefixed ULID, e.g., "obj_01HXK...") - `AccountID string` Account this operation belongs to for multi-tenant isolation (prefixed ULID) - `CreatedAt Time` Timestamp when this operation was created ULID includes timestamp information, but this explicit field enables easier querying - `ProfileID string` ID of the actor (user or service account) that created this operation - `WorkspaceID string` Workspace this operation belongs to for organizational grouping (prefixed ULID) - `ExternalID string` External ID for the operation (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"priority": "high", "source": "api", "workflow": "onboarding"} - `ObjectiveEvent UnwrapWebhookEventDataObjectiveEvent` - `Data ObjectiveEventData` - `AssistantMessage AssistantMessage` - `Content string` - `ToolCalls []AssistantToolCall` - `Arguments string` - `FunctionName string` - `Tool CallableTool` CallableTool is a union that represents a tool that can be called by an agent. In Cadenya, a tool that is used within an agent objective might be a user-defined tool (IE: MCP, HTTP), another Agent (useful to separate context), or a Cadenya Tool (one Cadenya provides). - `Agent ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `CadenyaProvidedTool ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `Tool ResourceMetadata` Standard metadata for persistent, named resources (e.g., agents, tools, prompts) - `ContextWindowCompacted ContextWindowCompacted` - `MessagesCompacted int64` Number of messages that were compacted - `NewContextWindow ObjectiveContextWindowData` The new context window created by this compaction - `CompletionTokens int64` A calculated value for how many completion tokens (output tokens) have been used in this context window - `ObjectiveID string` The objective's ID that this window belongs to - `PreviousWindowContinueInstructions string` The instructions for this window to continue from a previous window's chat history. - `PromptTokens int64` A calculated value for how many prompt tokens (input tokens) have been used in this context window - `Sequence int64` sequence is a numeric representation of which context window this is. Sequences are useful to perform a max(sequence) on in order to calculate how many context windows an objective has. - `Strategies []string` The strategies that were applied during this compaction - `Summary string` The summary generated by the summarization strategy, if used. - `Error ObjectiveError` - `Message string` - `Type string` - `SubObjectiveCreated SubObjectiveCreated` - `Metadata OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ToolApprovalRequested ToolApprovalRequested` - `ToolCallID string` The ID of the objective tool call record. Use this ID with the ApproveToolCall or DenyToolCall RPCs to approve or deny the tool call. - `ToolApproved ToolApproved` - `ToolCallID string` The ID of the objective tool call record that was approved via the ApproveToolCall RPC. - `ToolCalled ToolCalled` - `ToolCallID string` The ID of the objective tool call record that was executed. - `ToolDenied ToolDenied` - `Memo string` The memo provided by the reviewer when denying the tool call. This is passed to the agent to provide further instructions. - `ToolCallID string` The ID of the objective tool call record that was denied via the DenyToolCall RPC. - `ToolError ToolError` - `Message string` - `ToolCallID string` The ID of the objective tool call record that encountered an error during execution. - `ToolResult ToolResult` - `Content string` - `ToolCallID string` - `Type string` - `UserMessage UserMessage` - `Content string` - `Metadata OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `ContextWindowID string` - `Info ObjectiveEventInfo` - `CreatedBy Profile` Profile represents a human user at the account level. Profiles are account-scoped resources that can be associated with multiple workspaces through the Actor model. Authentication for profiles is handled via SSO/OAuth (WorkOS). - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec ProfileSpec` ProfileSpec contains the profile-specific fields - `Type ProfileSpecType` Type is the type of profile. User's are humans, API keys are computers. You know the deal. - `const ProfileSpecTypeProfileTypeUser ProfileSpecType = "PROFILE_TYPE_USER"` - `const ProfileSpecTypeProfileTypeAPIKey ProfileSpecType = "PROFILE_TYPE_API_KEY"` - `const ProfileSpecTypeProfileTypeSystem ProfileSpecType = "PROFILE_TYPE_SYSTEM"` - `Email string` Email address of the user (required, unique per account) - `Name string` Display name for the user (e.g., "Bobby Tables") - `Objective OperationMetadata` Metadata for ephemeral operations and activities (e.g., objectives, executions, runs) - `Timestamp Time` - `Type string` The event type, prefixed with objective_event. (e.g., objective_event.tool_result)