//native
type Kustomer = {
apiKey: string;
};
/**
* Create forward by conversation
* Creates a forward to send through email. Forwards will send all messages in a conversation.
### NOTE
> To schedule the forward for delivery, create a forward with a `sendAt` property.
Any one of the following roles is required for this endpoint:
|Legacy Role|Equivalent Permission Set Role|
|-----|--------|
|org.user.conversation_forward.write|org.permission.conversation_forward.create|
*/
export async function main(
auth: Kustomer,
id: string,
body: {
channel: "email";
app?: "gmail" | "postmark";
customer?: string;
status?: "draft" | "sent" | "failed";
sendAt?: string;
to?: { email: string; name?: string }[];
from?: { email: string; name?: string };
body?: string;
subject?: string;
replyTo?: string;
template?: string;
payload?: {};
attachments?: {
id: string;
name: string;
contentType: string;
contentLength: number;
}[];
},
) {
const url = new URL(
`https://api.kustomerapp.com/v1/conversations/${id}/forwards`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago