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
| Command | Description |
|---|---|
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 BlogPostPiping 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
| Flag | Description | Default |
|---|---|---|
--json <data> | Content data as a JSON string | - |
--status <status> | Set status: draft, published, or archived | draft |
--dry-run | Validate 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: slugDry 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: draftPublishing on Create
To create content as published immediately:
echo '{"title": "Live Post", "content": "Published content", "slug": "live-post"}' \
| pnpm laizy content create BlogPost --status publishedcontent 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 --jsonFlags
| Flag | Description | Default |
|---|---|---|
--status <status> | Filter by status: draft, published, or archived | All statuses |
--limit <number> | Maximum entries to return | 10 |
--json | Output 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 entriesJSON 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 publishedFlags
| Flag | Description |
|---|---|
--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 --forceFlags
| Flag | Description |
|---|---|
--force | Skip 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, HeroSectionAuthentication 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 BlogPostScripting 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.jsonlExport and transform
# Export all published posts as JSON
pnpm laizy content list BlogPost --status published --json > posts.jsonCI/CD content seeding
# Seed content in a deployment pipeline
pnpm laizy content create HeroSection \
--json '{"badge": "New", "headline": "Welcome to our site"}' \
--status publishedNext Steps
- Config Command -- Manage CLI configuration settings
- Client Queries -- Query content programmatically with the TypeScript client
- API Reference -- Raw API endpoints for content operations