Update Workspace
Updates an existing workspace. Only provided fields will be updated.
PRO Plan Required - This endpoint requires a PRO or TEAM subscription plan. API write access is not available on the FREE plan.
Endpoint
PATCH /api/v1/workspaces/{id}
Authentication
Requires a valid API token in the Authorization header.
Request
| Header | Value | Required |
|---|
Authorization | Bearer token | Yes |
Content-Type | application/json | Yes |
Path Parameters
| Parameter | Type | Required | Description |
|---|
id | string | Yes | Workspace ID |
Body Parameters
| Parameter | Type | Required | Description |
|---|
name | string | No | New workspace name (max 255 characters) |
description | string | No | New description (null to remove) |
All body parameters are optional. Only provided fields will be updated.
Request Body
{
"name": "Updated Design System",
"description": "Updated description"
}
Response
Success Response
Status: 200 OK
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Updated Design System",
"description": "Updated description",
"user_id": "user-123",
"created_at": "2025-01-15T10:00:00Z",
"updated_at": "2025-01-15T14:30:00Z"
}
Examples
curl -X PATCH https://app.tokencraft.dev/api/v1/workspaces/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer dtk_your_token_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Design System"
}'
Error Responses
400 Bad Request
{
"error": "Name must be a non-empty string"
}
Causes:
- Empty
name field
name exceeds 255 characters
- Invalid field types
401 Unauthorized
{
"error": "Invalid API token"
}
404 Not Found
{
"error": "Workspace not found"
}
Causes:
- Workspace ID doesn’t exist
- Workspace belongs to a different user
Validation Rules
- name: If provided, must be non-empty string, max 255 characters
- description: If provided, must be string or null
Use Cases
1. Rename Workspace
await updateWorkspace(id, { name: 'New Name' });
2. Update Description
await updateWorkspace(id, {
description: 'Updated project description'
});
3. Remove Description
await updateWorkspace(id, { description: null });
Next Steps