GET personas
Name
Value
{
"presigned_url": "https://...personas.zip?Expires=....Signature=...xxxx"
}{
"error": "Invalid request"
}Code segment
Last updated
Was this helpful?
{
"presigned_url": "https://...personas.zip?Expires=....Signature=...xxxx"
}{
"error": "Invalid request"
}Last updated
Was this helpful?
Was this helpful?
GET /api/personas endpoint
app.get("/api/personas", async (_req, res) => {
const AUTH_KEY = process.env.AUTH_KEY;
if (!AUTH_KEY) {
return res.status(500).json({ error: "AUTH_KEY not configured" });
}
// Step 1: Get the presigned URL for the personas file
const presignedRes = await fetch(
"https://api.conducttr.com/v1.1/eagle/personas",
{
headers: { Authorization: `Bearer ${AUTH_KEY}` },
}
);
if (!presignedRes.ok) {
return res.status(presignedRes.status).json({
error: "Failed to fetch personas presigned URL",
});
}
const presignedData = await presignedRes.json();
const zipUrl = presignedData.presigned_url;
// Step 2: Download the ZIP file
const zipRes = await fetch(zipUrl);
const zipBuffer = await zipRes.arrayBuffer();
// Step 3: Unzip and extract the JSON file
const zip = await JSZip.loadAsync(zipBuffer);
const jsonFileName = Object.keys(zip.files).find((name) =>
name.endsWith(".json")
);
if (!jsonFileName) {
return res.status(500).json({ error: "No JSON file found in ZIP" });
}
const jsonContent = await zip.files[jsonFileName].async("string");
const personasData = JSON.parse(jsonContent);
res.json(personasData);
});