# Generate A Secure Download Link

> Part of the [SpatialGen API documentation](/index.md). [HTML version of this page](/api/05_secure_download/).

How to get started with the SpatialGen API

## API context

-   API requests use `https://spatialgen.com` with the `/api` path prefix, included once.
-   Authenticate requests to SpatialGen API endpoints with the `X-SPATIALGEN-APPKEY` HTTP header.
-   Use a key from the workspace that owns the requested resources. Follow the roles and scopes specified for each endpoint below.
-   Keep `admin` and `upload` keys on a trusted backend. `readonly` keys may be used in client apps for permitted read operations.
-   Presigned upload URLs have their own authorization. Do not send your SpatialGen API key to those URLs.

See the [API key guide](/guides/get-started.md) for roles, key creation, expiration, revocation, and rotation.

* * *

**GET** `/videos/[id]/download`

Generate a unique and secure download link for a video with the given id. Returns a signed SpatialGen link which can be used to download the file.

Allowed API Key Roles

`admin`, `readonly`

### Example request for a video

downloadlink.js

```js
fetch('https://spatialgen.com/api/videos/<yourvideoid>/download?size=True', {
    method: 'GET',
    headers: {
        'X-SPATIALGEN-APPKEY': apiKey,
    }
})
```

### Example Response

response.json

```json
{
    "sasUrl": string; // The signed url from the SpatialGen CDN
    "size": number; // The file size in bytes
}
```
