HiveJournal API Documentation
This document describes the REST API endpoints for HiveJournal, designed to be consumed by both the web frontend and iOS app.
Base URL
- Development:
http://localhost:3001 - Production:
https://api.hivejournal.com(or your Railway backend URL)
Authentication
All protected endpoints require a Bearer token in the Authorization header:
Authorization: Bearer <supabase_access_token>
Endpoints
Health Check
GET /health
Check if the API is running.
Response:
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z"
}
Authentication
POST /api/auth/verify
Verify a Supabase access token.
Request Body:
{
"token": "supabase_access_token"
}
Response:
{
"user": {
"id": "user_uuid",
"email": "user@example.com"
}
}
Journal Entries
GET /api/journal
Get all journal entries for the authenticated user.
Headers:
Authorization: Bearer <token>
Response:
{
"entries": [
{
"id": "uuid",
"user_id": "uuid",
"title": "My Entry",
"content": "Entry content...",
"mood": "happy",
"tags": ["tag1", "tag2"],
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}
]
}
GET /api/journal/:id
Get a single journal entry.
Headers:
Authorization: Bearer <token>
Response:
{
"entry": {
"id": "uuid",
"user_id": "uuid",
"title": "My Entry",
"content": "Entry content...",
"mood": "happy",
"tags": ["tag1"],
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}
}
POST /api/journal
Create a new journal entry.
Headers:
Authorization: Bearer <token>
Request Body:
{
"title": "My Entry",
"content": "Entry content...",
"mood": "happy",
"tags": ["tag1", "tag2"]
}
Response:
{
"entry": {
"id": "uuid",
"user_id": "uuid",
"title": "My Entry",
"content": "Entry content...",
"mood": "happy",
"tags": ["tag1", "tag2"],
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}
}
PUT /api/journal/:id
Update a journal entry.
Headers:
Authorization: Bearer <token>
Request Body:
{
"title": "Updated Title",
"content": "Updated content...",
"mood": "sad",
"tags": ["tag1"]
}
DELETE /api/journal/:id
Delete a journal entry.
Headers:
Authorization: Bearer <token>
Response:
{
"message": "Entry deleted successfully"
}
Accountability Goals
GET /api/goals
Get all goals for the authenticated user.
Headers:
Authorization: Bearer <token>
Response:
{
"goals": [
{
"id": "uuid",
"user_id": "uuid",
"title": "My Goal",
"description": "Goal description",
"target_date": "2024-12-31",
"status": "active",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}
]
}
GET /api/goals/:id
Get a single goal with check-ins.
Headers:
Authorization: Bearer <token>
POST /api/goals
Create a new goal.
Headers:
Authorization: Bearer <token>
Request Body:
{
"title": "My Goal",
"description": "Goal description",
"target_date": "2024-12-31"
}
PUT /api/goals/:id
Update a goal.
Headers:
Authorization: Bearer <token>
DELETE /api/goals/:id
Delete a goal.
Headers:
Authorization: Bearer <token>
POST /api/goals/:id/check-ins
Create a check-in for a goal.
Headers:
Authorization: Bearer <token>
Request Body:
{
"status": "completed",
"notes": "Made good progress today"
}
User Profile
GET /api/user/profile
Get user profile.
Headers:
Authorization: Bearer <token>
PUT /api/user/profile
Update user profile.
Headers:
Authorization: Bearer <token>
Request Body:
{
"full_name": "John Doe",
"avatar_url": "https://...",
"preferences": {
"theme": "dark",
"notifications": true
}
}
Payments
POST /api/payment/create-checkout-session
Create a Stripe checkout session.
Headers:
Authorization: Bearer <token>
Request Body:
{
"priceId": "price_xxx",
"successUrl": "https://hivejournal.com/dashboard?success=true",
"cancelUrl": "https://hivejournal.com/dashboard?canceled=true"
}
Response:
{
"sessionId": "cs_xxx",
"url": "https://checkout.stripe.com/..."
}
GET /api/payment/subscription
Get subscription status.
Headers:
Authorization: Bearer <token>
Response:
{
"subscription": {
"id": "uuid",
"user_id": "uuid",
"stripe_customer_id": "cus_xxx",
"stripe_subscription_id": "sub_xxx",
"status": "active",
"created_at": "2024-01-01T00:00:00.000Z"
}
}
POST /api/payment/webhook
Stripe webhook endpoint (no authentication required, uses Stripe signature verification).
POST /api/email/send
Send an email via Resend.
Headers:
Authorization: Bearer <token>
Request Body:
{
"to": "user@example.com",
"subject": "Email Subject",
"html": "<p>Email content</p>",
"text": "Email content"
}
POST /api/email/webhook
Resend webhook endpoint for incoming emails (no authentication required).
Error Responses
All errors follow this format:
{
"error": "Error message"
}
Status Codes:
400- Bad Request401- Unauthorized404- Not Found500- Internal Server Error
iOS App Integration
For iOS app integration:
- Use Supabase Auth SDK to authenticate users
- Get the access token from Supabase
- Include the token in the
Authorizationheader for all API requests - Handle token refresh when tokens expire
- Implement proper error handling and retry logic
Example iOS request:
let url = URL(string: "https://api.hivejournal.com/api/journal")!
var request = URLRequest(url: url)
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"