Skip to main content
POST
/
v1
/
workspaces
/
{workspace_id}
/
workflows
/
{workflow_id}
/
runs
Execute workflow
curl --request POST \
  --url https://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "inputs": {},
  "session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "session_name": "<string>"
}
'
import requests

url = "https://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs"

payload = {
"inputs": {},
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"session_name": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
inputs: {},
session_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
session_name: '<string>'
})
};

fetch('https://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs', 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://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'inputs' => [

],
'session_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'session_name' => '<string>'
]),
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://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs"

payload := strings.NewReader("{\n \"inputs\": {},\n \"session_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"session_name\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", 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.post("https://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"inputs\": {},\n \"session_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"session_name\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.app.layer.ai/api/v1/workspaces/{workspace_id}/workflows/{workflow_id}/runs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"inputs\": {},\n \"session_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"session_name\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "estimated_price_creative_units": 123,
  "poll_interval_seconds": 123,
  "created_at": "2023-11-07T05:31:56Z",
  "session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Authorizations

Authorization
string
header
required

Personal Access Token or OAuth2 JWT. Create a PAT at app.layer.ai → Settings → Personal Access Tokens.

Path Parameters

workspace_id
string<uuid>
required
workflow_id
string<uuid>
required

Body

application/json
inputs
Inputs · object
required

Input values matching the workflow's input schema.

session_id
string<uuid> | null

Existing session ID. Takes precedence over session_name if both are provided.

session_name
string | null

Session name. Creates a new session if not found in the workspace. Ignored if session_id is set.

Response

Successful Response

run_id
string<uuid>
required

Unique identifier for this workflow run.

status
enum<string>
required

Current run status: PENDING or RUNNING.

Available options:
pending,
running,
success,
failure,
cancelled
estimated_price_creative_units
number
required

Estimated price in Creative Units.

poll_interval_seconds
integer
required

Suggested polling interval in seconds.

created_at
string<date-time>
required

Timestamp of when the run was created.

session_id
string<uuid> | null

Session ID the run was added to, if a session was specified.