Cookies
curl --request GET \
--url https://api.example.com/v1/sessions/{id}/cookies \
--header 'Content-Type: application/json' \
--data '
{
"cookies": "<string>",
"format": "<string>",
"merge": true
}
'import requests
url = "https://api.example.com/v1/sessions/{id}/cookies"
payload = {
"cookies": "<string>",
"format": "<string>",
"merge": True
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({cookies: '<string>', format: '<string>', merge: true})
};
fetch('https://api.example.com/v1/sessions/{id}/cookies', 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/{id}/cookies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'cookies' => '<string>',
'format' => '<string>',
'merge' => true
]),
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/v1/sessions/{id}/cookies"
payload := strings.NewReader("{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}")
req, _ := http.NewRequest("GET", 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.get("https://api.example.com/v1/sessions/{id}/cookies")
.header("Content-Type", "application/json")
.body("{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sessions/{id}/cookies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}"
response = http.request(request)
puts response.read_bodyAPI Reference
Cookies
Export and import session cookies
GET
/
v1
/
sessions
/
{id}
/
cookies
Cookies
curl --request GET \
--url https://api.example.com/v1/sessions/{id}/cookies \
--header 'Content-Type: application/json' \
--data '
{
"cookies": "<string>",
"format": "<string>",
"merge": true
}
'import requests
url = "https://api.example.com/v1/sessions/{id}/cookies"
payload = {
"cookies": "<string>",
"format": "<string>",
"merge": True
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({cookies: '<string>', format: '<string>', merge: true})
};
fetch('https://api.example.com/v1/sessions/{id}/cookies', 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/{id}/cookies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'cookies' => '<string>',
'format' => '<string>',
'merge' => true
]),
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/v1/sessions/{id}/cookies"
payload := strings.NewReader("{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}")
req, _ := http.NewRequest("GET", 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.get("https://api.example.com/v1/sessions/{id}/cookies")
.header("Content-Type", "application/json")
.body("{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sessions/{id}/cookies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"cookies\": \"<string>\",\n \"format\": \"<string>\",\n \"merge\": true\n}"
response = http.request(request)
puts response.read_bodyCookies
Read cookies out of a live browser session or load cookies into one. Useful for persisting login state across sessions or seeding a session from a saved profile.Export Cookies
GET /v1/sessions/{id}/cookies?format=json|netscape
string
default:"json"
json returns a JSON array of cookie objects. netscape returns a Netscape-format cookies.txt body (Content-Type: text/plain).Response (format=json)
[
{
"name": "sid",
"value": "abc123",
"domain": "example.com",
"path": "/",
"expires": 1767225600,
"httpOnly": true,
"secure": true,
"sameSite": "Lax"
}
]
Import Cookies
POST /v1/sessions/{id}/cookies/import
string
required
Serialized cookie data (a JSON array string, or Netscape
cookies.txt content).string
default:"json"
json or netscape.boolean
default:"false"
When
true, imported cookies are merged with the cookies already in the browser instead of being applied standalone.Response
{ "data": { "imported": 12 } }
Errors
| Status | Meaning |
|---|---|
400 | Unknown format or unparseable cookie data. |
404 | Session not found. |
502 | Browser rejected the cookie operation. |
⌘I