Skip to main content

Scenario

Your marketing team maintains a Notion content calendar database with columns like Title, Status, Content Type, Target Persona, and Publish Date. Planned pieces sit in “Idea” or “Outlined” status with no draft. This job queries the database for upcoming content, then calls Mavera’s Generate endpoint for each piece — producing first drafts at scale that match your existing brand voice. Flow: Notion POST /databases/{id}/query (filter: status = “Planned”) → For each row → Mavera POST /api/v1/generations (with brand_voice_id) → Draft content attached back as Notion page

Code

Example Output

Error Handling

If the query returns 404 or object not found, open the database in Notion → ⋯ → Connections → add your integration. This is the most common issue.
Notion property names are case-sensitive. If Status is actually status or Content Status in your database, the filter returns zero results. Use GET /databases/{id} to inspect property names.
The loop includes a 500ms delay. For calendars with 50+ pieces, add exponential backoff on 429 or batch into runs of 10.
Notion limits rich_text content to 2000 characters per block. The code chunks long paragraphs. Append requests are limited to 100 blocks per call.