curl --request POST \
--url https://api.circuit.org/partner/v0.1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent": "agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60",
"wallet": null,
"amount": "100"
}
'import requests
url = "https://api.circuit.org/partner/v0.1/sessions"
payload = {
"agent": "agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60",
"wallet": None,
"amount": "100"
}
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({agent: 'agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60', wallet: null, amount: '100'})
};
fetch('https://api.circuit.org/partner/v0.1/sessions', 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.circuit.org/partner/v0.1/sessions",
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([
'agent' => 'agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60',
'wallet' => null,
'amount' => '100'
]),
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.circuit.org/partner/v0.1/sessions"
payload := strings.NewReader("{\n \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\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.circuit.org/partner/v0.1/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.circuit.org/partner/v0.1/sessions")
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 \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent": "<string>",
"name": "<string>",
"status": "running",
"started_at": "2023-11-07T05:31:56Z",
"wallet": "<string>",
"value_usd": "<string>",
"pnl_usd": "<string>",
"error": "<string>"
}{
"error": "<string>",
"code": "<string>"
}Start an agent
Starts an agent for the user on a wallet they picked, or on paper money when wallet is null. It takes effect immediately, so call it only after the user confirms in your app. The agent then runs on its own schedule until it is stopped. Returns 400 with a message the user can read when the agent cannot start, for example when the amount is below its minimum.
curl --request POST \
--url https://api.circuit.org/partner/v0.1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent": "agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60",
"wallet": null,
"amount": "100"
}
'import requests
url = "https://api.circuit.org/partner/v0.1/sessions"
payload = {
"agent": "agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60",
"wallet": None,
"amount": "100"
}
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({agent: 'agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60', wallet: null, amount: '100'})
};
fetch('https://api.circuit.org/partner/v0.1/sessions', 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.circuit.org/partner/v0.1/sessions",
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([
'agent' => 'agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60',
'wallet' => null,
'amount' => '100'
]),
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.circuit.org/partner/v0.1/sessions"
payload := strings.NewReader("{\n \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\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.circuit.org/partner/v0.1/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.circuit.org/partner/v0.1/sessions")
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 \"agent\": \"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60\",\n \"wallet\": null,\n \"amount\": \"100\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent": "<string>",
"name": "<string>",
"status": "running",
"started_at": "2023-11-07T05:31:56Z",
"wallet": "<string>",
"value_usd": "<string>",
"pnl_usd": "<string>",
"error": "<string>"
}{
"error": "<string>",
"code": "<string>"
}Authorizations
The permit the user approved for your app.
Headers
Optional. A UUID your app generates for this request. Send the same value when you retry, and Circuit returns the first result instead of acting twice. Reusing a key with different contents returns 409. Without a key, a retried request can act twice.
Body
The agent to start, from GET /partner/agents.
"agt_0b3c9e2a-6d1f-4f7a-9c2e-5b8a1d4e7f60"
The wallet it should trade, from the account. Null runs it on paper money.
null
How much of the agent's starting asset to give it, as a decimal string. Null lets Circuit pick its default amount.
80^(?:0|[1-9]\d*)(?:\.\d+)?$"100"
Response
OK
An agent running for the user on one wallet or on paper money.
The session's id, starting with ses_.
The agent it runs, starting with agt_.
The agent's name.
The agent is running on its own schedule.
"running"When the session started.
The wallet it trades, starting with wal_. Null when it runs on paper money.
The current value of what the session holds, in USD as a decimal string. Null until Circuit first values a new session, about a minute after it starts, or when a holding can't be priced.
Profit or loss since the session started, in USD as a decimal string. Null when unknown.
What the user needs to do when status is needs_user. Null otherwise.