Skip to main content
POST
/
api
/
v1
/
tokensets
/
{id}
/
modes
Create Mode
curl --request POST \
  --url https://app.tokencraft.dev/api/v1/api/v1/tokensets/{id}/modes \
  --header 'Authorization: Bearer <token>'

Create Mode

Creates a new mode (theme variation) within a tokenset.
PRO Plan Required - This endpoint requires a PRO or TEAM subscription plan. API write access is not available on the FREE plan.

Endpoint

POST /api/v1/tokensets/{id}/modes

Authentication

Requires a valid API token in the Authorization header.

Request

Headers

HeaderValueRequired
AuthorizationBearer tokenYes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
idstringYesTokenset ID

Body Parameters

ParameterTypeRequiredDescription
namestringYesMode name (max 255 characters)
is_defaultbooleanNoWhether this mode is the default (default: false)
If is_default is true, all other modes in this tokenset will be set to non-default.

Request Body

{
  "name": "Dark",
  "is_default": false
}

Response

Success Response

Status: 201 Created
{
  "id": "mode-dark",
  "tokenset_id": "tokenset-123",
  "name": "Dark",
  "is_default": false,
  "created_at": "2025-01-15T10:00:00Z",
  "updated_at": "2025-01-15T10:00:00Z"
}

Examples

curl -X POST https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes \
  -H "Authorization: Bearer dtk_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Light",
    "is_default": true
  }'

Error Responses

400 Bad Request

{
  "error": "Name is required and must be a non-empty string"
}
{
  "error": "is_default must be a boolean"
}

404 Not Found

{
  "error": "Tokenset not found"
}

Common Mode Names

Theme Variations

  • Light
  • Dark
  • High Contrast

Platform Variations

  • Web
  • Mobile
  • Desktop

Brand Variations

  • Primary Brand
  • Secondary Brand

Context Variations

  • Marketing
  • Product
  • Admin

Use Cases

1. Create Light/Dark Themes

async function setupThemes(tokensetId) {
  const light = await createMode(tokensetId, {
    name: 'Light',
    is_default: true
  });
  
  const dark = await createMode(tokensetId, {
    name: 'Dark'
  });
  
  return { light, dark };
}

2. Create Multi-Platform Modes

const platforms = ['Web', 'iOS', 'Android'];

for (const platform of platforms) {
  await createMode(tokensetId, {
    name: platform,
    is_default: platform === 'Web'
  });
}

Default Mode Behavior

When setting a mode as default:
  1. The new mode’s is_default is set to true
  2. All other modes in the tokenset are set to is_default: false
  3. Only one mode can be default per tokenset

Next Steps