# Help creating json body dynamically

**URL:** https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987
**Category:** Get Help
**Tags:** General
**Created:** [March 19, 2025, 2:52am UTC](https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987 "2025-03-19T02:52:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mutty](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.gumloop.com/mutty/32/497_2.png) [@mutty](https://forum.gumloop.com/u/mutty)
#### Post date: [March 19, 2025, 2:52am UTC](https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987/1 "2025-03-19T02:52:23Z")

</div>

Hi guys,

This would usually be pretty simple if I were coding this but I’m having trouble wrapping my head around how to dynamically create a beehiiv post.

This is what the payload looks like in the “run code” block I have:

```
payload = {
    "title": "Newsletter Title",
    "subtitle": "Newsletter Subtitle",
    "blocks": [
        {
            "type": "heading",
            "level": "2",
            "text": "This is my block!!!",
            "anchorHeader": False,
            "anchorIncludeInToc": False,
        },
        {
            "type": "image",
            "imageUrl": "https://cdn.britannica.com/89/164789-050-D6B5E2C7/Barack-Obama-2012.jpg",
            "alt_text": "A picture of Barry Obama",
            "caption": "One Cool President",
            "captionAlignment": "center",
            "imageAlignment": "right",
            "title": "Barry O",
            "url": "https://www.whitehouse.gov/",
            "width": 75
        },
        {
            "type": "list",
            "items": ["g", "h", "i"],
            "listType": "unordered",
            "startNumber": 4
        },
        {
            "type": "paragraph",
            "formattedText": [
                {
                    "text": "Read the full story ",
                    "styling": ["italic"]
                },
                {
                    "text": "here",
                    "href": "/google.com",
                    "target": "_blank"
                    "styling": ["italic"]
                }
            ]
        },
    ],
    # ... 4 more
}

```

In my flow, I will eventually have 5 sets of the above blocks.

How would you advise to build a flow for such an output?

Thanks

---

<div class="post-metadata">

### Author: ![Gumloop\_Bot](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.gumloop.com/gumloop_bot/32/504_2.png) [@Gumloop\_Bot](https://forum.gumloop.com/u/Gumloop_Bot)
#### Post date: [March 19, 2025, 2:52am UTC](https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987/2 "2025-03-19T02:52:26Z")

</div>

Hey @mutty! If you’re reporting an issue with a flow or an error in a run, please include the **run link** and make sure it’s **shareable** so we can take a look.

1. **Find your run link** on the history page. Format: `https://www.gumloop.com/pipeline?run_id={your_run_id}&workbook_id={workbook_id}`

2. **Make it shareable** by clicking **“Share”** → ‘Anyone with the link can view’ in the top-left corner of the flow screen.  
 ![GIF guide](https://canada1.discourse-cdn.com/flex027/uploads/gumloop/original/1X/92c00c612fd65b861e706dd1b5eec5ec61677835.gif)

3. **Provide details** about the issue—more context helps us troubleshoot faster.

You can find your run history here: [https://www.gumloop.com/history](https://www.gumloop.com/history)

---

<div class="post-metadata">

### Author: ![Wasay-Gumloop](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.gumloop.com/wasay-gumloop/32/69_2.png) [@Wasay-Gumloop](https://forum.gumloop.com/u/Wasay-Gumloop)
#### Post date: [March 19, 2025, 2:55pm UTC](https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987/3 "2025-03-19T14:55:02Z")

</div>

Hey @mutty – I think the best option here would be to have AI (using the `Ask AI`) node to generate these blocks for you for each section. You can specify the exact format and then you can pass those blocks as inputs to your `Run Code` node or a `Custom Node` that can format them in the payload and send it to Beehiiv.

Let me know if this works for you. If you’ve the right set of prompts and a decent model like Claude 3.7 or GPT 4o this should work pretty well.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex027/uploads/gumloop/original/1X/d02ff8efcde6ac5d3ac8aa0376137d5f804da549.png) [@system](https://forum.gumloop.com/u/system)
#### Post date: [March 24, 2025, 2:55pm UTC](https://forum.gumloop.com/t/help-creating-json-body-dynamically/1987/4 "2025-03-24T14:55:39Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
