{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/staycharted-com/json-schema/staycharted-com-customer-schema.json",
  "title": "Customer",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/staycharted-com-openapi.yaml#/components/schemas/Customer",
  "type": "object",
  "required": [
    "id",
    "name",
    "access",
    "status"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "type": "string"
    },
    "contactEmail": {
      "type": "string"
    },
    "access": {
      "type": "string",
      "enum": [
        "api",
        "login"
      ]
    },
    "joinedFromDirect": {
      "type": "boolean",
      "description": "The customer already paid StayCharted itself and asked to be billed through you. Its account was its own before you, so cancelling it moves it back to direct billing rather than closing it."
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "cancelling",
        "cancelled",
        "handed_over"
      ]
    },
    "plan": {
      "type": [
        "string",
        "null"
      ],
      "description": "The first workspace's plan."
    },
    "pendingPlan": {
      "type": [
        "string",
        "null"
      ]
    },
    "addOns": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "endsAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "usage": {
      "$ref": "#/$defs/Usage"
    },
    "workspaces": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Workspace"
      }
    },
    "ownerSignedInAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "A resold customer only. When its Owner last signed in; null until they have."
    }
  },
  "$defs": {
    "Usage": {
      "type": [
        "object",
        "null"
      ],
      "description": "This billing month's counts. Never content.",
      "properties": {
        "cycleStart": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "predictions": {
          "type": "integer"
        },
        "predictionsLimit": {
          "type": [
            "integer",
            "null"
          ]
        },
        "pictures": {
          "type": "integer"
        },
        "picturesLimit": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "Workspace": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "plan": {
          "type": "string"
        },
        "pendingPlan": {
          "type": [
            "string",
            "null"
          ],
          "description": "A downgrade waiting for the end of the paid month."
        },
        "changesAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "endsAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Set when you stopped paying for it."
        },
        "archived": {
          "type": "boolean"
        },
        "primary": {
          "type": "boolean",
          "description": "The customer's first workspace."
        },
        "joinsAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "For a customer that joined you from its own billing: when this workspace moves to your bill, at the end of the month its Owner already paid for. Until then it is not on your bill and its plan cannot be changed (`partner.workspace_joining`)."
        },
        "addOns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "usage": {
          "$ref": "#/$defs/Usage"
        }
      }
    }
  }
}