> ## Documentation Index
> Fetch the complete documentation index at: https://run-deliverys.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Download receipt

> Download a PDF receipt for a delivered order.

Download a PDF receipt. Only available for **delivered** orders (otherwise `400`).

Requires scope: `orders:read`

The body is the PDF bytes. In cURL, `-OJ` saves the file using the `Content-Disposition` filename.

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer API key (`Bearer <api_key>`).
</ParamField>

## Path parameters

<ParamField path="id" type="string" required>
  Order document id.
</ParamField>

## Response headers

<ResponseField name="Content-Type" type="string">
  Response header: `application/pdf`.
</ResponseField>

<ResponseField name="Content-Disposition" type="string">
  Response header: `attachment; filename="receipt-RUN-A1B2C3D4.pdf"`.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -OJ "$RUN_BASE_URL/business/orders/$ID/receipt" \
    -H "Authorization: Bearer $RUN_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(
    `${process.env.RUN_BASE_URL}/business/orders/${orderId}/receipt`,
    {
      headers: {
        Authorization: `Bearer ${process.env.RUN_API_KEY}`,
      },
    },
  );

  if (!res.ok) {
    console.error(await res.json());
    throw new Error(`Receipt failed: ${res.status}`);
  }

  const buffer = Buffer.from(await res.arrayBuffer());
  const disposition = res.headers.get('content-disposition') || '';
  const match = /filename="([^"]+)"/.exec(disposition);
  const filename = match?.[1] || `receipt-${orderId}.pdf`;
  require('fs').writeFileSync(filename, buffer);
  ```

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

  order_id = os.environ["ORDER_ID"]
  res = requests.get(
      f"{os.environ['RUN_BASE_URL']}/business/orders/{order_id}/receipt",
      headers={"Authorization": f"Bearer {os.environ['RUN_API_KEY']}"},
  )

  if res.status_code != 200:
      print(res.json())
      raise SystemExit(res.status_code)

  disposition = res.headers.get("Content-Disposition", "")
  match = re.search(r'filename="([^"]+)"', disposition)
  filename = match.group(1) if match else f"receipt-{order_id}.pdf"
  with open(filename, "wb") as f:
      f.write(res.content)
  ```

  ```php PHP theme={null}
  <?php
  $orderId = getenv('ORDER_ID');
  $ch = curl_init(getenv('RUN_BASE_URL') . "/business/orders/{$orderId}/receipt");
  curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
      'Authorization: Bearer ' . getenv('RUN_API_KEY'),
    ],
    CURLOPT_HEADER => true,
  ]);
  $raw = curl_exec($ch);
  $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  $headers = substr($raw, 0, $headerSize);
  $body = substr($raw, $headerSize);
  curl_close($ch);

  if ($status !== 200) {
    echo $body;
    exit($status);
  }

  preg_match('/filename="([^"]+)"/', $headers, $m);
  $filename = $m[1] ?? "receipt-{$orderId}.pdf";
  file_put_contents($filename, $body);
  ```

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

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

  func main() {
    orderID := os.Getenv("ORDER_ID")
    req, _ := http.NewRequest(
      "GET",
      os.Getenv("RUN_BASE_URL")+"/business/orders/"+orderID+"/receipt",
      nil,
    )
    req.Header.Set("Authorization", "Bearer "+os.Getenv("RUN_API_KEY"))
    res, err := http.DefaultClient.Do(req)
    if err != nil {
      panic(err)
    }
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    if res.StatusCode != 200 {
      os.Stdout.Write(body)
      os.Exit(1)
    }
    filename := "receipt-" + orderID + ".pdf"
    if m := regexp.MustCompile(`filename="([^"]+)"`).FindStringSubmatch(
      res.Header.Get("Content-Disposition"),
    ); len(m) == 2 {
      filename = m[1]
    }
    _ = os.WriteFile(filename, body, 0o644)
  }
  ```
</RequestExample>

<ResponseExample>
  ```text 200 theme={null}
  application/pdf (binary body)

  Content-Type: application/pdf
  Content-Disposition: attachment; filename="receipt-RUN-A1B2C3D4.pdf"
  ```

  ```json 400 theme={null}
  {
    "statusCode": 400,
    "timestamp": "2026-08-12T15:18:51.396Z",
    "path": "/api/v2/business/orders/6a7c75f801df3fbb7fad0c58/receipt",
    "message": "Receipt is only available for delivered trips"
  }
  ```

  ```json 401 theme={null}
  {
    "statusCode": 401,
    "timestamp": "2026-08-12T15:18:51.396Z",
    "path": "/api/v2/business/orders/6a7c75f801df3fbb7fad0c58/receipt",
    "message": "Invalid API key"
  }
  ```

  ```json 403 theme={null}
  {
    "statusCode": 403,
    "timestamp": "2026-08-12T15:18:51.396Z",
    "path": "/api/v2/business/orders/6a7c75f801df3fbb7fad0c58/receipt",
    "message": "Insufficient API key scope"
  }
  ```

  ```json 404 theme={null}
  {
    "statusCode": 404,
    "timestamp": "2026-08-12T15:18:51.396Z",
    "path": "/api/v2/business/orders/6a7c75f801df3fbb7fad0c58/receipt",
    "message": "Order not found"
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.