# at.happyproto.admin.createSpaces

> Published by [happyproto.at](https://lexicon.garden/identity/did:plc:mo7vq4jbioxwafy5zkcc3eux)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.createSpaces)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.createSpaces/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.createSpaces/examples)

## Definitions

### `at.happyproto.admin.createSpaces`

**Type**: `procedure`

Create HappyProto's admin and customers spaces under HAPPYPROTO_DID, member-only, keeping either that already exists, and add each of staff to the admin space with write access, skipping existing members. Idempotent: a second call creates nothing and adds no one. Only HappyProto's own account may call it.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `staff` | `array` | No | DIDs to add to the admin space with write access. A DID listed twice is added once. A DID that is already a member is left at its current access (a read-only member is not upgraded) and is not listed in staffAdded. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `adminSpace` | `ref` → `#space` | Yes |  |
| `customersSpace` | `ref` → `#space` | Yes |  |
| `staffAdded` | `array` | Yes | The DIDs this call added to the admin space; members already present are left out. |

#### Errors

- **Forbidden**: The caller is not HAPPYPROTO_DID, is signed out, or HAPPYPROTO_DID is unset or not a DID.
- **InvalidRequest**: staff is not a list of at most 50 DIDs.
- **Upstream**: A space could not be read, created or changed, or the instance anchors new spaces under its own DID rather than HAPPYPROTO_DID. A failure part-way through staff names, in its message, the DIDs already added. Retrying is safe.

### `at.happyproto.admin.createSpaces#space`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `created` | `boolean` | Yes | Whether this call created the space; false when it already existed. |
| `uri` | `string` (uri) | Yes | The space's at:// uri, at://<HAPPYPROTO_DID>/space/<type>/main. Not format at-uri: that format allows a collection NSID and a record key at most, and a space uri has four path segments and `space` where the NSID would be, so @atproto/lexicon refuses it. |

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Create HappyProto's admin and customers spaces under HAPPYPROTO_DID, member-only, keeping either that already exists, and add each of staff to the admin space with write access, skipping existing members. Idempotent: a second call creates nothing and adds no one. Only HappyProto's own account may call it.",
      "errors": [
        {
          "description": "The caller is not HAPPYPROTO_DID, is signed out, or HAPPYPROTO_DID is unset or not a DID.",
          "name": "Forbidden"
        },
        {
          "description": "staff is not a list of at most 50 DIDs.",
          "name": "InvalidRequest"
        },
        {
          "description": "A space could not be read, created or changed, or the instance anchors new spaces under its own DID rather than HAPPYPROTO_DID. A failure part-way through staff names, in its message, the DIDs already added. Retrying is safe.",
          "name": "Upstream"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "staff": {
              "description": "DIDs to add to the admin space with write access. A DID listed twice is added once. A DID that is already a member is left at its current access (a read-only member is not upgraded) and is not listed in staffAdded.",
              "items": {
                "format": "did",
                "type": "string"
              },
              "maxLength": 50,
              "type": "array"
            }
          },
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "adminSpace": {
              "ref": "#space",
              "type": "ref"
            },
            "customersSpace": {
              "ref": "#space",
              "type": "ref"
            },
            "staffAdded": {
              "description": "The DIDs this call added to the admin space; members already present are left out.",
              "items": {
                "format": "did",
                "type": "string"
              },
              "type": "array"
            }
          },
          "required": [
            "adminSpace",
            "customersSpace",
            "staffAdded"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "space": {
      "properties": {
        "created": {
          "description": "Whether this call created the space; false when it already existed.",
          "type": "boolean"
        },
        "uri": {
          "description": "The space's at:// uri, at://<HAPPYPROTO_DID>/space/<type>/main. Not format at-uri: that format allows a collection NSID and a record key at most, and a space uri has four path segments and `space` where the NSID would be, so @atproto/lexicon refuses it.",
          "format": "uri",
          "type": "string"
        }
      },
      "required": [
        "uri",
        "created"
      ],
      "type": "object"
    }
  },
  "id": "at.happyproto.admin.createSpaces",
  "lexicon": 1
}
```
