# Second API Base URL: https://2.cloud This is a public HTTPS JSON API over one person's Second: their private user model and the accounts they connected to it. You read it through this API once the user has approved you. Discovery exposes no credentials and no personal records. What you need: a shell with curl. A client that can only fetch web pages cannot connect: say so, and that https://2.cloud/settings lists the other ways to connect. The one way in is HTTPS from your shell to the base URL above: no machine to log into, no SSH, VPN or Tailscale, no username, key, port or address to ask the user for. If it cannot be reached from where you run, tell the user so in your own words, and stop: there is nothing they need to do. What to do, in order: 1. Connect by the steps under "Connect an agent or terminal" below. 2. GET /tools with your token is the list of tools you may call: a summary first, then the records for any detail the summary lacks. 3. Before each call, the user hears that you are asking their Second and, where your access level asks, that the question goes to their phone, or their Mac when no phone is linked (a save asks no one; some writes go to their Mac). 4. A call is one POST to /second/tools/ with a reason in plain words. 5. The user hears what you read and where it came from. ## What Second can tell you Second answers questions about one person, from what they let it record and from the accounts they connected to it. Before you ask the user anything about themselves, their people, their time, their taste, or whether they have an account, an order or a booking somewhere, query Second: a sign-up, an order or a booking leaves an email or a message behind, and Second has those. "Plan a dinner" means querying Second for what the occasion is, who it is with, when they are free and what they like, then asking the user only what Second could not answer. Second has two layers: summaries of the user (the portrait, the constitution, the recent-context pack) and the records they are drawn from (search, mail, messages, calendar, events). A summary is where to start, never where to stop: when it lacks the detail you need, search the records before telling the user Second does not have it. It can say: - who the user is: name, address, phone, email, values, goals, preferences and habits; - the people, projects, organizations, tools and places in their life; - what they are working on: their tasks and their calendar; - what happened, from the last few minutes to the last few weeks, and the emails, messages and records behind it; - how they write, with their own writing as examples; - what is in their connected accounts (mail, calendars, documents, team chat, issue trackers, notes), read live through their Mac. Which of these your connection can use, and under what names, depends on what the user recorded, connected and allowed: GET /tools with your token is that list. ## Discovery - GET /agent: this guide (also served at / and /llms.txt). - GET /reference: the long reference (the connect protocol and every failure body). - GET /openapi.json: request and response schemas for every route below. - GET /tools (with your Bearer token): the tools of the account you are connected to, each with its JSON input schema, and "laptop_online"; its "skills" "texts" carry the second-retrieval and second-write skills. Read both before your first call (the write skill says when to record what your work came to). - GET /me (with your Bearer token): whether you are connected, the name the user knows you by, your agent ID and access level, and "laptop_online". Never anything of the user's. - GET /skills/ (with your Bearer token): how to use a group of tools. Read a connector's skill before your first call to that account; each such tool in GET /tools names its skill. ## Connect an agent or terminal Connecting lets you call the user's Second, and they can disconnect you in Second's settings at https://2.cloud/settings. It takes two calls, each one command below. Put the short name the user will know you by (letters, digits, spaces, hyphens or periods) for , and the agent product you are, such as Hermes, Muse or Codex, not the company whose model you run on, for . 1. Start. The answer stays in a private folder; the command prints the link for the user, never your device_code: ( case "/" in /*|*/|./*|../*|*/*/*|'","provider":""}' poll.json grep -o '"[a-z_]*":"[^"]*"' start.json | grep -v '"device_code":' ) 2. Post the exact link to the user first. Ask them to open it, sign in and approve the connection with Second. The link is for the user alone: never open or fetch it, never post it where others can see it, and never sign in or approve anything for the user. The request waits 10 minutes for their sign-in, then 15 minutes for their answer. 3. Wait for the answer with the held poll below: one call, held until the request changes, 30 seconds at most. It prints HTTP 200 once you are connected, HTTP 202 while the user decides, and HTTP 000 or 503 when no answer came; the request stands through all three. ( cd "$HOME/.second-cloud-agent/" 2>/dev/null && [ -s poll.json ] || { echo 'No connection request is kept under this name: run the start command first.'; exit 1; }; umask 077; A=$(mktemp answer.XXXXXX) || exit 1 S=$(curl -sS -m 60 -o "$A" -w '%{http_code}' -X POST 'https://2.cloud/auth/agent/token?wait=1' \ -H 'Content-Type: application/json' -d @poll.json "$A.h"; [ -s "$A.h" ] && mv -f "$A.h" authhdr || S=000; } echo "HTTP $S"; grep -o '"[a-z_]*":"[^"]*"' "$A" | grep -v access_token; rm -f "$A" "$A.h" ) If you can show the user a message and keep working in the same reply, run the poll in that reply, and run it again each time it prints HTTP 202, 000 or 503, for up to a few minutes. Only if the user sees nothing until your reply ends: if a command you start in the background keeps running after your reply ends, start the background poll below that way before you end the reply. In that case too, and if you can do neither, or you stop polling before the answer comes, tell the user to message you once they have approved and that their approval waits 30 minutes from their sign-in, as in "Message me once you've approved; your approval waits 30 minutes from your sign-in.", then end the reply; when they write, the poll answers at once. Never promise to tell the user on your own, as in "I'll let you know": a background command that finishes may not wake you, and if it does, say you are connected then. Never say a check is still running unless a command of yours still is. If your tool cuts the poll, run it again: the request stands, and an answer you lost comes again for 5 minutes. The background poll runs the same poll again 5 seconds after each HTTP 202, stops on any other answer, after 5 polls in a row that got no answer, or after 45 minutes, and prints the last: ( cd "$HOME/.second-cloud-agent/" 2>/dev/null && [ -s poll.json ] || { echo 'No connection request is kept under this name: run the start command first.'; exit 1; }; umask 077; A=$(mktemp answer.XXXXXX) || exit 1; N=0; T=$(( $(date +%s) + 2700 )) while [ "$(date +%s)" -lt "$T" ]; do : > "$A"; S=$(curl -sS -m 60 -o "$A" -w '%{http_code}' -X POST 'https://2.cloud/auth/agent/token?wait=1' \ -H 'Content-Type: application/json' -d @poll.json "$A.h"; [ -s "$A.h" ] && mv -f "$A.h" authhdr || S=000; } case "$S" in 202) N=0 ;; 000|503) N=$((N+1)); [ "$N" -lt 5 ] || break ;; *) break ;; esac; sleep 5; done echo "HTTP $S"; grep -o '"[a-z_]*":"[^"]*"' "$A" | grep -v access_token; rm -f "$A" "$A.h" ) 4. HTTP 200: you are connected, and authhdr holds your key. Send it as -H @"$D/authhdr" on every call; never print it or put it in a URL, a log or shared command history. Keep request_id, agent_id, name and access_level with your key. Tell the user your name, your agent ID (the first 8 characters of agent_id) and, when the answer carries access_level, your access level as it names it (such as Second prepares answers, Approve for me or Full access), as in "Connected to your Second as Muse. My agent ID is 3b9e1c2a, and my access is Second prepares answers.", then go on with what the user asked. Give the ID again only when the user asks which agent you are. Give your agent ID and a request_id only when the user asks for them or for what to tell support; no other reply shows the user a request_id or your whole agent_id. GET /me shows your current access level when Second states one. The key works for 360 days. On a 401, connect again with the same name: the user signs in again and is asked again. HTTP 202, 000 or 503: the request stands; run the poll again, as above. After 5 000s or 503s in a row, tell the user Second could not be reached from where you run. Any other answer ends the request: tell the user what its "detail" says, in your own words, and start again only if they ask. Every call below starts the same way: BASE='https://2.cloud'; D="$HOME/.second-cloud-agent/" and sends -H @"$D/authhdr". ## Calling Second - GET /tools is exactly what this user allows this connection, and it changes with their settings. - Every tool is called the same way: POST /second/tools/ with a JSON body that is the tool's arguments plus "reason". An argument the schema does not list, a missing required one, or a wrong type is a 400: "detail" names what to fix; fix it and send again (the user was not asked). - Give each call a specific "reason" in plain words: one line, at most 512 characters, no links. The reason is shown to the user when they are asked, quoted under your name, and shows in their Agent activity. Write it to the user, as "you": "You asked me who you are.", never "User asked who they are." - Each approval is the user's to decide: never skip a query to spare them a question; ask them only once Second has answered or refused. - Make one call at a time. Set your client timeout to 100 seconds (or your client's longest): the proxy in front of this API ends any call that has received no byte for 100 s. A call that needs the user's approval waits inside your call for their decision; if your call ends first, the question is withdrawn: a repeat asks the user again, and a write may already have run, so read back before repeating it. - ask_second is the exception: if your call ends while the user is still deciding, the question stays up; call ask_second again with no questions to receive what the user allows. Meanwhile say only that the question is waiting on the user's phone (their Mac with no phone linked); never call it a failure or ask whether to send it again. An ask is drafted on the Mac first, so the question can take minutes to appear. - A tool that writes is listed only where the user's account allows an outside agent's writes; while your list holds one, its "writes" member says how a write is asked, run and repeated. If your tool list holds write_outcome, your answers carry "report": the ask to record what it concluded; do as it says. Example: curl -sS --max-time 100 -X POST "$BASE/second/tools/query_tags" \ -H @"$D/authhdr" -H 'Content-Type: application/json' \ -d '{"reason":"Find the project the user asked me about."}'