# at.happyproto.server.createInstance

> Create an instance for the caller, and start a job that follows its provisioning. Customers only.

- Kind: procedure
- Authority: server.happyproto.at
- Lexicon: 1
- Published by [happyproto.at](https://lexicon.garden/identity/did:plc:mo7vq4jbioxwafy5zkcc3eux), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.createInstance)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.createInstance/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.createInstance/analytics)

## Procedure (`at.happyproto.server.createInstance`)

Type: procedure · POST

### Input (application/json)

- `idempotencyKey` (string, required): A UUID the client generates once per intended change and resends on every retry of it, so a retry gets the original reply instead of acting twice.
- `plan` (string, required): The plan's id, from at.happyproto.server.listPlans.
- `slug` (string, required): The instance's subdomain: 3 to 32 of a-z, 0-9 and -, starting with a letter.
- `terms` (ref): An acceptance of the beta terms made with this create, as dashboards from before sign-in acceptance send. Optional: the caller's account accepts them once with actor.acceptTerms, and the provisioner refuses a create unless one or the other covers the terms in force (TermsRequired, TermsOutdated), staff included.
  - Reference: `#termsAcceptance`

### Output (application/json)

- `instance` (ref, required)
  - Reference: `#instance`
- `jobId` (string, required): The background job following the change. Poll it with at.happyproto.server.getJob.

### Errors

- `AuthRequired`: This endpoint requires an authenticated caller.
- `Forbidden`: The caller is not a HappyProto customer, or the provisioner refused them.
- `InvalidRequest`: slug, plan or idempotencyKey is missing or malformed.
- `NotFound`: Passed through from the provisioner.
- `InvalidSlug`: Passed through from the provisioner: it reserves slugs by configuration as well.
- `SlugTaken`: Passed through from the provisioner.
- `NotEntitled`: Passed through from the provisioner.
- `InstanceLimit`: Passed through from the provisioner.
- `NoCapacity`: Passed through from the provisioner.
- `OperationInProgress`: Passed through from the provisioner: the instance is already changing, or a request with this idempotencyKey is still running.
- `TermsRequired`: The caller's account hasn't accepted the beta terms (actor.acceptTerms), and the create carried no acceptance of its own, or one without its wording.
- `TermsOutdated`: The caller accepted only older beta terms than the ones in force: accept the current ones and try again.
- `Upstream`: The provisioner is unreachable, not configured, or answered with an error it does not explain to callers, or the job could not be started.

## #availableVersion (`at.happyproto.server.createInstance#availableVersion`)

Type: object

A newer HappyView release the instance can upgrade to.

### Properties

- `label` (string): The HappyView version the release carries, e.g. 3.0.0-alpha.41, when known.
- `releasedAt` (string · datetime, required): When HappyProto first offered it.
- `version` (string, required): The release to pass to at.happyproto.server.upgradeInstance.

## #instance (`at.happyproto.server.createInstance#instance`)

Type: object

A customer's HappyView instance. Never carries the provisioner's placement or internal fields.

### Properties

- `availableVersion` (ref): A newer release, when one is on offer.
  - Reference: `#availableVersion`
- `createdAt` (string · datetime, required)
- `id` (string, required): A UUID.
- `operation` (ref): The change in progress, if any.
  - Reference: `#operation`
- `plan` (string, required): The plan's id.
- `slug` (string, required)
- `state` (string, required)
  - Constraints: knownValues: provisioning | running | stopped | failed | deleting
- `url` (string · uri, required)
- `version` (string, required): The HappyView release it runs.
- `versionLabel` (string): The HappyView version the release carries, e.g. 3.0.0-alpha.41, when known.

## #operation (`at.happyproto.server.createInstance#operation`)

Type: object

### Properties

- `error` (string): The provisioner's error code, when it failed.
- `id` (string, required)
- `kind` (string, required)
  - Constraints: knownValues: create | update | upgrade | stop | start | destroy
- `status` (string, required)
  - Constraints: knownValues: pending | running | succeeded | failed
- `step` (string): The step it last reached.

## #termsAcceptance (`at.happyproto.server.createInstance#termsAcceptance`)

Type: object

An acceptance of the beta terms, recorded append-only by the provisioner with the caller's DID.

### Properties

- `termsVersion` (string, required): The terms in force, e.g. beta-2026-11. Anything else is TermsOutdated.
  - Constraints: maxLength: 64
- `text` (string, required): The exact wording the caller ticked.
  - Constraints: maxLength: 1000
- `textVersion` (string, required): The version of the checkbox's wording.
  - Constraints: maxLength: 32

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "availableVersion": {
      "description": "A newer HappyView release the instance can upgrade to.",
      "properties": {
        "label": {
          "description": "The HappyView version the release carries, e.g. 3.0.0-alpha.41, when known.",
          "type": "string"
        },
        "releasedAt": {
          "description": "When HappyProto first offered it.",
          "format": "datetime",
          "type": "string"
        },
        "version": {
          "description": "The release to pass to at.happyproto.server.upgradeInstance.",
          "type": "string"
        }
      },
      "required": [
        "version",
        "releasedAt"
      ],
      "type": "object"
    },
    "instance": {
      "description": "A customer's HappyView instance. Never carries the provisioner's placement or internal fields.",
      "properties": {
        "availableVersion": {
          "description": "A newer release, when one is on offer.",
          "ref": "#availableVersion",
          "type": "ref"
        },
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "id": {
          "description": "A UUID.",
          "type": "string"
        },
        "operation": {
          "description": "The change in progress, if any.",
          "ref": "#operation",
          "type": "ref"
        },
        "plan": {
          "description": "The plan's id.",
          "type": "string"
        },
        "slug": {
          "type": "string"
        },
        "state": {
          "knownValues": [
            "provisioning",
            "running",
            "stopped",
            "failed",
            "deleting"
          ],
          "type": "string"
        },
        "url": {
          "format": "uri",
          "type": "string"
        },
        "version": {
          "description": "The HappyView release it runs.",
          "type": "string"
        },
        "versionLabel": {
          "description": "The HappyView version the release carries, e.g. 3.0.0-alpha.41, when known.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "slug",
        "url",
        "plan",
        "version",
        "state",
        "createdAt"
      ],
      "type": "object"
    },
    "main": {
      "description": "Create an instance for the caller, and start a job that follows its provisioning. Customers only.",
      "errors": [
        {
          "description": "This endpoint requires an authenticated caller.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller is not a HappyProto customer, or the provisioner refused them.",
          "name": "Forbidden"
        },
        {
          "description": "slug, plan or idempotencyKey is missing or malformed.",
          "name": "InvalidRequest"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NotFound"
        },
        {
          "description": "Passed through from the provisioner: it reserves slugs by configuration as well.",
          "name": "InvalidSlug"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "SlugTaken"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NotEntitled"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "InstanceLimit"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NoCapacity"
        },
        {
          "description": "Passed through from the provisioner: the instance is already changing, or a request with this idempotencyKey is still running.",
          "name": "OperationInProgress"
        },
        {
          "description": "The caller's account hasn't accepted the beta terms (actor.acceptTerms), and the create carried no acceptance of its own, or one without its wording.",
          "name": "TermsRequired"
        },
        {
          "description": "The caller accepted only older beta terms than the ones in force: accept the current ones and try again.",
          "name": "TermsOutdated"
        },
        {
          "description": "The provisioner is unreachable, not configured, or answered with an error it does not explain to callers, or the job could not be started.",
          "name": "Upstream"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "idempotencyKey": {
              "description": "A UUID the client generates once per intended change and resends on every retry of it, so a retry gets the original reply instead of acting twice.",
              "type": "string"
            },
            "plan": {
              "description": "The plan's id, from at.happyproto.server.listPlans.",
              "type": "string"
            },
            "slug": {
              "description": "The instance's subdomain: 3 to 32 of a-z, 0-9 and -, starting with a letter.",
              "type": "string"
            },
            "terms": {
              "description": "An acceptance of the beta terms made with this create, as dashboards from before sign-in acceptance send. Optional: the caller's account accepts them once with actor.acceptTerms, and the provisioner refuses a create unless one or the other covers the terms in force (TermsRequired, TermsOutdated), staff included.",
              "ref": "#termsAcceptance",
              "type": "ref"
            }
          },
          "required": [
            "slug",
            "plan",
            "idempotencyKey"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "instance": {
              "ref": "#instance",
              "type": "ref"
            },
            "jobId": {
              "description": "The background job following the change. Poll it with at.happyproto.server.getJob.",
              "type": "string"
            }
          },
          "required": [
            "instance",
            "jobId"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "operation": {
      "properties": {
        "error": {
          "description": "The provisioner's error code, when it failed.",
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "kind": {
          "knownValues": [
            "create",
            "update",
            "upgrade",
            "stop",
            "start",
            "destroy"
          ],
          "type": "string"
        },
        "status": {
          "knownValues": [
            "pending",
            "running",
            "succeeded",
            "failed"
          ],
          "type": "string"
        },
        "step": {
          "description": "The step it last reached.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "kind",
        "status"
      ],
      "type": "object"
    },
    "termsAcceptance": {
      "description": "An acceptance of the beta terms, recorded append-only by the provisioner with the caller's DID.",
      "properties": {
        "termsVersion": {
          "description": "The terms in force, e.g. beta-2026-11. Anything else is TermsOutdated.",
          "maxLength": 64,
          "type": "string"
        },
        "text": {
          "description": "The exact wording the caller ticked.",
          "maxLength": 1000,
          "type": "string"
        },
        "textVersion": {
          "description": "The version of the checkbox's wording.",
          "maxLength": 32,
          "type": "string"
        }
      },
      "required": [
        "termsVersion",
        "textVersion",
        "text"
      ],
      "type": "object"
    }
  },
  "id": "at.happyproto.server.createInstance",
  "lexicon": 1
}
```
