Workspaces
Most data in Archive belongs to a workspace, typically a single brand or region.
Send its UUID in WORKSPACE-ID to choose where a request reads or changes data.
WORKSPACE-ID: <workspace-uuid>Finding workspace IDs
A workspace ID is the id returned by the workspaces query, which lists every workspace your
token can access. You can also copy it from the Archive app’s API settings.
Run workspaces with your bearer token; it does not require a WORKSPACE-ID header.
query WorkspacesDefault($first: Int, $after: String) {
workspaces(first: $first, after: $after) {
totalCount
edges {
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
} {
"first": 10
} Authorization: Bearer docs_demo_token_0000000000000000000000
WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a curl https://app.archive.com/api/v2 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer docs_demo_token_0000000000000000000000' \
-H 'WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a' \
-d '{
"query": "query WorkspacesDefault($first: Int, $after: String) {\n workspaces(first: $first, after: $after) {\n totalCount\n edges {\n node {\n id\n name\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}",
"variables": {
"first": 10
}
}' const response = await fetch("https://app.archive.com/api/v2", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
},
body: JSON.stringify({
query: `query WorkspacesDefault($first: Int, $after: String) {
workspaces(first: $first, after: $after) {
totalCount
edges {
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}`,
variables: {
"first": 10
}
})
})
console.log(JSON.stringify(await response.json(), null, 2)) require "json"
require "net/http"
query = <<~'GRAPHQL'
query WorkspacesDefault($first: Int, $after: String) {
workspaces(first: $first, after: $after) {
totalCount
edges {
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
GRAPHQL
response = Net::HTTP.post(
URI("https://app.archive.com/api/v2"),
{ query: query, variables: { "first" => 10 } }.to_json,
"Content-Type" => "application/json",
"Authorization" => "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID" => "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
)
puts response.body import json
import requests
query = """
query WorkspacesDefault($first: Int, $after: String) {
workspaces(first: $first, after: $after) {
totalCount
edges {
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
"""
response = requests.post(
"https://app.archive.com/api/v2",
json={"query": query, "variables": {"first": 10}},
headers={
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
},
)
print(json.dumps(response.json(), indent=2)) {
"data": {
"workspaces": {
"totalCount": 1,
"edges": [
{
"node": {
"id": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
"name": "Northwind Botanicals"
}
}
],
"pageInfo": {
"hasNextPage": false,
"endCursor": "Z2lkOi8vYXJjaGl2ZS9Xb3Jrc3BhY2UvNmNjZWZhNzYtZThiYS01YWIwLTljNjAtZTQ4YTllMjM1YTRh"
}
}
}
} Which operations are workspace-scoped
Every operation is workspace-scoped except workspaces. Queries like workspace, items,
creators, and transcriptions all read from the workspace identified by the header, so they need
it on every call. Configure your client to include the header in each request:
query WorkspaceDefault {
workspace {
id
name
}
} Authorization: Bearer docs_demo_token_0000000000000000000000
WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a curl https://app.archive.com/api/v2 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer docs_demo_token_0000000000000000000000' \
-H 'WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a' \
-d '{
"query": "query WorkspaceDefault {\n workspace {\n id\n name\n }\n}"
}' const response = await fetch("https://app.archive.com/api/v2", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
},
body: JSON.stringify({
query: `query WorkspaceDefault {
workspace {
id
name
}
}`
})
})
console.log(JSON.stringify(await response.json(), null, 2)) require "json"
require "net/http"
query = <<~'GRAPHQL'
query WorkspaceDefault {
workspace {
id
name
}
}
GRAPHQL
response = Net::HTTP.post(
URI("https://app.archive.com/api/v2"),
{ query: query }.to_json,
"Content-Type" => "application/json",
"Authorization" => "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID" => "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
)
puts response.body import json
import requests
query = """
query WorkspaceDefault {
workspace {
id
name
}
}
"""
response = requests.post(
"https://app.archive.com/api/v2",
json={"query": query},
headers={
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
},
)
print(json.dumps(response.json(), indent=2)) {
"data": {
"workspace": {
"id": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
"name": "Northwind Botanicals"
}
}
} Missing or unknown workspaces
Check the header value against these three cases:
- Omitting the
WORKSPACE-IDheader on a workspace-scoped operation, or sending it empty, returns HTTP 400 with the body{"errors":"WORKSPACE-ID header is required"}.
{
"errors": "WORKSPACE-ID header is required"
} -
A value that isn’t a UUID at all, such as the numeric workspace ID from an app URL or a UUID with a character missing, returns HTTP 404 with the body
{"errors":"WORKSPACE-ID must be the workspace UUID shown in the app's API settings; numeric workspace ids are not accepted"}. Send the workspace’sidfromworkspacesinstead. -
An unknown workspace, or one your token can’t access, returns HTTP 404 with the body
{"errors":"Shop not found"}.
{
"errors": "Shop not found"
} Iterating across workspaces
With an organization-wide token:
- List accessible workspaces with
workspaces. - Set
WORKSPACE-IDto the first workspace’sidand run your queries. - Repeat for each workspace, changing the header and keeping the same bearer token.
When making concurrent requests, set the workspace header on each request to avoid mixing workspaces.
For the full error model, see the Errors guide.