Reorder a phase
curl --request PATCH \
--url https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"object": "flow_state",
"id": 123,
"key": "<string>",
"title": "<string>",
"position": 123,
"kind": "step",
"objective": "<string>",
"exit_criteria": "<string>",
"max_turns": 123,
"archived": true,
"slots": [
{
"object": "information_slot",
"id": 123,
"key": "<string>",
"title": "<string>",
"data_type": "string",
"archived": true,
"required": true,
"enum_values": [
"<string>"
],
"enum_labels": {},
"translations": {},
"description": "<string>"
}
],
"tools": [
"<string>"
]
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}Flow
Reorder a phase
Moves a phase one place earlier (up) or later (down), swapping it with its neighbour among the live phases. A new phase always lands just before the closing phase, so this is how you place it. The closing phase stays last and nothing moves past it — attempting either is a 422, as is moving beyond the first or last position. Trial-compiles.
PATCH
/
agents
/
{agent_slug}
/
flow
/
states
/
{id}
/
position
Reorder a phase
curl --request PATCH \
--url https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.pepline.ai/api/v1/agents/{agent_slug}/flow/states/{id}/position")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"object": "flow_state",
"id": 123,
"key": "<string>",
"title": "<string>",
"position": 123,
"kind": "step",
"objective": "<string>",
"exit_criteria": "<string>",
"max_turns": 123,
"archived": true,
"slots": [
{
"object": "information_slot",
"id": 123,
"key": "<string>",
"title": "<string>",
"data_type": "string",
"archived": true,
"required": true,
"enum_values": [
"<string>"
],
"enum_labels": {},
"translations": {},
"description": "<string>"
}
],
"tools": [
"<string>"
]
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "<string>",
"param": "<string>"
}
}Authorizations
Your secret key (pep_sk_…) from Settings → API. Keys are org-scoped; treat them like passwords.
Body
application/json
up moves the phase earlier in the flow, down later.
Available options:
up, down Response
The moved phase, with its new position.
Allowed value:
"flow_state"Available options:
step, loop, terminal Show child attributes
Show child attributes

