Skip to main content
GET
/
api
/
v1
/
workspaces
/
{id}
/
tokensets
List Workspace Tokensets
curl --request GET \
  --url https://app.tokencraft.dev/api/v1/api/v1/workspaces/{id}/tokensets \
  --header 'Authorization: Bearer <token>'

List Workspace Tokensets

Retrieves all tokensets within a specific workspace.

Endpoint

GET /api/v1/workspaces/{id}/tokensets

Authentication

Requires a valid API token in the Authorization header.

Request

Headers

HeaderValueRequired
AuthorizationBearer tokenYes

Path Parameters

ParameterTypeRequiredDescription
idstringYesWorkspace ID

Response

Success Response

Status: 200 OK
{
  "tokensets": [
    {
      "id": "tokenset-123",
      "workspace_id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Colors",
      "description": "Color tokens for the design system",
      "created_at": "2025-01-15T10:00:00Z",
      "updated_at": "2025-01-15T10:00:00Z"
    },
    {
      "id": "tokenset-456",
      "workspace_id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Typography",
      "description": "Font and text tokens",
      "created_at": "2025-01-15T10:05:00Z",
      "updated_at": "2025-01-16T14:30:00Z"
    }
  ],
  "total": 2
}

Response Fields

FieldTypeDescription
tokensetsarrayArray of tokenset objects
totalnumberTotal number of tokensets

Tokenset Object

FieldTypeDescription
idstringUnique tokenset identifier
workspace_idstringParent workspace ID
namestringTokenset name
descriptionstring|nullOptional description
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Examples

curl -H "Authorization: Bearer dtk_your_token_here" \
  https://app.tokencraft.dev/api/v1/workspaces/550e8400-e29b-41d4-a716-446655440000/tokensets

Error Responses

401 Unauthorized

{
  "error": "Invalid API token"
}

404 Not Found

{
  "error": "Workspace not found"
}

500 Internal Server Error

{
  "error": "Internal server error"
}

Use Cases

1. Build Navigation

Create a navigation menu:
async function buildTokensetsNav(workspaceId) {
  const { tokensets } = await getWorkspaceTokensets(workspaceId);
  
  return tokensets.map(ts => ({
    label: ts.name,
    href: `/tokensets/${ts.id}`,
    icon: getIconForTokenset(ts.name)
  }));
}

2. Export All Tokensets

Download all tokensets in a workspace:
async function exportWorkspace(workspaceId) {
  const { tokensets } = await getWorkspaceTokensets(workspaceId);
  
  for (const tokenset of tokensets) {
    const tokens = await exportTokenset(tokenset.id);
    saveToFile(`${tokenset.name}.json`, tokens);
  }
}

3. Analytics

Track tokenset count:
const { total } = await getWorkspaceTokensets(workspaceId);
console.log(`Workspace has ${total} tokensets`);

Next Steps