Skip to main content
POST
/
threads
/
{thread_id}
/
runs
Create Background Run
curl --request POST \
  --url https://api.example.com/threads/{thread_id}/runs \
  --header 'Content-Type: application/json' \
  --data '
{
  "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "checkpoint": {
    "thread_id": "<string>",
    "checkpoint_ns": "<string>",
    "checkpoint_id": "<string>",
    "checkpoint_map": {}
  },
  "input": {},
  "command": {
    "update": {},
    "resume": {},
    "goto": {
      "node": "<string>",
      "input": {}
    }
  },
  "metadata": {},
  "config": {
    "tags": [
      "<string>"
    ],
    "recursion_limit": 123,
    "configurable": {}
  },
  "context": {},
  "webhook": "<string>",
  "interrupt_before": "*",
  "interrupt_after": "*",
  "stream_mode": [
    "values"
  ],
  "stream_subgraphs": false,
  "stream_resumable": false,
  "feedback_keys": [
    "<string>"
  ],
  "multitask_strategy": "enqueue",
  "if_not_exists": "reject",
  "after_seconds": 123,
  "checkpoint_during": false,
  "durability": "async"
}
'
import requests

url = "https://api.example.com/threads/{thread_id}/runs"

payload = {
    "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "checkpoint": {
        "thread_id": "<string>",
        "checkpoint_ns": "<string>",
        "checkpoint_id": "<string>",
        "checkpoint_map": {}
    },
    "input": {},
    "command": {
        "update": {},
        "resume": {},
        "goto": {
            "node": "<string>",
            "input": {}
        }
    },
    "metadata": {},
    "config": {
        "tags": ["<string>"],
        "recursion_limit": 123,
        "configurable": {}
    },
    "context": {},
    "webhook": "<string>",
    "interrupt_before": "*",
    "interrupt_after": "*",
    "stream_mode": ["values"],
    "stream_subgraphs": False,
    "stream_resumable": False,
    "feedback_keys": ["<string>"],
    "multitask_strategy": "enqueue",
    "if_not_exists": "reject",
    "after_seconds": 123,
    "checkpoint_during": False,
    "durability": "async"
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    assistant_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    checkpoint: {
      thread_id: '<string>',
      checkpoint_ns: '<string>',
      checkpoint_id: '<string>',
      checkpoint_map: {}
    },
    input: {},
    command: {update: {}, resume: {}, goto: {node: '<string>', input: {}}},
    metadata: {},
    config: {tags: ['<string>'], recursion_limit: 123, configurable: {}},
    context: {},
    webhook: '<string>',
    interrupt_before: '*',
    interrupt_after: '*',
    stream_mode: ['values'],
    stream_subgraphs: false,
    stream_resumable: false,
    feedback_keys: ['<string>'],
    multitask_strategy: 'enqueue',
    if_not_exists: 'reject',
    after_seconds: 123,
    checkpoint_during: false,
    durability: 'async'
  })
};

fetch('https://api.example.com/threads/{thread_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.example.com/threads/{thread_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([
    'assistant_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    'checkpoint' => [
        'thread_id' => '<string>',
        'checkpoint_ns' => '<string>',
        'checkpoint_id' => '<string>',
        'checkpoint_map' => [
                
        ]
    ],
    'input' => [
        
    ],
    'command' => [
        'update' => [
                
        ],
        'resume' => [
                
        ],
        'goto' => [
                'node' => '<string>',
                'input' => [
                                
                ]
        ]
    ],
    'metadata' => [
        
    ],
    'config' => [
        'tags' => [
                '<string>'
        ],
        'recursion_limit' => 123,
        'configurable' => [
                
        ]
    ],
    'context' => [
        
    ],
    'webhook' => '<string>',
    'interrupt_before' => '*',
    'interrupt_after' => '*',
    'stream_mode' => [
        'values'
    ],
    'stream_subgraphs' => false,
    'stream_resumable' => false,
    'feedback_keys' => [
        '<string>'
    ],
    'multitask_strategy' => 'enqueue',
    'if_not_exists' => 'reject',
    'after_seconds' => 123,
    'checkpoint_during' => false,
    'durability' => 'async'
  ]),
  CURLOPT_HTTPHEADER => [
    "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.example.com/threads/{thread_id}/runs"

	payload := strings.NewReader("{\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"checkpoint\": {\n    \"thread_id\": \"<string>\",\n    \"checkpoint_ns\": \"<string>\",\n    \"checkpoint_id\": \"<string>\",\n    \"checkpoint_map\": {}\n  },\n  \"input\": {},\n  \"command\": {\n    \"update\": {},\n    \"resume\": {},\n    \"goto\": {\n      \"node\": \"<string>\",\n      \"input\": {}\n    }\n  },\n  \"metadata\": {},\n  \"config\": {\n    \"tags\": [\n      \"<string>\"\n    ],\n    \"recursion_limit\": 123,\n    \"configurable\": {}\n  },\n  \"context\": {},\n  \"webhook\": \"<string>\",\n  \"interrupt_before\": \"*\",\n  \"interrupt_after\": \"*\",\n  \"stream_mode\": [\n    \"values\"\n  ],\n  \"stream_subgraphs\": false,\n  \"stream_resumable\": false,\n  \"feedback_keys\": [\n    \"<string>\"\n  ],\n  \"multitask_strategy\": \"enqueue\",\n  \"if_not_exists\": \"reject\",\n  \"after_seconds\": 123,\n  \"checkpoint_during\": false,\n  \"durability\": \"async\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	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.example.com/threads/{thread_id}/runs")
  .header("Content-Type", "application/json")
  .body("{\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"checkpoint\": {\n    \"thread_id\": \"<string>\",\n    \"checkpoint_ns\": \"<string>\",\n    \"checkpoint_id\": \"<string>\",\n    \"checkpoint_map\": {}\n  },\n  \"input\": {},\n  \"command\": {\n    \"update\": {},\n    \"resume\": {},\n    \"goto\": {\n      \"node\": \"<string>\",\n      \"input\": {}\n    }\n  },\n  \"metadata\": {},\n  \"config\": {\n    \"tags\": [\n      \"<string>\"\n    ],\n    \"recursion_limit\": 123,\n    \"configurable\": {}\n  },\n  \"context\": {},\n  \"webhook\": \"<string>\",\n  \"interrupt_before\": \"*\",\n  \"interrupt_after\": \"*\",\n  \"stream_mode\": [\n    \"values\"\n  ],\n  \"stream_subgraphs\": false,\n  \"stream_resumable\": false,\n  \"feedback_keys\": [\n    \"<string>\"\n  ],\n  \"multitask_strategy\": \"enqueue\",\n  \"if_not_exists\": \"reject\",\n  \"after_seconds\": 123,\n  \"checkpoint_during\": false,\n  \"durability\": \"async\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/threads/{thread_id}/runs")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"checkpoint\": {\n    \"thread_id\": \"<string>\",\n    \"checkpoint_ns\": \"<string>\",\n    \"checkpoint_id\": \"<string>\",\n    \"checkpoint_map\": {}\n  },\n  \"input\": {},\n  \"command\": {\n    \"update\": {},\n    \"resume\": {},\n    \"goto\": {\n      \"node\": \"<string>\",\n      \"input\": {}\n    }\n  },\n  \"metadata\": {},\n  \"config\": {\n    \"tags\": [\n      \"<string>\"\n    ],\n    \"recursion_limit\": 123,\n    \"configurable\": {}\n  },\n  \"context\": {},\n  \"webhook\": \"<string>\",\n  \"interrupt_before\": \"*\",\n  \"interrupt_after\": \"*\",\n  \"stream_mode\": [\n    \"values\"\n  ],\n  \"stream_subgraphs\": false,\n  \"stream_resumable\": false,\n  \"feedback_keys\": [\n    \"<string>\"\n  ],\n  \"multitask_strategy\": \"enqueue\",\n  \"if_not_exists\": \"reject\",\n  \"after_seconds\": 123,\n  \"checkpoint_during\": false,\n  \"durability\": \"async\"\n}"

response = http.request(request)
puts response.read_body
{
  "run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "thread_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "metadata": {},
  "kwargs": {}
}
{
  "detail": "<string>"
}
{
  "detail": "<string>"
}
{
  "detail": "<string>"
}

Path Parameters

thread_id
string<uuid>
required

The ID of the thread.

Body

application/json

Payload for creating a run.

assistant_id
required

The assistant ID or graph name to run. If using graph name, will default to first assistant created from that graph.

checkpoint
Checkpoint · object

The checkpoint to resume from.

input

The input to the graph.

command
Command · object | null

The command to run.

metadata
Metadata · object

Metadata to assign to the run.

config
Config · object

The configuration for the assistant.

context
Context · object

Static context added to the assistant.

webhook
string<uri-reference>

Webhook to call after LangGraph API call is done.

Required string length: 1 - 65536
interrupt_before

Nodes to interrupt immediately before they get executed.

Available options:
*
interrupt_after

Nodes to interrupt immediately after they get executed.

Available options:
*
stream_mode

The stream mode(s) to use.

Available options:
values,
messages,
messages-tuple,
tasks,
checkpoints,
updates,
events,
debug,
custom
stream_subgraphs
boolean
default:false

Whether to stream output from subgraphs.

stream_resumable
boolean
default:false

Whether to persist the stream chunks in order to resume the stream later.

feedback_keys
string[]

Generate pre-signed URLs for assigning feedback keys to the run.

For each key specified, a unique URL will be generated that can be called to assign the feedback key to the run. See LangSmith Feedback for more details.

multitask_strategy
enum<string>
default:enqueue

Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.

Available options:
reject,
rollback,
interrupt,
enqueue
if_not_exists
enum<string>
default:reject

How to handle missing thread. Must be either 'reject' (raise error if missing), or 'create' (create new thread).

Available options:
create,
reject
after_seconds
number

The number of seconds to wait before starting the run. Use to schedule future runs.

checkpoint_during
boolean
default:false
deprecated

Whether to checkpoint during the run.

Deprecated. Use durability instead to control checkpoint persistence behavior during the run.

durability
enum<string>
default:async

Durability level for the run. Must be one of sync, async, or exit. See durability modes for more details.

Available options:
sync,
async,
exit

Response

Success

run_id
string<uuid>
required

The ID of the run.

thread_id
string<uuid>
required

The ID of the thread.

assistant_id
string<uuid>
required

The assistant that was used for this run.

created_at
string<date-time>
required

The time the run was created.

updated_at
string<date-time>
required

The last time the run was updated.

status
enum<string>
required

The status of the run. One of 'pending', 'running', 'error', 'success', 'timeout', 'interrupted'.

Available options:
pending,
running,
error,
success,
timeout,
interrupted
metadata
Metadata · object
required

The run metadata.

kwargs
Kwargs · object
required
multitask_strategy
enum<string>
required

Strategy to handle concurrent runs on the same thread.

Available options:
reject,
rollback,
interrupt,
enqueue