> For the complete documentation index, see [llms.txt](https://developers.gamma.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.gamma.app/build-with-gamma/import-a-presentation.md).

# Import a presentation

Import a PowerPoint or PDF deck into Gamma through the API, as is, with changes, or as the source for a new deck.

Hand Gamma a deck (.pptx, .potx, or a PDF of slides) or a link to one, and get a gamma back: imported as is, edited, restyled, or used as the source for a new deck. It takes two calls: upload the file, then start an agent generation that names it.

## Quick reference

* Upload with [`POST /uploads`](https://developers.gamma.app/agent-gamma-5/create-upload.md), then pass the returned `uploadId` and `filename` in `files` on [`POST /agent/generations`](https://developers.gamma.app/agent-gamma-5/create-agent-generation.md).
* The prompt decides what happens to the deck. Each generation creates one gamma.
* One presentation is imported per generation. A generation takes up to 50 files and 250 MiB in total.
* For a deck at a link, such as a Google Slides deck, put the link in `sourceUrls` instead of uploading it.
* Each upload can be attached to one generation; to retry, upload the file again. An upload that is never attached expires after two days.

## Upload and generate

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

```bash
UPLOAD=$(curl -s -X POST "https://public-api.gamma.app/v1.0/uploads?mimeType=application/vnd.openxmlformats-officedocument.presentationml.presentation" \
  -H "X-API-KEY: $GAMMA_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  -H "x-harness-upload-name: Q3%20review.pptx" \
  --data-binary @"Q3 review.pptx")

curl -s -X POST https://public-api.gamma.app/v1.0/agent/generations \
  -H "X-API-KEY: $GAMMA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --argjson upload "$UPLOAD" \
    '{prompt: "Import this deck.", files: [{uploadId: $upload.uploadId, filename: $upload.filename}]}')"
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from urllib.parse import quote

import requests

API = "https://public-api.gamma.app/v1.0"
KEY = {"X-API-KEY": os.environ["GAMMA_API_KEY"]}
PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"

with open("Q3 review.pptx", "rb") as deck:
    upload = requests.post(
        f"{API}/uploads",
        params={"mimeType": PPTX},
        headers={
            **KEY,
            "Content-Type": "application/octet-stream",
            "x-harness-upload-name": quote("Q3 review.pptx"),
        },
        data=deck,
    )
upload.raise_for_status()
file = {k: upload.json()[k] for k in ("uploadId", "filename")}

generation = requests.post(
    f"{API}/agent/generations",
    headers=KEY,
    json={"prompt": "Import this deck.", "files": [file]},
)
generation.raise_for_status()
print(generation.json()["generationId"])
```

{% endtab %}
{% endtabs %}

Poll [`GET /agent/generations/{generationId}`](https://developers.gamma.app/agent-gamma-5/get-agent-generation-status.md) until `status` is `completed` or `failed`. See [Poll for results](https://developers.gamma.app/guides/async-patterns-and-polling.md).

To mark a file as the presentation to import, add `"purpose": "import"` to its `files` entry. The prompt still takes precedence, so say "import it as is" when you want a faithful copy. Only one file can have it, and it can't be combined with `templateId`, `themeId`, or `numCards`.

## Write the prompt

| You want                    | Example prompt                                                                   | What Gamma does                                                       |
| --------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| The deck as is              | "Import this deck." A bare title also works.                                     | Imports it faithfully                                                 |
| Specific changes            | "Import this deck and change the heading on slide 7 to 'The window is closing.'" | Imports it, then edits the import                                     |
| A better look               | "Import this deck and make it look better." or "…in our brand colors."           | Imports it, then restyles the import and keeps its content            |
| A template for new content  | "Use this deck as a template for a Q3 update on climate tech."                   | Imports it, then rewrites the import, title included                  |
| A new deck from its content | "Make a 5-slide summary of this deck for our board."                             | Builds one new gamma from the content; the deck itself isn't imported |

Your file is unchanged either way; changes are made on the imported gamma.

A request to import, edit, or template more than one presentation fails without creating a gamma. Several presentations used together as content for one new deck are fine.

## Import from a link

Put the link in `sourceUrls` and use the same prompts. Gamma must be able to open the link, so share it publicly or use a direct download link. A link the prompt depends on is required: when Gamma can't read it, the generation fails with an explanation and creates no gamma.

## From a coding agent

With `GAMMA_API_KEY` set in your shell, ask your agent (Claude Code, Codex, Cursor) to upload the file and call the agent generation API, and point it at this page.

## Files from untrusted senders

{% hint style="warning" %}
Attached files and linked pages can contain text written to steer the agent. When you pass files from people you don't trust, set `disableConnectors: true` so the agent can't use your workspace connectors while it works.
{% endhint %}

## Troubleshooting

* **`invalid_files` on the status response:** an upload expired, was already attached to another generation, or the files exceed the size limit. Upload them again and retry.
* **`404` on `POST /agent/generations`:** an upload in `files` doesn't exist or has expired.
* **`413`:** the file exceeds 250 MiB (on `POST /uploads`), or the files exceed 250 MiB in total (on `POST /agent/generations`).
* **`503` on `POST /uploads`:** too many uploads are in progress. Retry with exponential backoff.

## Related

* [POST /uploads](https://developers.gamma.app/agent-gamma-5/create-upload.md) for upload limits and status codes
* [POST /agent/generations](https://developers.gamma.app/agent-gamma-5/create-agent-generation.md) for every generation option
* [Poll for results](https://developers.gamma.app/guides/async-patterns-and-polling.md) for polling and rate limits


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.gamma.app/build-with-gamma/import-a-presentation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
