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 ( ' \n Reading task...' );
const task = await makeRequest ( 'GET' , `/tasks/ ${ taskId } ` );
console . log ( 'โ Retrieved:' , task . data . title );
// Update
console . log ( ' \n Updating task...' );
await makeRequest ( 'PUT' , `/tasks/ ${ taskId } ` , {
status: 'in_progress'
});
console . log ( 'โ Updated to in_progress' );
// Complete
console . log ( ' \n Completing task...' );
await makeRequest ( 'POST' , `/tasks/ ${ taskId } /complete` );
console . log ( 'โ Completed' );
// Delete
console . log ( ' \n Deleting 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?
Managing Tasks Learn advanced task management techniques
Working with Events Create and manage calendar events
Error Handling Handle errors gracefully in production
API Reference Explore all available endpoints