# lol.dids.manage.grantSpaceAccess

> Published by [ngerakines.me](https://lexicon.garden/identity/did:plc:cbkjy5n7bk3ax2wplmtjofq2)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:cbkjy5n7bk3ax2wplmtjofq2/lol.dids.manage.grantSpaceAccess)
- [Documentation](https://lexicon.garden/lexicon/did:plc:cbkjy5n7bk3ax2wplmtjofq2/lol.dids.manage.grantSpaceAccess/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:cbkjy5n7bk3ax2wplmtjofq2/lol.dids.manage.grantSpaceAccess/examples)

## Definitions

### `lol.dids.manage.grantSpaceAccess`

**Type**: `procedure`

Hand bard a delegation token so it can keep reading a space. Any member may grant; the calling identity must be the token's issuer. Bard exchanges it under its own key, stores the credential, renews the notification registration when due, drains a queued receipt, and runs a head check if the space had lapsed.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `space` | `string` (at-uri) | Yes |  |
| `delegationToken` | `string` | Yes | A delegation token minted by the calling identity for this space; spent immediately and never stored. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `drained` | `integer` | Yes | Queued notification receipts turned into sync jobs by this grant. |
| `accessExpiresAt` | `string` (datetime) | Yes | When the credential bard now holds expires. |
| `registrationExpiresAt` | `string` (datetime) | No | When bard's notification registration at the space host expires. |

#### Errors

- **SpaceNotFound**: Bard is not connected to that space; call connectSpace first.
- **GrantIssuerMismatch**: The delegation token's issuer is not the calling identity.
- **GrantExpired**: The delegation token is past its lifetime.
- **GrantRefused**: The space host refused the exchange.
- **AppNotAllowed**: The space's app access does not admit bard.
- **SpacesDisabled**: Space support is disabled on this deployment.

## Raw Schema

```json
{
  "id": "lol.dids.manage.grantSpaceAccess",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "required": [
            "space",
            "delegationToken"
          ],
          "properties": {
            "space": {
              "type": "string",
              "format": "at-uri"
            },
            "delegationToken": {
              "type": "string",
              "description": "A delegation token minted by the calling identity for this space; spent immediately and never stored."
            }
          }
        },
        "encoding": "application/json"
      },
      "errors": [
        {
          "name": "SpaceNotFound",
          "description": "Bard is not connected to that space; call connectSpace first."
        },
        {
          "name": "GrantIssuerMismatch",
          "description": "The delegation token's issuer is not the calling identity."
        },
        {
          "name": "GrantExpired",
          "description": "The delegation token is past its lifetime."
        },
        {
          "name": "GrantRefused",
          "description": "The space host refused the exchange."
        },
        {
          "name": "AppNotAllowed",
          "description": "The space's app access does not admit bard."
        },
        {
          "name": "SpacesDisabled",
          "description": "Space support is disabled on this deployment."
        }
      ],
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "accessExpiresAt",
            "drained"
          ],
          "properties": {
            "drained": {
              "type": "integer",
              "description": "Queued notification receipts turned into sync jobs by this grant."
            },
            "accessExpiresAt": {
              "type": "string",
              "format": "datetime",
              "description": "When the credential bard now holds expires."
            },
            "registrationExpiresAt": {
              "type": "string",
              "format": "datetime",
              "description": "When bard's notification registration at the space host expires."
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Hand bard a delegation token so it can keep reading a space. Any member may grant; the calling identity must be the token's issuer. Bard exchanges it under its own key, stores the credential, renews the notification registration when due, drains a queued receipt, and runs a head check if the space had lapsed."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
