> Docs index: https://movekit.com/llms.txt. HTML version: https://movekit.com/docs/api/download-a-delivered-file

# Download a delivered file

Downloads the file named by a valid download link, with single byte ranges so downloads resume.

- Method and path: `GET /media/{grantId}`
- URL: `{DELIVERY_WORKER_URL}/media/{grantId}`
- Requires: Owned or sample content
- Authentication: No API key. The URL from the API response is the authorization; never send the key to it.
- Operation id: `getMedia`

Each link allows 16 requests.

## Path parameters

| Name | Type | Required | Default | Allowed | Example | Description |
| --- | --- | --- | --- | --- | --- | --- |
| `grantId` | string | yes |  | pattern ^grant_ | `grant_69e604c7-2f38-485c-89b3-24d61ab2af0e` | The download link id in the delivery URL. |

## Query parameters

| Name | Type | Required | Default | Allowed | Example | Description |
| --- | --- | --- | --- | --- | --- | --- |
| `t` | string | yes |  |  | `eyJnIjoiZ3JhbnRfNjllNjA0YzcifQ.Lqvtn5kUEJG22znYCC-jXAWyPJMsAP1Po2eNG279Yp` | The signed token from the delivery URL. Treat the whole URL as opaque. |

## Header parameters

| Name | Type | Required | Default | Allowed | Example | Description |
| --- | --- | --- | --- | --- | --- | --- |
| `Range` | string | no |  |  | `bytes=0-1048575` | One range: bytes=a-b, bytes=a- or bytes=-n. Multiple ranges are refused with 416. |
| `If-Range` | string | no |  |  | `"d74cedbbfbc4d6d93afd73cbbf4ca7e6d4ef1d876d12be14913c617974ba8109"` | ETag or HTTP date. A mismatch returns the full object instead of a range. |

## Response 200

The full file named by the download link. Cache-Control: private, no-store; Content-Disposition: attachment. Binary body; the headers carry the examples.

## Errors

| Status | Codes | Meaning |
| --- | --- | --- |
| 400 | `delivery_invalid` | The token failed verification, or the request was malformed. |
| 401 | `invalid_api_key` | The key that issued the download link was revoked. |
| 404 | `asset_not_available`, `not_found` | Unknown route, or the asset is not available. |
| 405 | `method_not_allowed` | Only GET, HEAD and OPTIONS. |
| 409 | `asset_mismatch` | The stored object does not match the download link; request a fresh download link. |
| 410 | `delivery_expired` | Download links work for 300 seconds. Request a fresh download link afterwards. |
| 416 | `range_not_satisfiable` | Content-Range carries bytes */size. |
| 429 | `sync_limit_exceeded`, `delivery_limit_exceeded`, `daily_request_limit`, `sample_busy` | A download link allows 16 requests. Each file version can be downloaded 20 times a month, then gets sync_limit_exceeded until the count starts again at 00:00 UTC on the 1st of each month; new versions start again. An account that reached its media requests for the day gets daily_request_limit until 00:00 UTC; a keyless sample link gets sample_busy when the sample is used up for the day. |
| 503 | `delivery_disabled`, `delivery_paused_global`, `delivery_unavailable` | Media delivery is disabled, paused or not configured. Retryable; nothing is charged. |

## Example request

cURL:

```bash
# DOWNLOAD_URL is a download link from Create deliveries. No API key: the URL is the authorization.
curl --fail -sS --max-redirs 0 \
  -o movekit-video.mp4 \
  "$DOWNLOAD_URL"
```

JavaScript:

```javascript
// Node 20 or newer: save as request.mjs and run node request.mjs
import { writeFile } from "node:fs/promises"

// DOWNLOAD_URL is a download link from Create deliveries. No API key: the URL is the authorization.
const response = await fetch(process.env.DOWNLOAD_URL, {
  redirect: "error",
})
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`)
await writeFile("movekit-video.mp4", Buffer.from(await response.arrayBuffer()))
```

Python:

```python
import os
import urllib.request

# DOWNLOAD_URL is a download link from Create deliveries. No API key: the URL is the authorization.
request = urllib.request.Request(os.environ["DOWNLOAD_URL"], method="GET", headers={"User-Agent": "movekit-docs-example/1"})
with urllib.request.urlopen(request) as response:
    with open("movekit-video.mp4", "wb") as file:
        file.write(response.read())
```

## Example response 200

```http
HTTP/1.1 200
Accept-Ranges: bytes
ETag: "d74cedbbfbc4d6d93afd73cbbf4ca7e6d4ef1d876d12be14913c617974ba8109"
```

## Example response 206

```http
HTTP/1.1 206
Accept-Ranges: bytes
ETag: "d74cedbbfbc4d6d93afd73cbbf4ca7e6d4ef1d876d12be14913c617974ba8109"
Content-Range: bytes 0-1048575/1843302
```

## Example response 400

```json
{
  "error": {
    "code": "delivery_invalid",
    "message": "The delivery token is invalid.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Request a fresh delivery from the MoveKit API with an authorized key."
  }
}
```

## Example response 401

```json
{
  "error": {
    "code": "invalid_api_key",
    "message": "The issuing key was revoked.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Use a valid key to request a fresh delivery."
  }
}
```

## Example response 404

```json
{
  "error": {
    "code": "asset_not_available",
    "message": "The asset is not available for delivery.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Request a fresh delivery; if the problem persists contact MoveKit support."
  }
}
```

## Example response 405

```json
{
  "error": {
    "code": "method_not_allowed",
    "message": "This method is not supported for this route.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Use GET or HEAD for media."
  }
}
```

## Example response 409

```json
{
  "error": {
    "code": "asset_mismatch",
    "message": "The stored asset does not match the download link.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Request a fresh delivery; if the problem persists contact MoveKit support."
  }
}
```

## Example response 410

```json
{
  "error": {
    "code": "delivery_expired",
    "message": "The delivery token expired.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Request a fresh delivery from the MoveKit API."
  }
}
```

## Example response 416

```json
{
  "error": {
    "code": "range_not_satisfiable",
    "message": "The requested range cannot be served.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Send one byte range inside the object size, or none."
  }
}
```

## Example response 429

```json
{
  "error": {
    "code": "sync_limit_exceeded",
    "message": "This version of the file reached its download limit for this month.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": false,
    "nextAction": "Use the copy you already imported until 00:00 UTC on the 1st of next month, when the limit starts again, or ask MoveKit for a reviewed reset."
  }
}
```

## Example response 503

```json
{
  "error": {
    "code": "delivery_disabled",
    "message": "Media delivery is temporarily disabled.",
    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
    "retryable": true,
    "nextAction": "Retry later. No usage is charged for refused requests."
  }
}
```

## OpenAPI

The operation and every component it references, from the OpenAPI document.

```json
{
  "openapi": "3.1.2",
  "info": {
    "title": "MoveKit API",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://api.movekit.com/v1",
      "description": "Control plane (MOVEKIT_API_BASE_URL). Paths below are relative to this URL."
    }
  ],
  "paths": {
    "/media/{grantId}": {
      "get": {
        "operationId": "getMedia",
        "tags": [
          "Deliveries"
        ],
        "summary": "Download a delivered file",
        "description": "Downloads the file named by a valid download link, with single byte ranges so downloads resume. Each link allows 16 requests.",
        "x-movekit-requires": "owned-asset",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/GrantId"
          },
          {
            "$ref": "#/components/parameters/DeliveryToken"
          },
          {
            "$ref": "#/components/parameters/Range"
          },
          {
            "$ref": "#/components/parameters/IfRange"
          }
        ],
        "responses": {
          "200": {
            "description": "The full file named by the download link. Cache-Control: private, no-store; Content-Disposition: attachment. Binary body; the headers carry the examples.",
            "headers": {
              "Accept-Ranges": {
                "$ref": "#/components/headers/Accept-Ranges"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "video/mp4"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/jpeg"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/webp"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/png"
                }
              }
            }
          },
          "206": {
            "description": "The requested byte range.",
            "headers": {
              "Accept-Ranges": {
                "$ref": "#/components/headers/Accept-Ranges"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Content-Range": {
                "$ref": "#/components/headers/Content-Range"
              }
            },
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "video/mp4"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/jpeg"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/webp"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "image/png"
                }
              }
            }
          },
          "400": {
            "description": "The token failed verification, or the request was malformed.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "delivery_invalid",
                    "message": "The delivery token is invalid.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Request a fresh delivery from the MoveKit API with an authorized key."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "delivery_invalid"
            ]
          },
          "401": {
            "description": "The key that issued the download link was revoked.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "invalid_api_key",
                    "message": "The issuing key was revoked.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Use a valid key to request a fresh delivery."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "invalid_api_key"
            ]
          },
          "404": {
            "description": "Unknown route, or the asset is not available.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "asset_not_available",
                    "message": "The asset is not available for delivery.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Request a fresh delivery; if the problem persists contact MoveKit support."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "asset_not_available",
              "not_found"
            ]
          },
          "405": {
            "description": "Only GET, HEAD and OPTIONS.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "This method is not supported for this route.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Use GET or HEAD for media."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "method_not_allowed"
            ]
          },
          "409": {
            "description": "The stored object does not match the download link; request a fresh download link.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "asset_mismatch",
                    "message": "The stored asset does not match the download link.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Request a fresh delivery; if the problem persists contact MoveKit support."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "asset_mismatch"
            ]
          },
          "410": {
            "description": "Download links work for 300 seconds. Request a fresh download link afterwards.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "delivery_expired",
                    "message": "The delivery token expired.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Request a fresh delivery from the MoveKit API."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "delivery_expired"
            ]
          },
          "416": {
            "description": "Content-Range carries bytes */size.",
            "headers": {
              "Content-Range": {
                "$ref": "#/components/headers/Content-Range"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "range_not_satisfiable",
                    "message": "The requested range cannot be served.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Send one byte range inside the object size, or none."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "range_not_satisfiable"
            ]
          },
          "429": {
            "description": "A download link allows 16 requests. Each file version can be downloaded 20 times a month, then gets sync_limit_exceeded until the count starts again at 00:00 UTC on the 1st of each month; new versions start again. An account that reached its media requests for the day gets daily_request_limit until 00:00 UTC; a keyless sample link gets sample_busy when the sample is used up for the day.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "sync_limit_exceeded",
                    "message": "This version of the file reached its download limit for this month.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": false,
                    "nextAction": "Use the copy you already imported until 00:00 UTC on the 1st of next month, when the limit starts again, or ask MoveKit for a reviewed reset."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "sync_limit_exceeded",
              "delivery_limit_exceeded",
              "daily_request_limit",
              "sample_busy"
            ]
          },
          "503": {
            "description": "Media delivery is disabled, paused or not configured. Retryable; nothing is charged.",
            "headers": {},
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryError"
                },
                "example": {
                  "error": {
                    "code": "delivery_disabled",
                    "message": "Media delivery is temporarily disabled.",
                    "requestId": "6f1d2c3b-8a9e-4f70-b5c4-2d1e0f9a8b7c",
                    "retryable": true,
                    "nextAction": "Retry later. No usage is charged for refused requests."
                  }
                }
              }
            },
            "x-movekit-codes": [
              "delivery_disabled",
              "delivery_paused_global",
              "delivery_unavailable"
            ]
          }
        }
      },
      "x-plane": "delivery",
      "servers": [
        {
          "url": "{DELIVERY_WORKER_URL}",
          "description": "The delivery host. Use the full URL from createDeliveries.",
          "variables": {
            "DELIVERY_WORKER_URL": {
              "default": "https://delivery.example.invalid",
              "description": "Origin of the url returned by createDeliveries."
            }
          }
        }
      ]
    }
  },
  "components": {
    "headers": {
      "Accept-Ranges": {
        "description": "Always `bytes`.",
        "required": true,
        "schema": {
          "const": "bytes"
        },
        "example": "bytes"
      },
      "Content-Range": {
        "description": "`bytes start-end/size` on 206, `bytes */size` on 416.",
        "schema": {
          "type": "string"
        },
        "example": "bytes 0-1048575/1843302"
      },
      "ETag": {
        "description": "Strong validator for If-Range: the quoted sha256 of the file.",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "\"d74cedbbfbc4d6d93afd73cbbf4ca7e6d4ef1d876d12be14913c617974ba8109\""
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer"
        },
        "example": 30
      }
    },
    "parameters": {
      "DeliveryToken": {
        "name": "t",
        "in": "query",
        "required": true,
        "description": "The signed token from the delivery URL. Treat the whole URL as opaque.",
        "schema": {
          "type": "string"
        },
        "example": "eyJnIjoiZ3JhbnRfNjllNjA0YzcifQ.Lqvtn5kUEJG22znYCC-jXAWyPJMsAP1Po2eNG279Yp"
      },
      "GrantId": {
        "name": "grantId",
        "in": "path",
        "required": true,
        "description": "The download link id in the delivery URL.",
        "schema": {
          "type": "string",
          "pattern": "^grant_"
        },
        "example": "grant_69e604c7-2f38-485c-89b3-24d61ab2af0e"
      },
      "IfRange": {
        "name": "If-Range",
        "in": "header",
        "description": "ETag or HTTP date. A mismatch returns the full object instead of a range.",
        "schema": {
          "type": "string"
        },
        "example": "\"d74cedbbfbc4d6d93afd73cbbf4ca7e6d4ef1d876d12be14913c617974ba8109\""
      },
      "Range": {
        "name": "Range",
        "in": "header",
        "description": "One range: bytes=a-b, bytes=a- or bytes=-n. Multiple ranges are refused with 416.",
        "schema": {
          "type": "string"
        },
        "example": "bytes=0-1048575"
      }
    },
    "schemas": {
      "DeliveryError": {
        "type": "object",
        "description": "The same envelope, returned by the delivery host on a media URL.",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "$ref": "#/components/schemas/DeliveryErrorCode"
              },
              "message": {
                "type": "string",
                "description": "What went wrong."
              },
              "requestId": {
                "type": "string",
                "description": "Correlation id of the delivery host."
              },
              "retryable": {
                "type": "boolean",
                "description": "True when the same request may succeed later."
              },
              "nextAction": {
                "type": "string",
                "description": "What to do next."
              }
            },
            "required": [
              "code",
              "message",
              "requestId",
              "retryable",
              "nextAction"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "DeliveryErrorCode": {
        "type": "string",
        "enum": [
          "invalid_request",
          "delivery_invalid",
          "delivery_expired",
          "invalid_api_key",
          "not_found",
          "method_not_allowed",
          "asset_not_available",
          "asset_mismatch",
          "range_not_satisfiable",
          "delivery_limit_exceeded",
          "sync_limit_exceeded",
          "daily_request_limit",
          "sample_busy",
          "delivery_disabled",
          "delivery_paused_global",
          "delivery_unavailable"
        ],
        "description": "Error code of a delivery URL."
      }
    }
  }
}
```
