{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://b2b.commercestudio.ai/ucp/schemas/account.json",
  "name": "ai.commercestudio.b2b.account",
  "version": "2026-10-19",
  "title": "ai.commercestudio.b2b.account",
  "description": "Linked company user: company, buyer role, ship-to and spend limit.",
  "requires": {
    "protocol": {
      "min": "2026-08-25"
    },
    "capabilities": {
      "dev.ucp.shopping.checkout": {
        "min": "2026-08-25"
      },
      "dev.ucp.shopping.cart": {
        "min": "2026-08-25"
      }
    }
  },
  "$defs": {
    "account_object": {
      "type": "object",
      "properties": {
        "company": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": {}
        },
        "buyer": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "role": {
              "type": "string",
              "description": "Company role, e.g. purchaser, purchasing_manager, junior_buyer"
            },
            "can_purchase": {
              "description": "false: this buyer's checkouts are submitted for approval; an approver places the order",
              "type": "boolean"
            }
          },
          "required": [
            "id",
            "name",
            "role"
          ],
          "additionalProperties": {}
        },
        "ship_to": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": {},
          "description": "Selected ship-to location"
        },
        "ship_tos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": {}
          }
        },
        "spend_limit": {
          "description": "Per-order spend limit for this buyer; absent means unlimited",
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "company",
        "buyer",
        "ship_to"
      ],
      "additionalProperties": {}
    },
    "dev.ucp.shopping.checkout": {
      "title": "dev.ucp.shopping.checkout with ai.commercestudio.b2b.account",
      "allOf": [
        {
          "$ref": "https://ucp.dev/2026-08-25/schemas/shopping/checkout.json"
        },
        {
          "type": "object",
          "properties": {
            "b2b_account": {
              "$ref": "#/$defs/account_object"
            }
          }
        }
      ]
    },
    "dev.ucp.shopping.cart": {
      "title": "dev.ucp.shopping.cart with ai.commercestudio.b2b.account",
      "allOf": [
        {
          "$ref": "https://ucp.dev/2026-08-25/schemas/shopping/cart.json"
        },
        {
          "type": "object",
          "properties": {
            "b2b_account": {
              "$ref": "#/$defs/account_object"
            }
          }
        }
      ]
    }
  }
}