//native
type Ai21 = {
apiKey: string;
};
/**
* Save Secret
*
*/
export async function main(
auth: Ai21,
body: { secret_name: string; secret_value: string; created_by: string },
) {
const url = new URL(`https://api.ai21.com/studio/v1/secrets`);
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 114 days ago