---
title: "Create User Schema V1"
method: POST
path: "/v1/schemas"
tags: ["v1", "Schema Management"]
---

# Create User Schema V1

`POST /v1/schemas`

Create a new user-defined graph schema.
    
    This endpoint allows users to define custom node types and relationships for their knowledge graph.
    The schema will be validated and stored for use in future memory extractions.
    
    **Features:**
    - Define custom node types with properties and validation rules
    - Define custom relationship types with constraints
    - Automatic validation against system schemas
    - Support for different scopes (personal, workspace, organization)
    - **Enum support**: Use `enum_values` to restrict property values to a predefined list (max 10 values)
    - **Auto-indexing**: Required properties are automatically indexed in Neo4j for optimal query performance
    
    **Property Types & Validation:**
    - `string`: Text values with optional `enum_values`, `min_length`, `max_length`, `pattern`
    - `integer`: Whole numbers with optional `min_value`, `max_value`
    - `float`: Decimal numbers with optional `min_value`, `max_value`
    - `boolean`: True/false values
    - `datetime`: ISO 8601 timestamp strings
    - `array`: Lists of values
    - `object`: Complex nested objects
    
    **Enum Values:**
    - Add `enum_values` to any string property to restrict values to a predefined list
    - Maximum 10 enum values allowed per property
    - Use with `default` to set a default enum value
    - Example: `"enum_values": ["small", "medium", "large"]`
    
    **When to Use Enums:**
    - Limited, well-defined options (≤10 values): sizes, statuses, categories, priorities
    - Controlled vocabularies: "active/inactive", "high/medium/low", "bronze/silver/gold"
    - When you want exact matching and no variations
    
    **When to Avoid Enums:**
    - Open-ended text fields: names, titles, descriptions, addresses
    - Large sets of options (>10): countries, cities, product models
    - When you want semantic similarity matching for entity resolution
    - Dynamic or frequently changing value sets
    
    **Unique Identifiers & Entity Resolution:**
    - Properties marked as `unique_identifiers` are used for entity deduplication and merging
    - **With enum_values**: Exact matching is used - entities with the same enum value are considered identical
    - **Without enum_values**: Semantic similarity matching is used - entities with similar meanings are automatically merged
    - Example: A "name" unique_identifier without enums will merge "Apple Inc" and "Apple Inc." as the same entity
    - Example: A "sku" unique_identifier with enums will only merge entities with exactly matching SKU codes
    - Use enums for unique_identifiers when you have a limited, predefined set of values (≤10 options)
    - Avoid enums for unique_identifiers when you have broad, open-ended values or >10 possible options
    - **Best practices**: Use enums for controlled vocabularies (status codes, categories), avoid for open text (company names, product titles)
    - **In the example above**: "name" uses semantic similarity (open-ended), "sku" uses exact matching (controlled set)
    
    **LLM-Friendly Descriptions:**
    - Write detailed property descriptions that guide the LLM on expected formats and usage
    - Include examples of typical values (e.g., "Product name, typically 2-4 words like 'iPhone 15 Pro'")
    - Specify data formats and constraints clearly (e.g., "Price in USD as decimal number")
    - For enums, explain when to use each option (e.g., "use 'new' for brand new items")
    
    **Authentication Required**:
    One of the following authentication methods must be used:
    - Bearer token in `Authorization` header
    - API Key in `X-API-Key` header
    - Session token in `X-Session-Token` header
    
    **Required Headers**:
    - Content-Type: application/json
    - X-Client-Type: (e.g., 'papr_plugin', 'browser_extension')

## Request body

- UserGraphSchemaInput — Complete user-defined graph schema
  - `id` string
  - `name` string, required
  - `description` string, nullable
  - `version` string
  - `user_id` union
    - string
    - object
  - `workspace_id` union
    - string
    - object
  - `organization_id` string, nullable
  - `node_types` object — Custom node types (max 15 per schema)
  - `relationship_types` object — Custom relationship types (max 20 per schema)
  - `status` 'draft' | 'active' | 'deprecated' | 'archived'
  - `scope` 'personal' | 'workspace' | 'organization'
  - `created_at` string, date-time
  - `updated_at` string, date-time, nullable
  - `read_access` string[]
  - `write_access` string[]
  - `usage_count` integer
  - `last_used_at` string, date-time, nullable

## Response `200`

Successful Response

- SchemaResponse — Response model for schema operations
  - `success` boolean, required
  - `data` UserGraphSchemaOutput — Complete user-defined graph schema
    - `id` string
    - `name` string, required
    - `description` string, nullable
    - `version` string
    - `user_id` union
      - string
      - object
    - `workspace_id` union
      - string
      - object
    - `organization_id` string, nullable
    - `node_types` object — Custom node types (max 15 per schema)
    - `relationship_types` object — Custom relationship types (max 20 per schema)
    - `status` 'draft' | 'active' | 'deprecated' | 'archived'
    - `scope` 'personal' | 'workspace' | 'organization'
    - `created_at` string, date-time
    - `updated_at` string, date-time, nullable
    - `read_access` string[]
    - `write_access` string[]
    - `usage_count` integer
    - `last_used_at` string, date-time, nullable
  - `error` string, nullable
  - `code` integer

## Other responses

- `201` — Schema created successfully
- `400` — Invalid schema definition
- `401` — Unauthorized
- `422` — Validation Error
- `500` — Internal server error

## Changes

- **2025-11-07** `14ff13755871` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/papr-ai/apis/papr-memory-api/changes/v1/schemas/post.md)

---

[API](https://skmtc.dev/papr-ai/apis/papr-memory-api.md) · [All operations](https://skmtc.dev/papr-ai/apis/papr-memory-api/llms.txt) · [OpenAPI document](https://skmtc.dev/papr-ai/apis/papr-memory-api/revisions/34b5e739fd20?raw)
