export type CreateApiV1NotesAttachmentsArgs = {body: BodyInit}; export type CreateApiV1NotesAttachmentsOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload an attachment for a note * * POST /v1/notes/attachments */ export const createApiV1NotesAttachments = async (args: CreateApiV1NotesAttachmentsArgs, options: CreateApiV1NotesAttachmentsOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/notes/attachments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };