Guide · REST API

Generate a PowerPoint deck from JSON and a template

Your numbers are JSON, the slides are a PowerPoint template your team maintains. XGenerate fills Word templates from the fields envelope today; PowerPoint templates with the same named placeholders are delivered as part of your integration, so the same request fills the slides and the deck comes back as PPTX or PDF.

Why not build the deck in code

  • A slide library makes every layout a programming task; the people who own the deck cannot move a box without a developer.
  • Automating PowerPoint on a server adds an Office installation to your deployment and is not supported for unattended use.
  • Monthly reports, offer decks and board packs repeat the same slides with new numbers; copying them by hand is where the errors come from.

The request

Today's API fills Word templates: a MERGEFIELD per value, a TableStart region per repeating table, PDF or DOCX back. PowerPoint templates are bound to the same envelope as part of your integration (tracked as xgenerateio/xgenerate#366); no PPTX output or presentation endpoint is exposed today, so the sample shows the Word-template call as it exists.

TOKEN=$(curl -sS https://auth.xgenerate.io/realms/xgenerate/protocol/openid-connect/token \
  -d grant_type=client_credentials \
  -d client_id="$XGENERATE_CLIENT_ID" \
  -d client_secret="$XGENERATE_CLIENT_SECRET" | jq -r .access_token)

# Today's call: a Word template with MERGEFIELD placeholders and a TableStart:kpis region.
cat > fields.json <<'JSON'
{
  "fields": [
    { "name": "report.title",  "value": "Quarterly review Q3 2026" },
    { "name": "report.period", "value": "July to September 2026" }
  ],
  "lists": [
    { "name": "kpis", "value": [
      { "fields": [ { "name": "label", "value": "Revenue" },       { "name": "value", "value": "CHF 1.2 M" } ] },
      { "fields": [ { "name": "label", "value": "New customers" }, { "name": "value", "value": "14" } ] }
    ] }
  ]
}
JSON

curl -sS https://api.xgenerate.io/v2/documents/generate \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@quarterly-review.docx" \
  -F "fields=@fields.json;type=application/json" \
  -F "format=PDF" \
  -o quarterly-review.pdf

# A PowerPoint template is bound to the same envelope as part of your integration;
# the API exposes no PPTX output today.

From .NET

using System.Net.Http.Json;

using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new("Bearer", token);

// Today's call fills a Word template over the JSON transport; a PowerPoint template
// bound as part of your integration takes the same envelope.
var request = new
{
    filename = "quarterly-review.docx",
    content = Convert.ToBase64String(await File.ReadAllBytesAsync("quarterly-review.docx")),
    format = "PDF",
    fields = new
    {
        fields = new[]
        {
            new { name = "report.title", value = "Quarterly review Q3 2026" },
            new { name = "report.period", value = "July to September 2026" }
        },
        lists = new[]
        {
            new
            {
                name = "kpis",
                value = new[]
                {
                    new { fields = new[] { new { name = "label", value = "Revenue" }, new { name = "value", value = "CHF 1.2 M" } } },
                    new { fields = new[] { new { name = "label", value = "New customers" }, new { name = "value", value = "14" } } }
                }
            }
        }
    }
};
var response = await http.PostAsJsonAsync(
    "https://api.xgenerate.io/v2/documents/generate", request);
response.EnsureSuccessStatusCode();

var result = await response.Content.ReadFromJsonAsync<GenerateResult>();
await File.WriteAllBytesAsync(result!.Filename, Convert.FromBase64String(result.Content));

record GenerateResult(string Filename, string Content, string Format);

The response

The multipart call streams the PDF back as raw bytes; the JSON transport returns filename, content, format and warnings. Warnings name image, QR and letterhead slots that received no value; merge fields and regions without data are removed without a warning. The request succeeds either way.

What XGenerate does not do

PPTX is not an output format of the API today: format is PDF or DOCX, templates are Word files, and there is no presentation endpoint. PowerPoint template support, text and table placeholders first and charts out of scope at first, is built as part of your integration and tracked as xgenerateio/xgenerate#366. Existing decks are not converted; a template is bound once and then filled per request.

Try it on your own template

Send us a Word file you use today. We render it with your data and return the PDF together with the adapted template, so your evaluation does not have to wait on us.

Request a demo

Related guides