# Building your JSON payload

Here we outline the component parts of the JSON payload necessary for creating a presentation.&#x20;

### Referencing your template PowerPoint file

First you must tell the API where to retrieve the PowerPoint file that contains the slides you intend to use as templates for your presentation. You will either refer to the template PowerPoint file by its name, or the link where it can be downloaded.&#x20;

In this case we are sending the template PowerPoint file directly with the POST request:

```javascript
{
  "presentation": {
    "template": "slides_as_template.pptx",
    "export_version": "Pptx2010",
    ....
```

Refer to [Templating your presentation](https://app.gitbook.com/@adambaker/s/json-to-pptx/~/drafts/-Mkb5A8tT0R978I1ByGW/creatine-a-new-presentation/slide-as-template) for more on sharing template PowerPoint files.&#x20;

### Defining your slides:

For each slide you want to create, you will need to build an object in the "slides" array:

```json
....
  "slides": [
    {
      ...shape objects...
    }
  ]
....
```

### Template type and which slide to use:

For each slide object you are required to specify the type of slide you want to use as template. In this case we are using a **slide** from our template PowerPoint file.

Additionally you are required to choose which template slide to use as template for your new slide (zero-based):

```bash
....
  "type": "slide",
  "slide_index": 0,
....
```

### Updating your shapes

Within your slide object you can refer to an array of shape objects.&#x20;

Everything on a slide is a shape. Each shape object has a name. To select and populate a specific shape, you must reference it by **name**. To find a specific shape by name see [here](https://docs.powerpointgeneratorapi.com/creatine-a-new-presentation/finding-shape-names-slides-as-template). Then you can specify the content you want placed into that shape on your slide. In this case we are adding a string to a text shape:

```bash
....
  "shapes": [
    {
      "name": "Title 1",
      "content": "Automate PowerPoint Generation"
    }
  ]
....
```

## Complete example payload

Payload below will generate a PowerPoint presentation with two slides, populating a textbox on slide one and a chart on slide two whilst retaining the styling of the two slides from the template PowerPoint file:

Template Presentation

{% file src="/files/-Mj4nNSqMXRJcPx-vlBq" %}

JSON Payload

```javascript
{
   "presentation":{
      "template":"slides_as_template.pptx",
      "export_version":"Pptx2010",
      "slides":[
         {
            "type":"slide",
            "slide_index":0,
            "shapes":[
               {
                  "name":"Title 1",
                  "content":"Automate PowerPoint Generation"
               }
            ]
         },
         {
            "type":"slide",
            "slide_index":1,
            "shapes":[
               {
                  "name":"Chart 14",
                  "title":"Average Annual Precipitations",
                  "data":[
                     [
                        "North",
                        "South",
                        "East",
                        "West"
                     ],
                     [
                        "January",
                        "February",
                        "March"
                     ],
                     [
                        11,
                        15,
                        4,
                        7
                     ],
                     [
                        25,
                        60,
                        77,
                        30
                     ],
                     [
                        40,
                        50,
                        65,
                        44
                     ]
                  ]
               }
            ]
         }
      ]
   }
}
```

## Using above payload, create a presentation using slide as template

<mark style="color:green;">`POST`</mark> `https://gen.powerpointgeneratorapi.com/v1.0/generator/create`

#### Headers

| Name                                            | Type   | Description                |
| ----------------------------------------------- | ------ | -------------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | string | multipart/form-data        |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer authorization token |

#### Request Body

| Name                                       | Type   | Description                                              |
| ------------------------------------------ | ------ | -------------------------------------------------------- |
| files                                      | object | PPTX file used as styling and layout template            |
| jsonData<mark style="color:red;">\*</mark> | string | JSON payload which contains  the presentation definition |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powerpointgeneratorapi.com/knowledge-base/building-your-payload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
