Narrative Protocol

Entity Schemas

Define entity structures

Entity Schemas API

Entity schema routes are world-scoped.

Endpoints

List Entity Schemas

GET /api/worlds/:worldAddress/entity-schemas?page=1&limit=20

Create Entity Schema

POST /api/worlds/:worldAddress/entity-schemas
Request Body
{
  "name": "horse",
  "description": "A racing horse",
  "attributes": [
    {
      "name": "speed_rating",
      "type": "float",
      "constraints": { "min": 0, "max": 1 },
      "defaultValue": 0.5
    }
  ]
}
FieldTypeRequiredDescription
namestringYesSchema name, 1-255 chars
descriptionstringNoSchema description
attributesobject[]NoInline attributes created with the schema
attributes[].namestringYesAttribute key
attributes[].typeenumYesinteger | float | string | boolean | json
attributes[].constraintsobjectNoValidation rules for attribute values
attributes[].constraints.minnumberNoLower bound
attributes[].constraints.maxnumberNoUpper bound
attributes[].constraints.enumstring[]NoAllowed string values
attributes[].constraints.patternstringNoRegex for string attributes
attributes[].constraints.requiredbooleanNoRequired semantics flag
attributes[].defaultValueanyNoDefault state value

List Attributes for a Schema

GET /api/worlds/:worldAddress/entity-schemas/:schemaName/attributes?page=1&limit=20

Create Attribute

POST /api/worlds/:worldAddress/entity-schemas/:schemaName/attributes
Request Body
{
  "name": "wins",
  "type": "integer",
  "constraints": { "min": 0 },
  "defaultValue": 0
}
FieldTypeRequiredDescription
namestringYesAttribute key
typeenumYesinteger | float | string | boolean | json
constraintsobjectNoValidation rules
constraints.minnumberNoLower bound
constraints.maxnumberNoUpper bound
constraints.enumstring[]NoAllowed string values
constraints.patternstringNoRegex for string attributes
constraints.requiredbooleanNoRequired semantics flag
defaultValueanyNoDefault state value

Get Attribute by Name

GET /api/worlds/:worldAddress/entity-schemas/:schemaName/attributes/:name

Update Attribute by Name

PUT /api/worlds/:worldAddress/entity-schemas/:schemaName/attributes/:name
Request Body
{
  "name": "wins",
  "type": "integer",
  "constraints": {
    "min": 0,
    "required": true
  },
  "defaultValue": 0
}
FieldTypeRequiredDescription
namestringNoNew attribute key
typeenumNointeger | float | string | boolean | json
constraintsobjectNoValidation rules (same shape as create)
defaultValueanyNoDefault value for future merges/defaulting

Delete Attribute by Name

DELETE /api/worlds/:worldAddress/entity-schemas/:schemaName/attributes/:name

Get Entity Schema

GET /api/worlds/:worldAddress/entity-schemas/:schemaName

Update Entity Schema

PUT /api/worlds/:worldAddress/entity-schemas/:schemaName
Request Body
{
  "name": "horse",
  "description": "A racing horse updated"
}
FieldTypeRequiredDescription
namestringNoSchema name.
descriptionstringNoSchema description.

Delete Entity Schema

DELETE /api/worlds/:worldAddress/entity-schemas/:schemaName