0

Update Resource Secrets

by
Published Apr 8, 2025

This endpoint updates the secrets of a resource.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Update Resource Secrets
7
 * This endpoint updates the secrets of a resource.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  integrationConfigurationId: string,
12
  resourceId: string,
13
  body: {
14
    secrets: { name: string; value: string; prefix?: string }[];
15
    partial?: false | true;
16
  },
17
) {
18
  const url = new URL(
19
    `https://api.vercel.com/v1/installations/${integrationConfigurationId}/resources/${resourceId}/secrets`,
20
  );
21

22
  const response = await fetch(url, {
23
    method: "PUT",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.text();
35
}
36