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:
- A Day Copilot account - Sign up here
- An HTTP client:
Step 1: Get Your Authentication Token
Via Dashboard
- Log in to Day Copilot
- Navigate to Settings β API Tokens
- Click Generate New Token
- 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
- Import Collection: Download Day Copilot Postman Collection
- Set Environment Variable:
- Key:
DAY_COPILOT_TOKEN
- Value: Your token
- 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?