# social.colibri.beta.actor.grantSpaceAccess

> Published by [colibri.social](https://lexicon.garden/identity/did:plc:mprdjqjluoswa7awzggaggj3)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.actor.grantSpaceAccess)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.actor.grantSpaceAccess/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mprdjqjluoswa7awzggaggj3/social.colibri.beta.actor.grantSpaceAccess/examples)

## Definitions

### `social.colibri.beta.actor.grantSpaceAccess`

**Type**: `procedure`

Hands the AppView access to one of the requesting user's personal spaces. The client mints a delegation token on its own PDS for the space and passes it here, because a delegation token is single-use and short-lived and the AppView has no OAuth session of its own. The AppView exchanges the token for a space credential and syncs the space.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `space` | `string` (space-ref) | Yes | The space to grant access to. |
| `delegationToken` | `string` | Yes | A delegation token minted by the user's PDS for the space. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `expiresAt` | `string` (datetime) | Yes | When the resulting space credential expires. The client should call this again before then to keep access current. |

#### Errors

- **AuthRequired**: The request has no valid service auth.
- **InvalidRequest**: The arguments are inconsistent or malformed beyond schema validation.
- **InvalidDelegationToken**: The delegation token is malformed, expired, or already used.
- **SpaceNotFound**: No space matches the given space reference.
- **NotAuthorized**: The delegation token does not grant access to the given space.
- **UpstreamFailure**: The user's PDS failed while the AppView exchanged the delegation token or synced the space.

## Raw Schema

```json
{
  "id": "social.colibri.beta.actor.grantSpaceAccess",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "required": [
            "space",
            "delegationToken"
          ],
          "properties": {
            "space": {
              "type": "string",
              "format": "space-ref",
              "description": "The space to grant access to."
            },
            "delegationToken": {
              "type": "string",
              "description": "A delegation token minted by the user's PDS for the space."
            }
          }
        },
        "encoding": "application/json"
      },
      "errors": [
        {
          "name": "AuthRequired",
          "description": "The request has no valid service auth."
        },
        {
          "name": "InvalidRequest",
          "description": "The arguments are inconsistent or malformed beyond schema validation."
        },
        {
          "name": "InvalidDelegationToken",
          "description": "The delegation token is malformed, expired, or already used."
        },
        {
          "name": "SpaceNotFound",
          "description": "No space matches the given space reference."
        },
        {
          "name": "NotAuthorized",
          "description": "The delegation token does not grant access to the given space."
        },
        {
          "name": "UpstreamFailure",
          "description": "The user's PDS failed while the AppView exchanged the delegation token or synced the space."
        }
      ],
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "expiresAt"
          ],
          "properties": {
            "expiresAt": {
              "type": "string",
              "format": "datetime",
              "description": "When the resulting space credential expires. The client should call this again before then to keep access current."
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Hands the AppView access to one of the requesting user's personal spaces. The client mints a delegation token on its own PDS for the space and passes it here, because a delegation token is single-use and short-lived and the AppView has no OAuth session of its own. The AppView exchanges the token for a space credential and syncs the space."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
