> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Export draw

> Export giveaway draw results in 7 formats including winners and participant data

<blockquote className="agent-llms-directive">
  For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
</blockquote>

<Callout icon="circle-check" color="#16a34a">
  **Free** - does not consume credits
</Callout>

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://xquik.com/api/v1/draws/f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345/export?format=csv&type=winners" \
    -H "x-api-key: xq_YOUR_KEY_HERE" \
    -o draw-winners-f4bd00a2.csv
  ```

  ```javascript Node.js theme={null}
  const drawId = "f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345";
  const response = await fetch(
    `https://xquik.com/api/v1/draws/${drawId}/export?format=csv&type=winners`,
    {
      headers: { "x-api-key": "xq_YOUR_KEY_HERE" },
    }
  );
  const blob = await response.blob();
  // Save to file or process as needed
  ```

  ```python Python theme={null}
  import requests

  draw_id = "f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345"
  response = requests.get(
      f"https://xquik.com/api/v1/draws/{draw_id}/export",
      headers={"x-api-key": "xq_YOUR_KEY_HERE"},
      params={"format": "csv", "type": "winners"},
  )
  with open(f"draw-winners-{draw_id}.csv", "wb") as f:
      f.write(response.content)
  ```

  ```go Go theme={null}
  package main

  import (
  	"io"
  	"log"
  	"net/http"
  	"os"
  )

  func main() {
    drawID := "f4bd00a2-7b4e-4e59-8e1b-72e2c9f12345"
  	req, err := http.NewRequest("GET", "https://xquik.com/api/v1/draws/"+drawID+"/export?format=csv&type=winners", nil)
  	if err != nil {
  		log.Fatal(err)
  	}
  	req.Header.Set("x-api-key", "xq_YOUR_KEY_HERE")

  	resp, err := http.DefaultClient.Do(req)
  	if err != nil {
  		log.Fatal(err)
  	}
  	defer resp.Body.Close()

  	file, err := os.Create("draw-winners-" + drawID + ".csv")
  	if err != nil {
  		log.Fatal(err)
  	}
  	defer file.Close()

  	if _, err := io.Copy(file, resp.Body); err != nil {
  		log.Fatal(err)
  	}
  }
  ```
</CodeGroup>

## Headers

<ParamField header="x-api-key" type="string" required>
  Your API key. Session cookie authentication is also supported.
</ParamField>

## Path parameters

<ParamField path="id" type="string" required>
  The draw public ID. Returned when you [create a draw](/api-reference/draws/create) or [list draws](/api-reference/draws/list).
</ParamField>

## Query parameters

<ParamField query="format" type="string" required>
  Export file format. Must be one of `csv`, `json`, `md`, `md-document`, `pdf`, `txt`, `xlsx`.
</ParamField>

<ParamField query="type" type="string">
  Data to export. `winners` exports the selected winners, `entries` exports all collected replies. Default `winners`.
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    Returns a file download. The response includes a `Content-Disposition`
    header with the filename.

    <CardGroup cols={2}>
      <Card title="CSV" icon="table">
        `format=csv` returns `text/csv; charset=utf-8` with filenames like
        `draw-winners-*.csv`.
      </Card>

      <Card title="JSON" icon="braces">
        `format=json` returns `application/json; charset=utf-8` with filenames
        like `draw-winners-*.json`.
      </Card>

      <Card title="Markdown" icon="file-text">
        `format=md` returns `text/markdown; charset=utf-8` with filenames like
        `draw-winners-*.md`.
      </Card>

      <Card title="Markdown document" icon="file-text">
        `format=md-document` returns `text/markdown; charset=utf-8` with
        filenames like `draw-winners-*.md`.
      </Card>

      <Card title="PDF" icon="file-down">
        `format=pdf` returns `application/pdf` with filenames like
        `draw-winners-*.pdf`.
      </Card>

      <Card title="TXT" icon="file">
        `format=txt` returns `text/plain; charset=utf-8` with filenames like
        `draw-winners-*.txt`.
      </Card>

      <Card title="XLSX" icon="file-spreadsheet">
        `format=xlsx` returns
        `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` with
        filenames like `draw-winners-*.xlsx`.
      </Card>
    </CardGroup>

    Entry exports use the same suffix pattern with `draw-entries-*` filenames.

    **Winner export columns:** Position, Username, Text, Backup

    **Entry export columns:** Username, Text, Passed Filter, Language

    Entry exports are capped at 100,000 rows (10,000 for PDF).
  </Tab>

  <Tab title="400 Invalid Params">
    ```json theme={null}
    { "error": "invalid_params" }
    ```

    Missing or invalid `format` value, or invalid `type` value. Format must be `csv`, `json`, `md`, `md-document`, `pdf`, `txt`, or `xlsx`. Type must be `winners` or `entries`.
  </Tab>

  <Tab title="401 Unauthenticated">
    ```json theme={null}
    { "error": "unauthenticated" }
    ```

    Missing or invalid API key / session cookie.
  </Tab>

  <Tab title="404 Not Found">
    ```json theme={null}
    { "error": "not_found" }
    ```

    No draw exists with this ID, or it belongs to a different account.
  </Tab>

  <Tab title="429 Rate Limited">
    ```json theme={null}
    { "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 1 }
    ```

    Too many requests. Wait for the `Retry-After` header before retrying.
  </Tab>
</Tabs>

<Note>
  **Next steps:** [Get Draw](/api-reference/draws/get) to retrieve draw details and winners as JSON · [List Draws](/api-reference/draws/list) to find draw IDs.
</Note>
