# Source: https://upstash.com/docs/workflow/basics/context.md

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

# Overview

A workflow's **context** is an object provided by the route function.

The context object provides:

* **Workflow APIs** – functions for defining workflow steps.
* **Workflow Run Properties** – request payload, request headers, and other metadata.

<CodeGroup>
  ```typescript api/workflow/route.ts highlight={4-5} theme={"system"}
  import { serve } from "@upstash/workflow/nextjs";

  export const { POST } = serve(
    // 👇 the workflow context
    async (context) => {
      // ...
    }
  );
  ```

  ```python main.py theme={"system"}
  from fastapi import FastAPI
  from upstash_workflow.fastapi import Serve
  from upstash_workflow import AsyncWorkflowContext

  app = FastAPI()
  serve = Serve(app)


  @serve.post("/api/example")
  async def example(context: AsyncWorkflowContext[str]) -> None: ...

  ```
</CodeGroup>

## Context Object Properties

<ParamField path="requestPayload" type="object">
  The request payload passed to the workflow run via `trigger()` call.
</ParamField>

<ParamField path="headers" type="object">
  The request headers passed to the workflow run via `trigger()` call.
</ParamField>

<ParamField path="workflowRunId" type="string">
  The unique identifier of the current workflow run.
</ParamField>

<ParamField path="url" type="string">
  The public URL of the workflow endpoint.
</ParamField>

<ParamField path="failureUrl" type="string">
  The URL used for workflow failure callback.

  If a failure function is defined, this is the same as the workflow's `url`.
</ParamField>

<ParamField path="env" type="object">
  The environment variables available to the workflow.
</ParamField>

<ParamField path="qstashClient" type="object">
  The QStash client instance used by the workflow endpoint.
</ParamField>

<ParamField path="label" type="srting | undefined">
  The label of the current workflow run, if set in [client.trigger](/workflow/basics/client/trigger).
</ParamField>

## Context Object Functions

You can use the functions exposed by context object to define workflow steps.

* [context.run](/workflow/basics/context/run)
* [context.sleep](/workflow/basics/context/sleep)
* [context.sleepUntil](/workflow/basics/context/sleepUntil)
* [context.waitForEvent](/workflow/basics/context/waitForEvent)
* [context.createWebhook](/workflow/basics/context/createWebhook)
* [context.waitForWebhook](/workflow/basics/context/waitForWebhook)
* [context.notify](/workflow/basics/context/notify)
* [context.invoke](/workflow/basics/context/invoke)
* [context.call](/workflow/basics/context/call)
* [context.cancel](/workflow/basics/context/cancel)
* [context.api](/workflow/basics/context/api)