---
title: "Edit a flow with an AI instruction"
method: POST
path: "/flows/{id}/edit"
tags: ["AI"]
---

# Edit a flow with an AI instruction

`POST /flows/{id}/edit`

## Request

- Base URL: `https://lnzcwfswvljbijqszxxn.supabase.co/functions/v1/api/v1`
- URL: `https://lnzcwfswvljbijqszxxn.supabase.co/functions/v1/api/v1/flows/{id}/edit`
- Auth: HTTP bearer

Changes the flow from a plain instruction, for example "Add a manager approval before the refund". Saves a version.

## Request body

- object
  - `instruction` string, required

## Response `200`

The changed flow.

- FlowResponse
  - `flow` Flow
    - `id` string, uuid
    - `title` string
    - `graph_nodes` Node[]
      - `id` string: Unique in the flow. Default n1, n2.
      - `type` 'start' | 'step' | 'decision' | 'data' | 'system' | 'actor' | 'end' | 'screen'
      - `label` string, required
      - `owner` string: Role or team that does the step. Used for swimlanes.
      - `x` number
      - `y` number
    - `graph_edges` Edge[]
      - `id` string
      - `source` string, required
      - `target` string, required
      - `label` string
    - `transcript` string, nullable
    - `diagram_code` string, nullable
    - `team_id` string, nullable
    - `folder_id` string, nullable
    - `is_public` boolean
    - `owner` string
    - `created_at` string, date-time
    - `updated_at` string, date-time

## Other responses

- `400`: Error. Codes: bad_request, bad_graph, unauthorized, key_expired, save_failed, missing_scope, not_found, rate_limited, internal.
- `401`: Error. Codes: bad_request, bad_graph, unauthorized, key_expired, save_failed, missing_scope, not_found, rate_limited, internal.
- `403`: Error. Codes: bad_request, bad_graph, unauthorized, key_expired, save_failed, missing_scope, not_found, rate_limited, internal.
- `404`: Error. Codes: bad_request, bad_graph, unauthorized, key_expired, save_failed, missing_scope, not_found, rate_limited, internal.
- `429`: Error. Codes: bad_request, bad_graph, unauthorized, key_expired, save_failed, missing_scope, not_found, rate_limited, internal.

---

[API](https://skmtc.dev/wavelengthflow/apis/wavelength-api.md) · [All operations](https://skmtc.dev/wavelengthflow/apis/wavelength-api/llms.txt) · [OpenAPI document](https://skmtc.dev/wavelengthflow/apis/wavelength-api/revisions/676f533e10d5?raw)
