> For the complete documentation index, see [llms.txt](https://docs.patagon.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.patagon.ai/en/api-reference/hooks.md).

# Hooks

Interact with our agents

## Agent WebChat Hook

> Submit a message to the specified agent.

```json
{"openapi":"3.0.0","info":{"title":"PatagonAI API v1","version":"1.0"},"tags":[{"name":"Hooks","description":"Interact with our agents"}],"servers":[{"url":"https://api.patagon.ai"}],"paths":{"/v1/hooks/{agentId}/webchat":{"post":{"summary":"Agent WebChat Hook","operationId":"postWebChatRequest","tags":["Hooks"],"description":"Submit a message to the specified agent.","parameters":[{"in":"path","name":"agentId","required":true,"schema":{"type":"string"},"description":"The Id of the agent"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string","description":"user message"},"userId":{"type":"string","description":"unique identifier for the user"},"sessionId":{"type":"string","description":"unique identifier for the session/user"},"stream":{"type":"boolean","default":false,"description":"Whether to stream the response as its being generated"}}}}}},"responses":{"200":{"description":"Message sent successfully","content":{"application/json":{"schema":{"type":"object","required":["messages","metadata"],"properties":{"messages":{"type":"array","description":"The messages in the response ordered by appearance","items":{"type":"object","description":"A message in the response","required":["content","type","url","caption"],"properties":{"content":{"type":"string","description":"The text of the response message"},"type":{"type":"string","enum":["text","image","document","video","audio"]},"url":{"type":"string","description":"The URL of the media file or empty string if the message is not of type image, document, video, or audio"}}}},"metadata":{"type":"object","required":["rawResponse","totalParts"],"properties":{"rawResponse":{"type":"string"},"inputMessage":{"type":"string"},"totalParts":{"type":"number"}}}}}}}},"400":{"description":"Bad request or unable to send message","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"404":{"description":"Agent not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.patagon.ai/en/api-reference/hooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
