Laizy CMS
CLI

laizy content

Create, list, update, and delete content entries from the CLI with JSON input and status filtering.

laizy content

The content command group lets you manage content entries directly from the terminal. You can create entries from JSON, list them with filters, update existing entries, and delete them with confirmation prompts.

Commands

CommandDescription
laizy content create <model>Create a new content entry
laizy content list <model>List content entries
laizy content update <model> <id>Update an existing entry
laizy content delete <model> <id>Delete an entry

content create

Create a new content entry for a specified model. Content data can be provided via the --json flag or piped through stdin.

Usage

echo '{"title": "Hello World", "content": "My first post", "slug": "hello-world"}' \
  | pnpm laizy content create BlogPost

Piping JSON from stdin is useful for scripting and AI agent integration.

pnpm laizy content create BlogPost \
  --json '{"title": "Hello World", "content": "My first post", "slug": "hello-world"}'

The --json flag is more explicit and works well in scripts.

Flags

FlagDescriptionDefault
--json <data>Content data as a JSON string-
--status <status>Set status: draft, published, or archiveddraft
--dry-runValidate input without creating content-

Validation

The CLI validates your JSON data against the schema before sending it to the API:

  • Required fields must be present
  • Field names must exist in the model definition
  • The model name must exist in your schema
# Validation error example
pnpm laizy content create BlogPost --json '{"title": "Hello"}'
# Validation failed:
#   - Missing required field: content
#   - Missing required field: slug

Dry Run

Use --dry-run to validate without creating:

echo '{"title": "Test", "content": "Body", "slug": "test"}' \
  | pnpm laizy content create BlogPost --dry-run

# Output:
# Validation passed
# Data would be created:
# {
#   "title": "Test",
#   "content": "Body",
#   "slug": "test"
# }
# Status: draft

Publishing on Create

To create content as published immediately:

echo '{"title": "Live Post", "content": "Published content", "slug": "live-post"}' \
  | pnpm laizy content create BlogPost --status published

content list

List content entries for a specific model with optional status filtering and output format control.

Usage

pnpm laizy content list BlogPost
pnpm laizy content list BlogPost --status published
pnpm laizy content list BlogPost --limit 20
pnpm laizy content list BlogPost --json

Flags

FlagDescriptionDefault
--status <status>Filter by status: draft, published, or archivedAll statuses
--limit <number>Maximum entries to return10
--jsonOutput as raw JSON (useful for piping)Table format

Table Output (default)

BlogPost Content Entries

  ID            Title          Status      Created
  ────────      ──────         ──────      ───────
  abc123        Hello World    published   1/15/2024, 10:30:00 AM
  def456        Draft Post     draft       1/14/2024, 3:15:00 PM

2 entries

JSON Output

pnpm laizy content list BlogPost --json
[
  {
    "id": "abc123",
    "modelName": "BlogPost",
    "data": {
      "title": "Hello World",
      "content": "My first post",
      "slug": "hello-world"
    },
    "status": "published",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  }
]

The JSON output is useful for piping to other tools like jq:

pnpm laizy content list BlogPost --json | jq '.[].data.title'

content update

Update an existing content entry by ID. You can modify field data, status, or both.

Usage

# Update field data
pnpm laizy content update BlogPost abc123 \
  --json '{"title": "Updated Title"}'

# Update status only
pnpm laizy content update BlogPost abc123 \
  --status published

# Update both
pnpm laizy content update BlogPost abc123 \
  --json '{"title": "Updated Title"}' \
  --status published

Flags

FlagDescription
--json <data>JSON data with fields to update (partial updates supported)
--status <status>Update status: draft, published, or archived

Updates are partial -- you only need to include the fields you want to change. Fields not included in the JSON are left unchanged.

Validation for updates is less strict than for creation. Only the provided fields are validated against the schema, and required field checks are skipped since the entry already exists.

content delete

Delete a content entry by ID. Shows entry details and asks for confirmation before deleting.

Usage

pnpm laizy content delete BlogPost abc123
pnpm laizy content delete BlogPost abc123 --force

Flags

FlagDescription
--forceSkip the confirmation prompt

Confirmation Flow

Without --force, the CLI shows entry details and asks for confirmation:

Entry to delete:
ID: abc123
Model: BlogPost
Status: published
Created: 1/15/2024, 10:30:00 AM
Preview: title: Hello World, content: My first post...

? Are you sure you want to delete this BlogPost entry? (y/N)

Error Handling

Model not found

If the model name does not exist in your schema:

Model not found
Model 'BlogPosts' not found in schema
Available models: BlogPost, Author, HeroSection

Authentication errors

If your API token is invalid or expired:

Failed to create content
Error: unauthorized

This might be an authentication issue.
Try running laizy init to update your credentials.

Missing data

If no JSON data is provided to create:

No JSON data provided
Use --json flag or pipe JSON data via stdin
Example: echo '{"title":"Hello"}' | laizy content create BlogPost

Scripting Examples

Batch create from a file

# Create multiple entries from a JSON lines file
while IFS= read -r line; do
  echo "$line" | pnpm laizy content create BlogPost --status published
done < posts.jsonl

Export and transform

# Export all published posts as JSON
pnpm laizy content list BlogPost --status published --json > posts.json

CI/CD content seeding

# Seed content in a deployment pipeline
pnpm laizy content create HeroSection \
  --json '{"badge": "New", "headline": "Welcome to our site"}' \
  --status published

Next Steps

On this page