# app.tempomusic.staff.createInviteCode

> Published by [lexicons.tempomusic.fan](https://lexicon.garden/identity/did:plc:pxsuqmultto34oks44m2lgxm)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:pxsuqmultto34oks44m2lgxm/app.tempomusic.staff.createInviteCode)
- [Documentation](https://lexicon.garden/lexicon/did:plc:pxsuqmultto34oks44m2lgxm/app.tempomusic.staff.createInviteCode/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:pxsuqmultto34oks44m2lgxm/app.tempomusic.staff.createInviteCode/examples)

## Definitions

### `app.tempomusic.staff.createInviteCode`

**Type**: `procedure`

Generate a batch of single-use PDS invite codes (TEM-502). Requires the caller to have the `superAdmin` role. Each call requests `quantity` codes from the PDS (`com.atproto.server.createInviteCode` with `useCount=1`), writes one `inviteCodeCreated` audit row per successfully-created code (payload = SHA-256 hash of the suffix + `use_count`, never the plain code), and returns the suffix-only codes. When the PDS returns a transient failure mid-batch the handler stops iterating and returns the successfully-generated codes together with the requested count (partial-batch surfacing — the client decides whether to retry the missing count).

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `quantity` | `integer` | Yes | Number of invite codes to generate in this batch. Hard-capped at 25 to keep the audit-log write batch bounded and the partial-failure surface predictable. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `codes` | `array` | Yes | The successfully-generated invite codes as suffix-only strings (the env prefix stored under `APPVIEW_PDS_INVITE_CODE_PREFIX` has been stripped). |
| `created` | `integer` | Yes | Number of codes actually generated (equal to `codes.length`). Present redundantly to make the partial-batch semantic obvious to clients that only inspect scalars. |
| `requested` | `integer` | Yes | The `quantity` originally requested. `created < requested` signals a partial batch — the client may retry with `quantity = requested - created`. |

#### Errors

- **Forbidden**: The caller is not a super-admin.
- **InvalidRequest**: `quantity` outside the 1..25 range.
- **PdsUnavailable**: The PDS returned a transient failure on the FIRST call and zero codes were generated. Partial failures on subsequent calls surface via `created < requested` on a 200 OK response, NOT this error.

## Raw Schema

```json
{
  "id": "app.tempomusic.staff.createInviteCode",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "required": [
            "quantity"
          ],
          "properties": {
            "quantity": {
              "type": "integer",
              "maximum": 25,
              "minimum": 1,
              "description": "Number of invite codes to generate in this batch. Hard-capped at 25 to keep the audit-log write batch bounded and the partial-failure surface predictable."
            }
          }
        },
        "encoding": "application/json"
      },
      "errors": [
        {
          "name": "Forbidden",
          "description": "The caller is not a super-admin."
        },
        {
          "name": "InvalidRequest",
          "description": "`quantity` outside the 1..25 range."
        },
        {
          "name": "PdsUnavailable",
          "description": "The PDS returned a transient failure on the FIRST call and zero codes were generated. Partial failures on subsequent calls surface via `created < requested` on a 200 OK response, NOT this error."
        }
      ],
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "codes",
            "created",
            "requested"
          ],
          "properties": {
            "codes": {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 128
              },
              "description": "The successfully-generated invite codes as suffix-only strings (the env prefix stored under `APPVIEW_PDS_INVITE_CODE_PREFIX` has been stripped)."
            },
            "created": {
              "type": "integer",
              "minimum": 0,
              "description": "Number of codes actually generated (equal to `codes.length`). Present redundantly to make the partial-batch semantic obvious to clients that only inspect scalars."
            },
            "requested": {
              "type": "integer",
              "minimum": 1,
              "description": "The `quantity` originally requested. `created < requested` signals a partial batch — the client may retry with `quantity = requested - created`."
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Generate a batch of single-use PDS invite codes (TEM-502). Requires the caller to have the `superAdmin` role. Each call requests `quantity` codes from the PDS (`com.atproto.server.createInviteCode` with `useCount=1`), writes one `inviteCodeCreated` audit row per successfully-created code (payload = SHA-256 hash of the suffix + `use_count`, never the plain code), and returns the suffix-only codes. When the PDS returns a transient failure mid-batch the handler stops iterating and returns the successfully-generated codes together with the requested count (partial-batch surfacing — the client decides whether to retry the missing count)."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
