๐Ÿ”—Create a Briefing Document from a Website

This snippet mirrors the website-based document recipe using PHP.

<?php

$token = getenv('AUTOCONTENT_TOKEN') ?: 'YOUR_API_TOKEN';
$endpoint = 'https://api.autocontentapi.com/content/Create';

$payload = [
  'outputType' => 'briefing_doc',
  'format' => 'html',
  'resources' => [
    [
      'type' => 'website',
      'content' => 'https://example.com/2026-cloud-security-report'
    ]
  ],
  'text' => 'Summarize the report for CISOs. Use sections for market context, top threats, and recommended priorities.',
  'language' => 'en',
];

$body = json_encode($payload);
if ($body === false) {
    fwrite(STDERR, 'Failed to encode payload: ' . json_last_error_msg() . "\n");
    exit(1);
}

$ch = curl_init($endpoint);
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $token,
        'Content-Type: application/json',
        'Accept: application/json',
    ],
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
if ($response === false) {
    fwrite(STDERR, 'Request failed: ' . curl_error($ch) . "\n");
    curl_close($ch);
    exit(1);
}

$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status >= 400) {
    fwrite(STDERR, "HTTP $status\n$response\n");
    exit(1);
}

echo "Document request accepted:\n" . $response . "\n";

Set YOUR_API_TOKEN (or AUTOCONTENT_TOKEN) before running.

See also

Last updated