API

Workspaces and collections

List your workspaces and their collections to get the IDs every record call needs.

Record paths need a workspace ID and a collection ID. These two calls give you both. Every example sends the token from Authentication.

List workspaces

GET /api/v1/workspaces

curl 'http://127.0.0.1:8080/api/v1/workspaces' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
const res = await fetch('http://127.0.0.1:8080/api/v1/workspaces', {
	headers: { Authorization: `Bearer ${token}` }
});
const { data: workspaces } = await res.json();
req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/api/v1/workspaces", nil)
req.Header.Set("Authorization", "Bearer "+token)
res, err := http.DefaultClient.Do(req)
res = requests.get(
    "http://127.0.0.1:8080/api/v1/workspaces",
    headers={"Authorization": f"Bearer {token}"},
)
workspaces = res.json()["data"]

Response:

{
	"data": [
		{
			"id": "1d6035d32788a9046a1e3209059e00a3",
			"name": "Acme CRM",
			"role": "owner",
			"role_name": "Owner",
			"capabilities": [
				"admin_access",
				"manage_members",
				"manage_roles",
				"manage_schema",
				"read_system",
				"write_records"
			],
			"collection_count": 7,
			"member_count": 1
		}
	],
	"meta": { "request_id": "...", "response_time": 2.1 }
}

capabilities tells you what your role may do there. Without write_records you can only read.

List collections

GET /api/v1/workspaces/:workspace/collections

curl 'http://127.0.0.1:8080/api/v1/workspaces/YOUR_WORKSPACE_ID/collections' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
const res = await fetch(`http://127.0.0.1:8080/api/v1/workspaces/${workspaceId}/collections`, {
	headers: { Authorization: `Bearer ${token}` }
});
const { data: collections } = await res.json();
req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/api/v1/workspaces/"+workspaceID+"/collections", nil)
req.Header.Set("Authorization", "Bearer "+token)
res, err := http.DefaultClient.Do(req)
res = requests.get(
    f"http://127.0.0.1:8080/api/v1/workspaces/{workspace_id}/collections",
    headers={"Authorization": f"Bearer {token}"},
)
collections = res.json()["data"]

Each collection includes its fields and what you may do with its records:

{
	"id": "6827046ffd8a5b4f737360bf4348139b",
	"workspace_id": "1d6035d32788a9046a1e3209059e00a3",
	"name": "deals",
	"state": "ready",
	"primary_key_kind": "hex32",
	"access": { "read": true, "create": true, "update": true, "delete": true },
	"fields": [
		{
			"id": "44e5cd49ad31b2da7a4ac5decb08a201",
			"name": "title",
			"type": "string",
			"required": true,
			"read_only": false
		}
	]
}

Use the collection id in record paths. The collection name does not work there.

Next steps

Buy me a coffee