# zone.stratos.sync.subscribeRecords

> Published by [lexicon.northsky.app](https://lexicon.garden/identity/did:plc:6uxgo3ypovauub7nblwylqyv)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:6uxgo3ypovauub7nblwylqyv/zone.stratos.sync.subscribeRecords)
- [Documentation](https://lexicon.garden/lexicon/did:plc:6uxgo3ypovauub7nblwylqyv/zone.stratos.sync.subscribeRecords/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:6uxgo3ypovauub7nblwylqyv/zone.stratos.sync.subscribeRecords/examples)

## Definitions

### `zone.stratos.sync.subscribeRecords#info`

**Type**: `object`

An informational message about the subscription state.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `name` | `string` | Yes | The type of info message. |
| `message` | `string` | No | Additional details about the info message. |

### `zone.stratos.sync.subscribeRecords`

**Type**: `subscription`

Subscribe to stratos events. When 'did' is provided, subscribes to record updates for that account. When omitted, subscribes to service-level events (enrollments). AppViews must provide a signed service JWT via syncToken.

```json
{
  "type": "subscription",
  "errors": [
    {
      "name": "FutureCursor",
      "description": "Cursor is in the future."
    },
    {
      "name": "AuthRequired",
      "description": "Authentication is required."
    }
  ],
  "message": {
    "schema": {
      "refs": [
        "#commit",
        "#enrollment",
        "#info"
      ],
      "type": "union"
    }
  },
  "parameters": {
    "type": "params",
    "properties": {
      "did": {
        "type": "string",
        "format": "did",
        "description": "The DID of the account to subscribe to. If omitted, subscribes to service-level enrollment events."
      },
      "cursor": {
        "type": "integer",
        "description": "The last known event sequence number to resume from."
      },
      "domain": {
        "type": "string",
        "maxLength": 253,
        "description": "Optional domain filter. Only events for records with this domain in their boundary will be emitted."
      },
      "syncToken": {
        "type": "string",
        "description": "Signed service JWT for AppView authentication. Must include iss, aud, exp, and lxm claims. Required for service callers; owner callers may use the Authorization header instead."
      }
    }
  },
  "description": "Subscribe to stratos events. When 'did' is provided, subscribes to record updates for that account. When omitted, subscribes to service-level events (enrollments). AppViews must provide a signed service JWT via syncToken."
}
```

### `zone.stratos.sync.subscribeRecords#commit`

**Type**: `object`

A commit event containing record operations.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `did` | `string` (did) | Yes | The DID of the account. |
| `ops` | `array` | Yes | List of record operations in this commit. |
| `rev` | `string` (tid) | Yes | The repo revision. |
| `seq` | `integer` | Yes | The sequence number of this event. |
| `time` | `string` (datetime) | Yes | Timestamp of when the event was sequenced. |

### `zone.stratos.sync.subscribeRecords#recordOp`

**Type**: `object`

A single record operation within a commit.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `cid` | `cid-link` | No | The CID of the record. Present for create and update operations. |
| `path` | `string` | Yes | The record path (collection/rkey). |
| `action` | `string` | Yes | The type of operation. |
| `record` | `unknown` | No | The record content. Present for create and update operations. |

### `zone.stratos.sync.subscribeRecords#enrollment`

**Type**: `object`

An enrollment event indicating a user has enrolled or unenrolled from the service.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `did` | `string` (did) | Yes | The DID of the user. |
| `time` | `string` (datetime) | Yes | Timestamp of the enrollment event. |
| `action` | `string` | Yes | The enrollment action. |
| `service` | `string` (uri) | No | The Stratos service endpoint URL. |
| `boundaries` | `array` | No | The boundaries assigned to the user. |

## Raw Schema

```json
{
  "id": "zone.stratos.sync.subscribeRecords",
  "defs": {
    "info": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 128,
          "description": "The type of info message.",
          "knownValues": [
            "OutdatedCursor"
          ]
        },
        "message": {
          "type": "string",
          "maxLength": 1024,
          "description": "Additional details about the info message."
        }
      },
      "description": "An informational message about the subscription state."
    },
    "main": {
      "type": "subscription",
      "errors": [
        {
          "name": "FutureCursor",
          "description": "Cursor is in the future."
        },
        {
          "name": "AuthRequired",
          "description": "Authentication is required."
        }
      ],
      "message": {
        "schema": {
          "refs": [
            "#commit",
            "#enrollment",
            "#info"
          ],
          "type": "union"
        }
      },
      "parameters": {
        "type": "params",
        "properties": {
          "did": {
            "type": "string",
            "format": "did",
            "description": "The DID of the account to subscribe to. If omitted, subscribes to service-level enrollment events."
          },
          "cursor": {
            "type": "integer",
            "description": "The last known event sequence number to resume from."
          },
          "domain": {
            "type": "string",
            "maxLength": 253,
            "description": "Optional domain filter. Only events for records with this domain in their boundary will be emitted."
          },
          "syncToken": {
            "type": "string",
            "description": "Signed service JWT for AppView authentication. Must include iss, aud, exp, and lxm claims. Required for service callers; owner callers may use the Authorization header instead."
          }
        }
      },
      "description": "Subscribe to stratos events. When 'did' is provided, subscribes to record updates for that account. When omitted, subscribes to service-level events (enrollments). AppViews must provide a signed service JWT via syncToken."
    },
    "commit": {
      "type": "object",
      "required": [
        "seq",
        "did",
        "time",
        "rev",
        "ops"
      ],
      "properties": {
        "did": {
          "type": "string",
          "format": "did",
          "description": "The DID of the account."
        },
        "ops": {
          "type": "array",
          "items": {
            "ref": "#recordOp",
            "type": "ref"
          },
          "description": "List of record operations in this commit."
        },
        "rev": {
          "type": "string",
          "format": "tid",
          "description": "The repo revision."
        },
        "seq": {
          "type": "integer",
          "description": "The sequence number of this event."
        },
        "time": {
          "type": "string",
          "format": "datetime",
          "description": "Timestamp of when the event was sequenced."
        }
      },
      "description": "A commit event containing record operations."
    },
    "recordOp": {
      "type": "object",
      "required": [
        "action",
        "path"
      ],
      "properties": {
        "cid": {
          "type": "cid-link",
          "description": "The CID of the record. Present for create and update operations."
        },
        "path": {
          "type": "string",
          "maxLength": 512,
          "description": "The record path (collection/rkey)."
        },
        "action": {
          "type": "string",
          "maxLength": 32,
          "description": "The type of operation.",
          "knownValues": [
            "create",
            "update",
            "delete"
          ]
        },
        "record": {
          "type": "unknown",
          "description": "The record content. Present for create and update operations."
        }
      },
      "description": "A single record operation within a commit."
    },
    "enrollment": {
      "type": "object",
      "required": [
        "did",
        "action",
        "time"
      ],
      "properties": {
        "did": {
          "type": "string",
          "format": "did",
          "description": "The DID of the user."
        },
        "time": {
          "type": "string",
          "format": "datetime",
          "description": "Timestamp of the enrollment event."
        },
        "action": {
          "type": "string",
          "maxLength": 32,
          "description": "The enrollment action.",
          "knownValues": [
            "enroll",
            "unenroll"
          ]
        },
        "service": {
          "type": "string",
          "format": "uri",
          "description": "The Stratos service endpoint URL."
        },
        "boundaries": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The boundaries assigned to the user."
        }
      },
      "description": "An enrollment event indicating a user has enrolled or unenrolled from the service."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
