> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# Subscribe active contracts

> Returns a stream of the snapshot of the active contracts and incomplete (un)assignments at a ledger offset. Once the stream of GetActiveContractsResponses completes, the client SHOULD begin streaming updates from the update service, starting at the GetActiveContractsRequest.active_at_offset specified in this request. Clients SHOULD NOT assume that the set of active contracts they receive reflects the state at the ledger end. If the given offset is different than the ledger end, and there are (un)assignments in-flight at the given offset, the snapshot may fail with "FAILED_PRECONDITION/PARTICIPANT_PRUNED_DATA_ACCESSED". Note that it is ok to request acs snapshots for party migration with offsets other than ledger end, because party migration is not concerned with incomplete (un)assignments.

[JSON API AsyncAPI](https://docs.canton.network/reference/json-api-asyncapi-reference/index.md)

›

[/v2/state/active-contracts](https://docs.canton.network/reference/json-api-asyncapi-reference/channels/v2-state-active-contracts.md)

›

subscribe

/v2/state/active-contracts

# Subscribe active contracts

WebSocket

[Updated 3.7](#history-updated-3-7)

SUBSCRIBE

`/v2/state/active-contracts`

Returns a stream of the snapshot of the active contracts and incomplete (un)assignments at a ledger offset.
Once the stream of GetActiveContractsResponses completes,
the client SHOULD begin streaming updates from the update service,
starting at the GetActiveContractsRequest.active\_at\_offset specified in this request.
Clients SHOULD NOT assume that the set of active contracts they receive reflects the state at the ledger end.
If the given offset is different than the ledger end, and there are (un)assignments in-flight at the given offset,
the snapshot may fail with "FAILED\_PRECONDITION/PARTICIPANT\_PRUNED\_DATA\_ACCESSED".
Note that it is ok to request acs snapshots for party migration with offsets other than ledger end, because party
migration is not concerned with incomplete (un)assignments.

## Protocol Details

Protocol
WebSocket

Channel
/v2/state/active-contracts

Action
subscribe

Operation ID
onV2StateActive-contracts

Content type
application/json

Payload
oneOf

## Inputs

## Outputs

### Either\_JsCantonError\_JsGetActiveContractsResponse

Direction
Server -> Client

Message
Either\_JsCantonError\_JsGetActiveContractsResponse

Variants

#### JsCantonError

object

`code`
string

required

`cause`
string

required

`context`
object

required

`errorCategory`
string

required

#### JsGetActiveContractsResponse

object

`workflowId`
string

`contractEntry`
object

`streamContinuationToken`
string

Variants

#### contractEntry

oneOf

`JsActiveContract`
object

Variants

#### JsActiveContract

object

`JsActiveContract`
object

required

#### JsEmpty

object

`JsEmpty`
object

required

#### JsIncompleteAssigned

object

`JsIncompleteAssigned`
object

required

#### JsIncompleteUnassigned

object

`JsIncompleteUnassigned`
object

required

## Related Schemas

> [accordion] Either\_JsCantonError\_JsGetActiveContractsResponse
>
> Variants
>
> #### JsCantonError
>
> object
>
> `code`
> string
>
> required
>
> `cause`
> string
>
> required
>
> `context`
> object
>
> required
>
> `errorCategory`
> string
>
> required
>
> #### JsGetActiveContractsResponse
>
> object
>
> `workflowId`
> string
>
> `contractEntry`
> object
>
> `streamContinuationToken`
> string
>
> Variants
>
> #### contractEntry
>
> oneOf
>
> `JsActiveContract`
> object
>
> Variants
>
> #### JsActiveContract
>
> object
>
> `JsActiveContract`
> object
>
> required
>
> #### JsEmpty
>
> object
>
> `JsEmpty`
> object
>
> required
>
> #### JsIncompleteAssigned
>
> object
>
> `JsIncompleteAssigned`
> object
>
> required
>
> #### JsIncompleteUnassigned
>
> object
>
> `JsIncompleteUnassigned`
> object
>
> required

## History

Updated
`3.7`

channel description updated

Updated
`3.5`

channel description updated; subscribe description updated

wscat

```bash wscat theme={"theme":{"light":"github-light","dark":"github-dark"}}
npx wscat -c <WEBSOCKET_URL>
```

message

application/json

```json message theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "code": "<string>",
  "cause": "<string>",
  "context": {},
  "errorCategory": "<integer>"
}
```
