Skip to content

Modal.WebhookToken reference

Source: packages/modal/src/WebhookToken.ts

A Modal proxy auth token: the Modal-Key / Modal-Secret header pair that web endpoints and sandbox tunnels created with proxy authentication require. A scoped token works only in the environments it lists.

Modal shows a token’s secret once, at creation, so a token deleted outside Alchemy is recreated with a new secret on the next deploy. Tokens have no unique names, so they can’t be adopted and aren’t listed for alchemy nuke.

A workspace-wide token

import * as Modal from "@alchemy.run/modal";
export const Caller = Modal.WebhookToken("Caller", {});

A token scoped to one environment

import * as Modal from "@alchemy.run/modal";
export const Agents = Modal.Environment("Agents", {});
export const AgentsCaller = Modal.WebhookToken("AgentsCaller", {
scoped: true,
environments: [Agents],
});

WebhookToken: Calling a protected endpoint

Section titled “WebhookToken: Calling a protected endpoint”
const token = yield* AgentsCaller;
const response = yield* HttpClient.get(url, {
headers: {
"Modal-Key": token.tokenId,
"Modal-Secret": Redacted.value(token.tokenSecret),
},
});