Skip to content
BuzzTake
MenuClose
DocumentationAccounts with cookies

How to connect a social account with exported cookies

Last updated

Connect an account with the session of a browser where you are already signed in. BuzzTake imports the cookies and uses that session, so you do not send a password.

You need a BuzzTake API key, your workspace id, and a desktop browser where the account is signed in. Bluesky and Telegram keep their sessions outside cookies: use a password or a sign-in link for those two.

1. Export the cookies

Sign in to the platform in a desktop browser. Then export the cookies of that site with a cookie export extension. BuzzTake reads these formats:

  • A JSON array of cookie objects, the usual export of a cookie extension.
  • A Netscape cookies.txt file, as one string.
  • A browser storage state, { "cookies": [...], "origins": [...] }, as one string.

From each JSON cookie, BuzzTake reads name, value, domain (or host), path, the expiry (expirationDate, expires or expiry), httpOnly, secure, sameSite, hostOnly and session. A Netscape file has seven tab-separated fields per line; lines that start with #HttpOnly_ are read as http-only cookies.

cookies.txt (shortened)
# Netscape HTTP Cookie File
.x.com	TRUE	/	TRUE	1798761600	auth_token	3f9a...
.x.com	TRUE	/	TRUE	1798761600	ct0	a71c...

BuzzTake keeps only the platform's own cookies that have not expired, at most 300 per account. Export only the platform's site to stay under that limit. These are the domains it keeps, with their subdomains:

PlatformCookie domains kept
Xx.com, twitter.com
Instagraminstagram.com
Facebookfacebook.com, messenger.com
LinkedInlinkedin.com
TikToktiktok.com
Threadsthreads.com, threads.net, instagram.com
Redditreddit.com
YouTubeyoutube.com, google.com
Pinterestpinterest.com and Pinterest's country domains
MastodonThe host of the server in instance
Warning: The file signs anyone in as you. Keep it off shared drives and out of version control, and delete it after the import. Do not sign out in that browser afterwards: signing out can end the session the cookies hold.

2. Import the cookies

POST/v1/workspaces/{workspace_id}/accounts

Send the export in connect.cookies with method: "cookies". A Netscape file or a storage state goes as a string. A JSON export can go as the array itself or as a string.

curl

curl
jq -n --rawfile cookies cookies.txt '{
  platform: "x",
  label: "Brand X",
  connect: { method: "cookies", cookies: $cookies }
}' | curl https://api.buzztake.com/v1/workspaces/$WORKSPACE_ID/accounts \
  -H "Authorization: Bearer $BUZZTAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @-

JavaScript

JavaScript
import { readFileSync } from "node:fs";

// A Netscape file goes as a string; a JSON export can go as the parsed array.
const cookies = readFileSync("cookies.txt", "utf8");

const res = await fetch(
  `https://api.buzztake.com/v1/workspaces/${process.env.WORKSPACE_ID}/accounts`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.BUZZTAKE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      platform: "x",
      label: "Brand X",
      connect: { method: "cookies", cookies },
    }),
  },
);
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
const { account, action } = await res.json();
console.log(account.id, action.id, action.params.cookie_count);

Python

Python
import os
import requests

# A Netscape file goes as a string; a JSON export can go as the parsed list.
with open("cookies.txt", encoding="utf-8") as f:
    cookies = f.read()

resp = requests.post(
    f"https://api.buzztake.com/v1/workspaces/{os.environ['WORKSPACE_ID']}/accounts",
    headers={"Authorization": f"Bearer {os.environ['BUZZTAKE_API_KEY']}"},
    json={
        "platform": "x",
        "label": "Brand X",
        "connect": {"method": "cookies", "cookies": cookies},
    },
    timeout=30,
)
if not resp.ok:
    raise SystemExit(f"{resp.status_code}: {resp.text}")
body = resp.json()
print(body["account"]["id"], body["action"]["id"], body["action"]["params"]["cookie_count"])
201 Created (trimmed)
{
  "account": { "id": "0199a1b2-...", "platform": "x", "status": "connecting", "has_credentials": false },
  "action": {
    "id": "0199c3d4-...",
    "type": "connect",
    "status": "queued",
    "params": { "method": "cookies", "cookie_count": 14 }
  }
}

cookie_count is how many cookies BuzzTake kept after it dropped other sites and expired cookies. The cookies themselves are stored encrypted and never returned.

In the web app, open Accounts, select "Add account", pick the platform, then choose "Paste cookies". Paste the export into "Cookies", or select "Load from a file".

3. Wait for the session check

The connect action opens the platform with the imported cookies and checks that the account is signed in. It costs 25 credits, charged when it starts.

Wait for the connect action
curl "https://api.buzztake.com/v1/actions/$ACTION_ID?wait=60" \
  -H "Authorization: Bearer $BUZZTAKE_API_KEY"

succeeded means the account is active. A failed action with signed_out means the cookies did not sign the account in; the attempt is not refunded. Export fresh cookies from a browser that is signed in and import them with POST /v1/accounts/{id}/connect and the same connect object.

4. Store a login for when the cookies expire

Cookies expire. When an account has no stored login, an expired session leaves it signed_out until someone imports new cookies or signs in. With a stored login, BuzzTake signs in again by itself when the next action finds the account signed out.

PATCH/v1/accounts/{id}

Store a login (optional)
curl -X PATCH https://api.buzztake.com/v1/accounts/$ACCOUNT_ID \
  -H "Authorization: Bearer $BUZZTAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "credentials": {
      "username": "acme_demo",
      "password": "your-password",
      "totp_secret": "JBSWY3DPEHPK3PXP"
    }
  }'

The answer is the account, now with has_credentials: true. Nothing signs in and nothing is charged. totp_secret is optional; seehow to connect an account that uses two-factor authenticationfor where to find it.

Common errors

Each of these is a 422 answer, and no account is created.

invalid_input
"None of these cookies are current cookies for x.com, twitter.com. Export the cookies while signed in to x.com, then send them again." The export came from another site, or every cookie had expired.
invalid_input
"At most 300 cookies are kept for one account; this export has 412 for X." Export only the platform's site.
invalid_input
"cookies looks like JSON but could not be parsed. Send the exported array as is." The text was cut or edited.
invalid_input
"Line 3 of the cookie file does not have the seven tab-separated fields of a Netscape cookie file." An editor turned the tabs into spaces.
unsupported
"Bluesky accounts cannot connect with cookies." The answer's supported list names the methods the platform takes: password and browser.

See also

To run this on your own accounts, create a BuzzTake account, then add an account and an API key.