Skip to main content

Overview

This guide walks you through making your first API call to Day Copilot, from obtaining credentials to handling the response. By the end, you’ll have created your first task via the API.
Estimated time: 10 minutes

Prerequisites

Before you begin, you need:
  1. A Day Copilot account - Sign up here
  2. An HTTP client:

Step 1: Get Your Authentication Token

Via Dashboard

  1. Log in to Day Copilot
  2. Navigate to Settings β†’ API Tokens
  3. Click Generate New Token
  4. Copy the token (it will only be shown once!)
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLXV1aWQifQ...
Keep your token secret! Never commit it to version control or share it publicly. Treat it like a password.

Store Your Token Securely

# Set as environment variable
export DAY_COPILOT_TOKEN="your-token-here"

Step 2: Make Your First Request

Let’s fetch your existing tasks to verify authentication works.
curl -X GET "https://app.daycopilot.ai/api/v1/tasks" \
  -H "Authorization: Bearer $DAY_COPILOT_TOKEN" \
  -H "Content-Type: application/json"

Expected Response

{
  "data": [],
  "meta": {
    "pagination": {
      "limit": 50,
      "offset": 0,
      "total": 0,
      "hasMore": false
    }
  }
}
If you get an empty array, that’s perfect! It means authentication worked and you just don’t have any tasks yet.

Step 3: Create Your First Task

Now let’s create a task:
curl -X POST "https://app.daycopilot.ai/api/v1/tasks" \
  -H "Authorization: Bearer $DAY_COPILOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My First API Task",
    "description": "Created using the Day Copilot API",
    "priority": "medium",
    "status": "pending"
  }'

Success Response

{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "title": "My First API Task",
    "description": "Created using the Day Copilot API",
    "priority": "medium",
    "status": "pending",
    "created_at": "2025-11-02T12:00:00Z",
    "updated_at": "2025-11-02T12:00:00Z",
    "user_id": "your-user-uuid",
    "version_major": 1,
    "version_minor": 0,
    "is_published": true
  }
}
Key Fields:
  • id: Unique identifier for this task
  • created_at: ISO 8601 timestamp
  • version_major/minor: Versioning info
  • is_published: Whether task is published (new tasks are auto-published)

Step 4: Retrieve Your Task

Use the id from the creation response to fetch your task:
# Replace {taskId} with actual ID from previous step
curl -X GET "https://app.daycopilot.ai/api/v1/tasks/{taskId}" \
  -H "Authorization: Bearer $DAY_COPILOT_TOKEN"

Step 5: Update Your Task

Let’s change the priority to high:
curl -X PUT "https://app.daycopilot.ai/api/v1/tasks/{taskId}" \
  -H "Authorization: Bearer $DAY_COPILOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "priority": "high"
  }'

Step 6: Complete Your Task

Mark the task as completed:
curl -X POST "https://app.daycopilot.ai/api/v1/tasks/{taskId}/complete" \
  -H "Authorization: Bearer $DAY_COPILOT_TOKEN"

Common Errors & Solutions

401 Unauthorized

{
  "error": "Unauthorized",
  "message": "Missing or invalid authentication token",
  "status": 401
}
Solutions:
  • Check token is valid (not expired)
  • Verify Authorization: Bearer TOKEN format
  • Ensure token has no extra whitespace

404 Not Found

{
  "error": "Not Found",
  "message": "Task with ID abc-123 does not exist",
  "status": 404
}
Solutions:
  • Verify task ID is correct
  • Check task wasn’t deleted
  • Confirm you have access to this task (RLS)

429 Rate Limited

{
  "error": "Rate limit exceeded",
  "message": "Too many requests",
  "status": 429,
  "retryAfter": 60
}
Solutions:
  • Wait retryAfter seconds before retry
  • Implement exponential backoff
  • Review rate limits

Next Steps: Full CRUD Example

Here’s a complete script demonstrating all operations:
const TOKEN = process.env.DAY_COPILOT_TOKEN;
const BASE_URL = 'https://app.daycopilot.ai/api/v1';

async function makeRequest(method, endpoint, body = null) {
  const options = {
    method,
    headers: {
      'Authorization': `Bearer ${TOKEN}`,
      'Content-Type': 'application/json'
    }
  };

  if (body) {
    options.body = JSON.stringify(body);
  }

  const response = await fetch(`${BASE_URL}${endpoint}`, options);

  if (!response.ok) {
    const error = await response.json();
    throw new Error(`API Error: ${error.message}`);
  }

  return response.json();
}

async function main() {
  try {
    // Create
    console.log('Creating task...');
    const created = await makeRequest('POST', '/tasks', {
      title: 'Learn Day Copilot API',
      priority: 'high'
    });
    const taskId = created.data.id;
    console.log('βœ“ Created:', taskId);

    // Read
    console.log('\nReading task...');
    const task = await makeRequest('GET', `/tasks/${taskId}`);
    console.log('βœ“ Retrieved:', task.data.title);

    // Update
    console.log('\nUpdating task...');
    await makeRequest('PUT', `/tasks/${taskId}`, {
      status: 'in_progress'
    });
    console.log('βœ“ Updated to in_progress');

    // Complete
    console.log('\nCompleting task...');
    await makeRequest('POST', `/tasks/${taskId}/complete`);
    console.log('βœ“ Completed');

    // Delete
    console.log('\nDeleting task...');
    await makeRequest('DELETE', `/tasks/${taskId}`);
    console.log('βœ“ Deleted');

  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

Testing in Postman

  1. Import Collection: Download Day Copilot Postman Collection
  2. Set Environment Variable:
    • Key: DAY_COPILOT_TOKEN
    • Value: Your token
  3. Run Requests: Try each endpoint in the collection

Congratulations! πŸŽ‰

You’ve successfully:
  • βœ… Authenticated with Day Copilot API
  • βœ… Created a task
  • βœ… Retrieved task data
  • βœ… Updated a task
  • βœ… Completed a task

What’s Next?