//native
type Ultravox = {
apiKey: string;
};
/**
* Api keys update
* Updates an API key.
*/
export async function main(
auth: Ultravox,
api_key_prefix: string,
body: {
prefix: string;
created: string;
creator: string;
name: string;
expiryDate: string;
revoked?: false | true;
},
) {
const url = new URL(`https://api.ultravox.ai/api/api_keys/${api_key_prefix}`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
"X-API-Key": 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 428 days ago