const baseUrl = process.env.FLOW_API_URL.replace(/\/$/, "");
const headers = {
"X-API-Key": process.env.FLOW_API_KEY,
customer: process.env.FLOW_CUSTOMER,
};
import { readFile } from "node:fs/promises";
const entities = JSON.parse(await readFile("created-entities.json", "utf8"));
const payload = {
branchId: process.env.BRANCH_ID,
updates: [
{ entityId: entities[0].id, key: "name", value: "API example: operating range" },
{ entityId: entities[1].id, key: "name", value: "API example: storage range" },
],
};
const url = new URL(`${baseUrl}/project/${process.env.PROJECT_ID}/entities/values/batch`);
const response = await fetch(url, {
method: "PUT",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const data = await response.json();
console.log(JSON.stringify(data, null, 2));