export type CreateApiAgentphoneV1AgentsAgentIdWebhookArgs = {agentId: string, body: {url: string}}; export type CreateApiAgentphoneV1AgentsAgentIdWebhookOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set webhook URL for a specific agent. * * POST /agentphone/v1/agents/{agentId}/webhook */ export const createApiAgentphoneV1AgentsAgentIdWebhook = async (args: CreateApiAgentphoneV1AgentsAgentIdWebhookArgs, options?: CreateApiAgentphoneV1AgentsAgentIdWebhookOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/agentphone/v1/agents/${encodeURIComponent(String(args.agentId))}/webhook${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };