# at.happyproto.admin.createInvites

> 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.createInvites)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.createInvites/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.admin.createInvites/examples)

## Definitions

### `at.happyproto.admin.createInvites#invite`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `email` | `string` | Yes |  |
| `expiresAt` | `string` (datetime) | Yes |  |
| `token` | `string` | Yes | The secret the invitee redeems. Shown once: HappyView and the provisioner keep only its hash. |

### `at.happyproto.admin.createInvites`

**Type**: `procedure`

Invite customers: mint one single-use customers-space invite per address, each expiring after expiresInDays, and record which address each went to, so a redeemed invite pairs the address with the account. Redeemed with actor.acceptInvite. Staff only.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `emails` | `array` | Yes |  |
| `expiresInDays` | `integer` | No |  |
| `idempotencyKey` | `string` | Yes | A UUID, new for each attempt; a retry reuses it. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `invites` | `array` | Yes |  |

#### Errors

- **AuthRequired**: This endpoint requires an authenticated caller.
- **Forbidden**: The caller is not HappyProto staff, or may not invite to the customers space: only its creator or a HappyView super user may.
- **InvalidRequest**: emails is not 1 to 50 distinct addresses, expiresInDays is not a whole number from 1 to 30, or idempotencyKey is not a UUID.
- **OperationInProgress**: A request with this idempotencyKey is still running.
- **Upstream**: The customers space is not configured, an invite could not be made, or the addresses could not be recorded. Nothing is returned then: an invite whose address is not recorded is never handed out, and simply expires.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "invite": {
      "properties": {
        "email": {
          "type": "string"
        },
        "expiresAt": {
          "format": "datetime",
          "type": "string"
        },
        "token": {
          "description": "The secret the invitee redeems. Shown once: HappyView and the provisioner keep only its hash.",
          "type": "string"
        }
      },
      "required": [
        "email",
        "token",
        "expiresAt"
      ],
      "type": "object"
    },
    "main": {
      "description": "Invite customers: mint one single-use customers-space invite per address, each expiring after expiresInDays, and record which address each went to, so a redeemed invite pairs the address with the account. Redeemed with actor.acceptInvite. Staff only.",
      "errors": [
        {
          "description": "This endpoint requires an authenticated caller.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller is not HappyProto staff, or may not invite to the customers space: only its creator or a HappyView super user may.",
          "name": "Forbidden"
        },
        {
          "description": "emails is not 1 to 50 distinct addresses, expiresInDays is not a whole number from 1 to 30, or idempotencyKey is not a UUID.",
          "name": "InvalidRequest"
        },
        {
          "description": "A request with this idempotencyKey is still running.",
          "name": "OperationInProgress"
        },
        {
          "description": "The customers space is not configured, an invite could not be made, or the addresses could not be recorded. Nothing is returned then: an invite whose address is not recorded is never handed out, and simply expires.",
          "name": "Upstream"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "emails": {
              "items": {
                "maxLength": 254,
                "type": "string"
              },
              "maxLength": 50,
              "minLength": 1,
              "type": "array"
            },
            "expiresInDays": {
              "default": 14,
              "maximum": 30,
              "minimum": 1,
              "type": "integer"
            },
            "idempotencyKey": {
              "description": "A UUID, new for each attempt; a retry reuses it.",
              "type": "string"
            }
          },
          "required": [
            "emails",
            "idempotencyKey"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "invites": {
              "items": {
                "ref": "#invite",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "invites"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "at.happyproto.admin.createInvites",
  "lexicon": 1
}
```
