API Overview
Habito provides a comprehensive REST API for building integrations, automations, and custom tools. Access all features programmatically using standard HTTP methods and JSON payloads.
Base URL
All API requests are made to:
https://habito.ar/api
Authentication
API requests require authentication using an API key. Generate keys from your profile page.
Header Format:
Authorization: Bearer YOUR_API_KEY_HERE
Example request:
curl https://habito.ar/api/me \
-H "Authorization: Bearer hab_your_api_key_here"
Rate Limits
API requests are rate limited to prevent abuse:
- 100 requests per minute per API key
- 1,000 requests per hour per API key
- 10,000 requests per day per API key
Rate limit headers are included in responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1609459200
Response Format
All responses use JSON format with consistent structure.
Success Response:
{
"data": {
"id": "uuid",
"name": "Example",
// ... resource fields
}
}
List Response:
{
"data": [
{ "id": "1", "name": "Item 1" },
{ "id": "2", "name": "Item 2" }
],
"meta": {
"total": 2,
"page": 1,
"perPage": 20
}
}
Error Response:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Title is required",
"details": {
"field": "title",
"rule": "required"
}
}
}
HTTP Status Codes
| Code | Meaning | When Used |
|---|---|---|
| 200 | OK | Successful GET, PATCH request |
| 201 | Created | Successful POST request |
| 204 | No Content | Successful DELETE request |
| 400 | Bad Request | Invalid request payload |
| 401 | Unauthorized | Missing or invalid API key |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource doesn't exist |
| 422 | Unprocessable Entity | Validation failed |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error |
API Endpoints
User & Profile
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/me | Get authenticated user |
Tasks
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks | List tasks |
| POST | /api/tasks | Create task |
| GET | /api/tasks/:id | Get task details |
| PATCH | /api/tasks/:id | Update task |
| DELETE | /api/tasks/:id | Archive task |
| POST | /api/tasks/:id/complete | Complete task |
Teams
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/teams | List teams |
| POST | /api/teams | Create team |
| GET | /api/teams/:id | Get team details |
| POST | /api/teams/join | Join team |
| DELETE | /api/teams/:id/leave | Leave team |
Projects
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/projects | List projects |
| POST | /api/projects | Create project |
| GET | /api/projects/:id | Get project details |
| PATCH | /api/projects/:id | Update project |
Issues
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks | List issues |
| POST | /api/tasks | Create issue |
| GET | /api/tasks/:id | Get issue details |
| PATCH | /api/tasks/:id | Update issue |
| GET | /api/tasks/search | Search issues |
Comments
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/tasks/:id/comments | Create comment |
| PATCH | /api/tasks/:id/comments/:commentId | Edit comment |
| DELETE | /api/tasks/:id/comments/:commentId | Delete comment |
Pagination
List endpoints support pagination using query parameters:
GET /api/tasks?page=2&limit=50
Parameters:
page: Page number (default: 1)limit: Items per page (default: 20, max: 100)
Response includes pagination metadata:
{
"data": [...],
"meta": {
"total": 150,
"page": 2,
"perPage": 50,
"totalPages": 3
}
}
Filtering
Many endpoints support filtering via query parameters:
GET /api/tasks?type=habit&difficulty=medium
GET /api/tasks?status=in_progress&priority=high
GET /api/projects?teamId=uuid
Sorting
Sort results using the sort parameter:
GET /api/tasks?sort=-createdAt
GET /api/tasks?sort=priority,-updatedAt
Sort syntax:
- Field name: ascending order (
sort=name) -prefix: descending order (sort=-createdAt)- Multiple fields: comma-separated (
sort=priority,-createdAt)
Timestamps
All timestamps use ISO 8601 format in UTC:
{
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-20T14:45:30.000Z"
}
Webhooks (Coming Soon)
Subscribe to events and receive HTTP callbacks when they occur:
task.completedlevel.upstreak.milestoneissue.createdissue.updated
SDKs (Coming Soon)
Official client libraries:
- JavaScript/TypeScript
- Python
- Go
- Ruby
Examples
Create a Task
curl -X POST https://habito.ar/api/tasks \
-H "Authorization: Bearer hab_your_key" \
-H "Content-Type: application/json" \
-d '{
"title": "Morning workout",
"type": "habit",
"difficulty": "medium",
"isPositive": true
}'
Complete a Task
curl -X POST https://habito.ar/api/tasks/uuid/complete \
-H "Authorization: Bearer hab_your_key"
Create an Issue
curl -X POST https://habito.ar/api/tasks \
-H "Authorization: Bearer hab_your_key" \
-H "Content-Type: application/json" \
-d '{
"projectId": "project-uuid",
"title": "Add dark mode",
"priority": "high",
"status": "todo"
}'
Search Issues
curl "https://habito.ar/api/tasks/search?q=authentication&projectId=uuid" \
-H "Authorization: Bearer hab_your_key"
Error Handling
Handle errors gracefully in your applications:
try {
const response = await fetch('https://habito.ar/api/tasks', {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(taskData)
})
if (!response.ok) {
const error = await response.json()
console.error('API Error:', error)
// Handle specific error codes
if (response.status === 401) {
// Invalid API key
} else if (response.status === 422) {
// Validation error
}
}
const data = await response.json()
return data
} catch (error) {
console.error('Network error:', error)
}
Best Practices
- Cache responses when data doesn't change frequently
- Batch requests to minimize API calls
- Handle rate limits gracefully with exponential backoff
- Validate data before sending to avoid 422 errors
- Store API keys securely in environment variables
- Use webhooks instead of polling (when available)
- Implement retries for transient errors (500, 503)
Next Steps
- Authentication - Detailed auth guide
- Tasks API - Task endpoints reference
- Projects API - Project & issue endpoints
- MCP Integration - Use AI assistants with Habito