Skip to main content
POST
/
api
/
v1
/
labels
curl -X POST https://api.jasni.ai/api/v1/labels \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Urgent",
    "color": "#ef4444",
    "description": "Requires immediate attention"
  }'
{
  "success": true,
  "data": {
    "label": {
      "id": "550e8400-e29b-41d4-a716-446655440002",
      "name": "Urgent",
      "color": "#ef4444",
      "description": "Requires immediate attention",
      "created_at": "2024-01-15T11:00:00Z"
    }
  },
  "message": "Label created successfully"
}

Request Body

name
string
required
Label name (1-50 characters)
color
string
Hex color code (e.g., #ff0000). If not provided, a random color is assigned.
description
string
Optional description for the label

Response

success
boolean
Indicates if the label was created successfully
data
object
message
string
Success message
curl -X POST https://api.jasni.ai/api/v1/labels \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Urgent",
    "color": "#ef4444",
    "description": "Requires immediate attention"
  }'
{
  "success": true,
  "data": {
    "label": {
      "id": "550e8400-e29b-41d4-a716-446655440002",
      "name": "Urgent",
      "color": "#ef4444",
      "description": "Requires immediate attention",
      "created_at": "2024-01-15T11:00:00Z"
    }
  },
  "message": "Label created successfully"
}

Validation

Name

  • Required
  • 1-50 characters
  • Must be unique per user

Color

  • Optional (random color assigned if not provided)
  • Must be valid hex format: #RRGGBB
  • Examples: #ff0000 (red), #00ff00 (green), #0000ff (blue)

Default Color Palette

If no color is specified, one of these colors is randomly assigned:
ColorHex
Indigo#6366f1
Violet#8b5cf6
Purple#a855f7
Fuchsia#d946ef
Pink#ec4899
Red#ef4444
Orange#f97316
Amber#f59e0b
Green#22c55e
Cyan#0ea5e9

Use Cases

AI Classification Labels

Create labels for your AI agent to classify emails:
const classificationLabels = [
  { name: 'Support Request', color: '#3b82f6' },
  { name: 'Sales Inquiry', color: '#22c55e' },
  { name: 'Partnership', color: '#8b5cf6' },
  { name: 'Spam', color: '#ef4444' },
  { name: 'Needs Review', color: '#f59e0b' },
];

for (const label of classificationLabels) {
  await fetch('https://api.jasni.ai/api/v1/labels', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer jsk_your_api_key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(label),
  });
}

Priority Labels

const priorityLabels = [
  { name: 'P1 - Critical', color: '#dc2626', description: 'Respond within 1 hour' },
  { name: 'P2 - High', color: '#f97316', description: 'Respond within 4 hours' },
  { name: 'P3 - Normal', color: '#eab308', description: 'Respond within 24 hours' },
  { name: 'P4 - Low', color: '#22c55e', description: 'Respond within 1 week' },
];