# Create A New Stream

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

Submit a new job to create a stream for a video

## 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.

* * *

**POST** `/videos/[id]/streams`

Submit a new job to create a stream for a video. This endpoint will return the information of the created job.

Required API Key Role

`admin`

The status of the job can be tracked at `/videos/<video_id>/jobs/<job_id>/status`

**New Stream Request Parameters**

-   `streamFormat`: “MVHEVC”, “HEVC”, “H264”
-   `transforms`: _(optional)_ array of transforms to apply. Omit it or use `[]` for no transforms. See `reproject` below.
-   `useDrm`: _(optional)_ boolean. When `true`, the stream will be encrypted with Apple FairPlay.
-   `preview`: _(optional)_ boolean. When `true`, omit bitrateLadder for a quick preview stream. (Must be MV-HEVC, 4320x4320 or less, and under 200 _Mbps_)
-   `bitrateLadder`: List of bitrates and heights for the stream. Bitrates are measured in _Mbps_.

### Example Request to Create a New Stream

getVideoInfo.js

```js
const newStreamData = {
    streamFormat: 'MVHEVC',
    bitrateLadder: [
        {
            bitrate: 5,
            height: 1080
        },
        {
            bitrate: 10,
            height: 2160
        },
        {
            bitrate: 15,
            height: 2160
        }
    ]
}

fetch('https://spatialgen.com/api/videos/<yourvideoid>/streams', {
    method: 'POST',
    headers: {
        'X-SPATIALGEN-APPKEY': apiKey,
    },
        body: JSON.stringify(newStreamData)
    }
)
```

### Transform: Reproject to VR180

Use `{ "type": "reproject", "target": "VR180" }` to convert an Apple Immersive Video to a 180-degree equirectangular stream.

Set `streamFormat` to `"MVHEVC"` for layered stereo or `"HEVC"` for side-by-side stereo. The maximum supported resolution is 4096x4096 per eye.

```json
{
  "streamFormat": "HEVC",
  "transforms": [{ "type": "reproject", "target": "VR180" }],
  "bitrateLadder": [
    { "height": 4096, "bitrate": 60 },
    { "height": 4096, "bitrate": 80 },
    { "height": 4096, "bitrate": 100 }
  ]
}
```

### Example Response

response.json

```json
{
    "createdAt": string,
    "id": number,
    "status": string,
    "progress": [],
}
```
