allow or deny within 3 seconds. The proxy continues only if your server answers allow.
You save a hook in your Agent Vault project with a name, a URL, and a signing secret, then pick it on each service it should check. A service can have one hook, and one hook can check many services. The proxy asks a service’s hook about the service’s requests in every session that uses the service.
Use a hook when a service’s methods and paths or allowed tools can’t express the rule you want to apply. For example: to refuse refunds above a set amount, to allow writes to some repositories only, or to have a person approve an action first.
Your server gets the agent’s request, but never the service’s credential.
Prerequisites
- The Admin role in your Agent Vault project, to save hooks and pick them on services
- A server that accepts
POSTrequests at anhttps://orhttp://URL, and that every proxy in the project can reach
How it works
The proxy asks the service’s hook at a different point for each service type:- HTTP APIs and MCP servers: Before it sends each request that the hook checks
- Databases and SSH servers: Once for each connection the agent opens
Save a hook
You can save a hook in Infisical or through the API. Each proxy applies a change to a hook at its next check-in, within one poll interval (60 seconds by default).- In Infisical
- Through the API
1
In your Agent Vault project, go to Hooks and select Create Hook.
2
Enter a Name, such as
refund-approval, and an optional Description.3
In URL, enter your server’s URL, such as
https://hooks.example.com/agent-vault. The URL can’t include a username, a password, a query string, or a fragment.4
In Secret, enter the secret your server checks signatures with (see Pick a signing secret).
5
Select Create Hook.
Pick a signing secret
The proxy signs every request to your server with the hook’s signing secret, so your server can check that the request came from your proxy. The secret must be 32 to 512 characters long. It can use letters, numbers, and symbols, but no spaces. To generate a secret:/agent-vault/refunds and /agent-vault/deploys, so your server can tell which secret to check the signature with. The body names the hook too, but your server can’t trust the body until it has checked the signature.
Change the signing secret
When you replace the secret, each proxy keeps signing with the old secret until its next check-in. To keep your server from rejecting requests in the meantime:1
On your server, accept a signature made with either the old or the new secret.
2
Replace the secret on the hook.
3
After every proxy in the project has checked in (within one poll interval, at most 300 seconds), remove the old secret from your server.
Edit or delete a hook
The Used By column on the Hooks page lists the services each hook checks. To edit a hook, go to Hooks, open the hook’s actions menu, and select Edit. Through the API, call the Update hook endpoint with only the fields you want to change. If you leave outsecret, the hook keeps its saved secret.
To delete a hook, open its actions menu and select Delete, or call the Delete hook endpoint. From the proxy’s next check-in, the proxy stops asking about requests to the services that used the hook, and those services keep working without a hook.
Attach a hook to a service
You pick a service’s hook on the service itself. Each proxy applies the change at its next check-in.- In Infisical
- Through the API
1
Go to Services, then select Add Service, or open a service’s actions menu and select Edit.
2
On the Hook step, pick a saved hook in Hook. To create a hook here, select Create New Hook.
3
Optionally, narrow the requests the hook checks for this service: Methods and Paths for an HTTP API, or Tools for an MCP server.
4
Check the hook on the Review step, then select Add Service, or Save if you’re editing the service.
Narrow the requests the hook checks
Without narrowing, the proxy asks the hook about every request to the service. To ask about only some of them, narrow the hook on the service. The narrowing depends on the service’s type:- HTTP APIs:
methods, a list of methods such asPOST, andpaths, a list of path prefixes that match the same way as a service’s paths (if you set both, a request has to match both) - MCP servers:
tools, a list of tool names (the proxy then asks only about calls to those tools, and not about calls such asinitializeortools/list) - Databases and SSH servers: No narrowing, so the proxy asks the hook about every connection
Use a hook with an inline service
An inline service can use a saved hook too. Name the hook in the inline service’shook field, with the same narrowing as a service in the project:
Build the hook server
For each check, your server receives onePOST request, verifies the request’s signature, and answers allow or deny in JSON. The proxy waits at most 3 seconds for the answer.
Verify the signature
The proxy signs requests the way the Standard Webhooks specification describes, so you can verify them with any Standard Webhooks library. Load the library in raw-key mode. In the default mode, the library rejects every signature from the proxy. Verify the raw request body, before any framework parses it. The libraries also refuse a request if itswebhook-timestamp is more than five minutes off your server’s clock.
Request format
Each request has these headers:Answer the request
Answer with a2xx status and a JSON body, for both decisions:
Text for the session logs, up to 512 bytes.
message, tell the agent what to do next, such as whether to try again.
The proxy can send the same check twice if a connection to your server drops. Both copies have the same webhook-id, so answer both with the same decision. If your server records or counts checks, count each webhook-id once.
Unusable answers
The proxy refuses the request if any of the following happens:- No answer within 3 seconds
- A connection or TLS error
- A status other than
2xx - A redirect
- A body larger than 64 KB
- A body that isn’t valid JSON
- A missing or unknown
decision
Considerations
Your server sees the agent’s request as the agent sent it, before the proxy changes anything. Keep these points in mind when you write a rule:- No credentials: The request doesn’t include the service’s credential or its custom headers
- Substitutions: If the agent sends a substitution placeholder, your server sees the placeholder, not the real value
- Method overrides: Some APIs accept a header such as
X-HTTP-Method-Overridethat turns aPOSTinto aDELETE, so check those headers as well asmethod - Large bodies: The proxy sends at most the first 1 MB of the body, and sets
bodyTruncatedtotrueif it cut the body short - Compressed bodies: A body sent with a
Content-Encodingheader, such asgzip, arrives still compressed, as base64 - Repeated keys: A header, a query parameter, or a JSON key can appear more than once, and the API might read a different copy than your parser does
Ask a person for approval
Your server has 3 seconds to answer, which isn’t enough time for a person to approve a request. To have a person approve an action, deny the request first, then allow it when the agent tries again:1
When the request arrives, record a pending approval for the session’s
id and the action, and send the approval request to a person, such as in Slack. To find who to ask, use session.metadata or session.onBehalfOf.2
Deny the request with a
message that tells the agent to try again later, such as Approval requested from the on-call engineer. Try again in 5 minutes.3
When the agent sends the same request again, check the approval. If the person approved it, answer
allow and mark the approval as used, so it covers only that one request. If the approval is still pending, deny the request again with a message that tells the agent to wait.webhook-id, and for MCP servers, a new JSON-RPC id.
Refused requests
When the proxy refuses a request, the agent gets one of these messages:- If your server denies the request: Your
message, or “Your organization’s hook refused this request.” if you sent none (for databases and SSH servers, “Your organization’s hook refused this connection.”) - If your server doesn’t give a usable answer: A message that says the hook didn’t give a usable answer
- HTTP APIs: A
403response with thehook_deniederror code if your server denies the request, or a503response with thehook_failederror code and aRetry-After: 5header if it doesn’t give a usable answer - Tool calls to MCP servers: A tool result with
isErrorset totrue, which the agent reads as the tool’s answer - Other MCP calls: A JSON-RPC error with the message
- Databases and SSH servers:
infisical agent-vault connectprints the service’s name and the message, as inanalytics: <message>, and the proxy closes the agent’s connection without opening one to the server
Session log entries
Each refusal adds a row to the session logs. For a denial, the row ends with yourreason. For databases and SSH servers, the row shows your message instead if you sent no reason.


reason that the session’s owner or the project’s admins shouldn’t see. They can read the session logs, and the proxy also writes reason to its own log.
Limitations
- Session labels and metadata aren’t a safe input: The session’s owner and project admins can change the label and metadata at any time, so never allow a request because of
session.labelorsession.metadata - MySQL can switch databases:
connection.databaseis the database the connection opens with, but a MySQL client can switch to any other database the service’s account can reach withUSE, so limit the account’s grants on the server - One MCP tool call can reach the hook more than once: If an MCP server asks the agent for more input during a tool call, the agent sends the tool call again with a new JSON-RPC ID, and the proxy asks the hook again
http://isn’t encrypted: Over anhttp://URL, the request (with the agent’s headers and body) and your server’s answer cross the network unencrypted, so usehttp://only on a network you trust- Private certificate authorities: If your server’s
https://certificate comes from a private certificate authority, every machine that runs a proxy has to trust that authority (on Linux, setSSL_CERT_FILEorSSL_CERT_DIRin the proxy’s environment to the authority’s certificate)
Troubleshooting
The proxy doesn't ask the hook about a request
The proxy doesn't ask the hook about a request
Check that:
- The service has the hook (the Used By column on the Hooks page lists the hook’s services)
- The hook’s methods, paths, or tools on the service match the request
- The proxy has checked in since you last changed the hook or the service (within one poll interval)
Every request is refused with hook_failed
Every request is refused with hook_failed
The proxy couldn’t get a usable answer from your server. Check that:
- Every machine that runs a proxy in the project can reach the hook URL
- Your server answers within 3 seconds, with a
2xxstatus and a JSON body whosedecisionisallowordeny - Your server doesn’t redirect the request, for example from
http://tohttps://
Your server rejects every signature
Your server rejects every signature
Check that:
- Your server loads the library in raw-key mode, as in Verify the signature
- The secret on your server matches the hook’s signing secret exactly (if you recently changed it, proxies switch on their next check-in)
- Your server verifies the raw body, before a framework parses or reformats it
- The clocks on the proxy’s machine and on your server are both correct, since the library refuses a timestamp more than five minutes off
The MCP server stops working after you attach a hook
The MCP server stops working after you attach a hook
If the MCP server’s hook has no
tools, the proxy asks the hook about every request to the MCP server, including initialize, tools/list, and notifications. Allow those requests on your server, or narrow the hook to the tools you want to check.