# createDocumentService

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/media/functions/createdocumentservice/

```ts
function createDocumentService(
   track, 
   document?, 
   options?
): DocumentService;
```

Defined in: [relay-sdks/ts/src/document-service.ts:199](https://github.com/caprids/relay-sdks/blob/main/ts/src/document-service.ts#L199)

Serve a state-shaped track whose document the application replaces, such as the msf-01 media timeline: the latest
document goes out as a new group on every relay subscription, as [createCatalogService](https://www.caprid.com/docs/reference/typescript/caprid/relay/media/functions/createcatalogservice/) does, and again on
every `update()` while the relay is subscribed. Nothing is sent before the first document, and an update without
relay demand only replaces it.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `track` | [`RelayTrackWriter`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaytrackwriter/) |
| `document?` | `ArrayBufferView`\<`ArrayBufferLike`\> |
| `options?` | [`CatalogServiceOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/media/interfaces/catalogserviceoptions/) |

## Returns

[`DocumentService`](https://www.caprid.com/docs/reference/typescript/caprid/relay/media/interfaces/documentservice/)
