curl --request POST \
--url https://api.hq.zone/v1/api/me/workspaces/switch \
--header 'Content-Type: application/json' \
--cookie hq-session= \
--data '
{
"slug": "<string>"
}
'import requests
url = "https://api.hq.zone/v1/api/me/workspaces/switch"
payload = { "slug": "<string>" }
headers = {
"cookie": "hq-session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'hq-session=', 'Content-Type': 'application/json'},
body: JSON.stringify({slug: '<string>'})
};
fetch('https://api.hq.zone/v1/api/me/workspaces/switch', 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.hq.zone/v1/api/me/workspaces/switch",
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([
'slug' => '<string>'
]),
CURLOPT_COOKIE => "hq-session=",
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.hq.zone/v1/api/me/workspaces/switch"
payload := strings.NewReader("{\n \"slug\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "hq-session=")
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.hq.zone/v1/api/me/workspaces/switch")
.header("cookie", "hq-session=")
.header("Content-Type", "application/json")
.body("{\n \"slug\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/v1/api/me/workspaces/switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'hq-session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"slug\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "<string>",
"onboarded": true,
"slug": "<string>",
"session_token": "<string>"
}Switch the active workspace
Re-scopes the session to another workspace the caller can reach (workspace
switcher P2). Verifies the caller’s verified email has a policy-passing
membership in the target - the identical signin_decision gate as sign-in,
so this never grants access a fresh sign-in wouldn’t - then re-mints the
vault-sealed session cookie for the target identity (Pattern 2: instant, no
Slack re-auth). Returns 200 + a fresh Set-Cookie; the SPA reloads into the
new workspace. 403 if the caller has no eligible membership in the target.
curl --request POST \
--url https://api.hq.zone/v1/api/me/workspaces/switch \
--header 'Content-Type: application/json' \
--cookie hq-session= \
--data '
{
"slug": "<string>"
}
'import requests
url = "https://api.hq.zone/v1/api/me/workspaces/switch"
payload = { "slug": "<string>" }
headers = {
"cookie": "hq-session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'hq-session=', 'Content-Type': 'application/json'},
body: JSON.stringify({slug: '<string>'})
};
fetch('https://api.hq.zone/v1/api/me/workspaces/switch', 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.hq.zone/v1/api/me/workspaces/switch",
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([
'slug' => '<string>'
]),
CURLOPT_COOKIE => "hq-session=",
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.hq.zone/v1/api/me/workspaces/switch"
payload := strings.NewReader("{\n \"slug\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "hq-session=")
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.hq.zone/v1/api/me/workspaces/switch")
.header("cookie", "hq-session=")
.header("Content-Type", "application/json")
.body("{\n \"slug\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/v1/api/me/workspaces/switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'hq-session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"slug\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "<string>",
"onboarded": true,
"slug": "<string>",
"session_token": "<string>"
}Authorizations
Response
Active workspace switched (fresh session cookie set)
Native clients (the iOS/mobile app, X-Hq-Native: 1) can't ride the
Set-Cookie re-scope - they store an explicit bearer. When the switch is
requested natively we additionally mint a fresh native session token
(hqses_<sealed>) for the target workspace, byte-identical underneath to
the cookie. None for web callers (they use the cookie).