Create Session
curl --request POST \
--url https://api.example.com/v1/sessionsimport requests
url = "https://api.example.com/v1/sessions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/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.example.com/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/sessions"
req, _ := http.NewRequest("POST", url, nil)
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/v1/sessions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodySessions
Create Session
Start a new autonomous agent session
POST
/
v1
/
sessions
Create Session
curl --request POST \
--url https://api.example.com/v1/sessionsimport requests
url = "https://api.example.com/v1/sessions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/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.example.com/v1/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/sessions"
req, _ := http.NewRequest("POST", url, nil)
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/v1/sessions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyStart a new agent session on a phone. The session creates a sandboxed environment where an AI agent autonomously executes your instruction.
Request
curl -X POST https://api.tapkit.ai/v1/sessions \
-H "X-API-Key: joot_your_api_key" \
-H "Content-Type: application/json" \
-d '{"phone_id": "abc123", "instruction": "Open Instagram and like the first 3 posts"}'
Request Body
{
"phone_id": "abc123-def456",
"instruction": "Open Instagram and like the first 3 posts"
}
| Field | Type | Required | Description |
|---|---|---|---|
phone_id | string | Yes | The phone to run the session on |
instruction | string | Yes | What the agent should do |
Response
Status: 201 Created{
"id": "sess_abc123",
"phone_id": "abc123-def456",
"instruction": "Open Instagram and like the first 3 posts",
"status": "creating",
"cost_usd": null,
"duration_ms": null,
"num_turns": null,
"error": null,
"created_at": "2024-01-15T10:30:00Z",
"started_at": null,
"completed_at": null
}
Response Fields
| Field | Type | Description |
|---|---|---|
id | string | Session identifier |
phone_id | string | Phone the session is running on |
instruction | string | The original instruction |
status | string | creating, running, paused, completed, failed, or killed |
cost_usd | number | null | Cost in USD (populated after completion) |
duration_ms | integer | null | Duration in milliseconds (populated after completion) |
num_turns | integer | null | Number of agent turns (populated after completion) |
error | string | null | Error message if the session failed |
created_at | string | ISO 8601 creation timestamp |
started_at | string | null | ISO 8601 timestamp when the session started running |
completed_at | string | null | ISO 8601 timestamp when the session finished |
Examples
Python
import requests
response = requests.post(
"https://api.tapkit.ai/v1/sessions",
headers={
"X-API-Key": "joot_...",
"Content-Type": "application/json"
},
json={
"phone_id": "abc123",
"instruction": "Open Instagram and like the first 3 posts"
}
)
session = response.json()
print(f"Session {session['id']} status: {session['status']}")
Poll Until Complete
import time
session_id = session["id"]
while True:
resp = requests.get(
f"https://api.tapkit.ai/v1/sessions/{session_id}",
headers={"X-API-Key": "joot_..."}
)
session = resp.json()
if session["status"] in ("completed", "failed", "killed"):
break
time.sleep(2)
print(f"Done: {session['status']} in {session['duration_ms']}ms, {session['num_turns']} turns")
Related Endpoints
- List Sessions - List all sessions
- Get Session - Get session details
- Get Events - Poll for session events
- Stop Session - Kill a running session
⌘I