Skip to main content
GET
/
api
/
v1
/
tokensets
/
{id}
/
modes
/
{modeId}
/
tokens
/
{tokenId}
Get Token
curl --request GET \
  --url https://app.tokencraft.dev/api/v1/api/v1/tokensets/{id}/modes/{modeId}/tokens/{tokenId} \
  --header 'Authorization: Bearer <token>'

Get Token

Retrieves a specific design token by its unique identifier within a mode.

Endpoint

GET /api/v1/tokensets/{id}/modes/{modeId}/tokens/{tokenId}

Request

Path Parameters

ParameterTypeRequiredDescription
idstringYesTokenset ID
modeIdstringYesMode ID
tokenIdstringYesToken ID returned by the list tokens endpoints
To look up a tokenId, call List Tokens or Get Tokenset Tokens and use the id field from the response.

Response

Status: 200 OK
{
  "id": "token-1",
  "tokenset_id": "tokenset-123",
  "mode_id": "mode-light",
  "name": "colors.primary.500",
  "type": "color",
  "value": "#3b82f6",
  "description": "Primary brand color",
  "alias_to": null,
  "resolved_value": "#3b82f6",
  "created_at": "2025-01-15T10:00:00Z",
  "updated_at": "2025-01-15T10:00:00Z"
}

Special Fields

FieldDescription
resolved_valueIf token is an alias, this contains the final resolved value
alias_toIf set, this token references another token

Token with Alias

{
  "name": "colors.button.primary",
  "type": "color",
  "value": null,
  "alias_to": "colors.primary.500",
  "resolved_value": "#3b82f6"
}

Examples

curl -H "Authorization: Bearer dtk_your_token_here" \
  "https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes/mode-light/tokens/token-1"

Error Responses

404 Not Found

{
  "error": "Token not found"
}
Causes:
  • Token ID doesn’t exist in this mode
  • Token was deleted
  • Token belongs to a different tokenset or mode

Use Cases

1. Token Details View

Show full token information:
async function TokenDetails({ tokensetId, modeId, tokenId }) {
  const token = await getToken(tokensetId, modeId, tokenId);
  
  return (
    <div>
      <h2>{token.name}</h2>
      <p>Type: {token.type}</p>
      <p>Value: {token.resolved_value || token.value}</p>
      {token.description && <p>{token.description}</p>}
      {token.alias_to && <p>References: {token.alias_to}</p>}
    </div>
  );
}

2. Token Validation

Check if token exists:
async function tokenExists(tokensetId, modeId, tokenId) {
  try {
    await getToken(tokensetId, modeId, tokenId);
    return true;
  } catch (error) {
    if (error.status === 404) return false;
    throw error;
  }
}

3. Resolve Alias Chain

Follow alias references:
async function resolveToken(tokensetId, modeId, tokenId) {
  const token = await getToken(tokensetId, modeId, tokenId);
  return token.resolved_value || token.value;
}

Next Steps