export type CreateApiAgentphoneV1MessagesArgs = {body: {agent_id: string, to_number: string, body: string, media_url?: string | undefined, number_id?: string | undefined}}; export type CreateApiAgentphoneV1MessagesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send an SMS from an agent's phone number. First message compliance: Your initial SMS to any new contact must include (1) your brand name, (2) opt-in confirmation, and (3) opt-out instructions (e.g., "Reply STOP to unsubscribe"). Non-compliant first messages may be silently filtered by carriers. * * POST /agentphone/v1/messages */ export const createApiAgentphoneV1Messages = async (args: CreateApiAgentphoneV1MessagesArgs, options?: CreateApiAgentphoneV1MessagesOptions) => { 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/messages${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 };