> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Expand JobRun payload dynamically

## Recipe

This recipe shows how to chain API executions by extending a job's payload within your code using Intuned's [`extendPayload`](/main/05-references/runtime-sdk-typescript/extend-payload) (TypeScript) or [`extend_payload`](/main/05-references/runtime-sdk-python/extend-payload) (Python) helper.

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { extendPayload } from "@intuned/runtime";
  import { BrowserContext, Page } from "playwright";

  export default async function handler(
    params: any,
    page: Page,
    context: BrowserContext
  ) {
    await page.goto("https://books.toscrape.com/");

    const bookTitles: { title: string }[] = [];

    // Scraping book titles
    const bookLocators = page.locator("ol li");
    const count = await bookLocators.count();

    const allLocators = await bookLocators.all();

    for (const bookLocator of allLocators) {
      const titleLocator = bookLocator.locator("h3");
      const txt = (await titleLocator.textContent())?.trim();

      const detailsUrlLocator = bookLocator.locator("div.image_container a");
      const href = await detailsUrlLocator.getAttribute("href");
      const detailsUrl = "https://books.toscrape.com/" + href;

      if (txt) {
        bookTitles.push({ title: txt });
       
      }
      // Extending payload
      extendPayload({
          api: "details",
          parameters: { url: detailsUrl },
        });
    }
  }
  ```

  ```python Python theme={null}
  from intuned_runtime import extend_payload
  from playwright.async_api import Page, BrowserContext

  async def automation(page: Page, params: dict | None = None, **_kwargs):
      await page.goto("https://books.toscrape.com/")

      book_titles = []

      # Scraping book titles
      book_locators = page.locator("ol li")
      count = await book_locators.count()

      all_locators = await book_locators.all()

      for book_locator in all_locators:
          title_locator = book_locator.locator("h3")
          txt = await title_locator.text_content()
          txt = txt.strip() if txt else None

          details_locator = book_locator.locator("div.image_container a")
          href = await details_locator.get_attribute("href")
          details_url = f"https://books.toscrape.com/{href}"

          if txt:
              book_titles.append({"title": txt})

          # Extending payload
          extend_payload({
              "api": "details",
              "parameters": {"url": details_url},
          })

  ```
</CodeGroup>

## Related SDK methods

<CardGroup cols={2}>
  <Card title="extendPayload (TypeScript)" icon="js" href="/main/05-references/runtime-sdk-typescript/extend-payload">
    TypeScript SDK helper for extending payloads
  </Card>

  <Card title="extend_payload (Python)" icon="python" href="/main/05-references/runtime-sdk-python/extend-payload">
    Python SDK helper for extending payloads
  </Card>

  <Card title="nested_scheduling" href="/main/02-features/jobs-batched-executions#nested-scheduling">
    Nested scheduling
  </Card>
</CardGroup>
