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

# Workflows

> Embed Blocks into existing workflow systems and continue after the final response.

Blocks fits cleanly into multi-step workflows where one stage needs an AI agent to do work and a later stage needs to consume the result. A workflow can create a session, wait for the assistant's `final_message`, and then continue with the next action in your system.

## Typical workflow shape

1. A workflow step decides work should be delegated to Blocks.
2. It creates a session with `POST /rest/v1/sessions`.
3. It stores the returned `session_id` and `_links.final_message.href`.
4. It polls or schedules a follow-up check for the final assistant message.
5. It uses that result to continue the workflow.

## Example uses

* Create a Jira or Linear issue after Blocks produces a scoped implementation plan
* Run a review or triage step, then route based on the final recommendation
* Generate a technical summary that another workflow step posts to Slack or email
* Start a coding task, then trigger downstream automation when the final answer is ready

## Example

```javascript theme={null}
const headers = {
  Authorization: `ApiKey ${process.env.BLOCKS_API_KEY}`,
  "Content-Type": "application/json",
};

const session = await fetch("https://api.blocks.team/rest/v1/sessions", {
  method: "POST",
  headers,
  body: JSON.stringify({
    agent_name: "claude",
    message:
      "Review this ticket and produce a short implementation plan: https://linear.app/acme-corp/issue/ENG-247/add-audit-logging-to-admin-actions",
  }),
}).then((r) => r.json());

const finalPage = await fetch(session._links.final_message.href, { headers }).then((r) => r.json());
const finalMessage = finalPage.items[0]?.message;

if (finalMessage) {
  await continueWorkflow({
    sessionId: session.id,
    blocksResult: finalMessage,
  });
}
```

## Why this works well

* The session ID gives every workflow run a durable reference
* `final_message` provides a clean handoff point for downstream systems
* Follow-up messages let later workflow steps continue the same session when needed

For the API details behind this pattern, start with [Quick Start](/rest-api/quick-start) and [Send Messages](/rest-api/sessions/follow-up).
