Skip to main content

Overview

Retrieve and update the authenticated user’s profile information.

Authentication

Requires Auth0 authentication. Users can only access and update their own profile.

Get User Profile

GET /user/
Retrieve the authenticated user’s complete profile information.

Response

auth0_user_id
string
User’s Auth0 ID (primary key)
email
string
User’s email address
name
string
User’s display name
image_url
string | null
URL of the user’s profile image stored in Google Cloud Storage
home_address
string | null
User’s home address
home_coords
string | null
Coordinates of the user’s home location
work_address
string | null
User’s work address
work_coords
string | null
Coordinates of the user’s work location
date_registered
string
ISO 8601 timestamp of when the user registered

Example

cURL
curl -X GET "https://api.cyclemate.com/user/" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response (200 OK)

{
  "auth0_user_id": "auth0|123456",
  "email": "john.doe@example.com",
  "name": "John Doe",
  "image_url": "https://storage.googleapis.com/cyclemate-images/users/profile-123456.jpg",
  "home_address": "123 Main St, San Francisco, CA",
  "home_coords": "-122.4194,37.7749",
  "work_address": "456 Market St, San Francisco, CA",
  "work_coords": "-122.3988,37.7911",
  "date_registered": "2024-01-15T10:00:00Z"
}

Error Responses

404 Not Found - User not found
{
  "error": "User not found"
}

Update User Profile

PATCH /user/
Update one or more fields in the authenticated user’s profile. This is a partial update - only include the fields you want to change.

Request Body

All fields are optional. Only include the fields you want to update.
name
string
User’s display name
image_url
string | null
URL of the user’s profile image. Use POST /user/upload-photo/ to upload a new image.
home_address
string | null
User’s home address
home_coords
string | null
Coordinates of the user’s home location (format: “longitude,latitude”)
work_address
string | null
User’s work address
work_coords
string | null
Coordinates of the user’s work location (format: “longitude,latitude”)

Response

status
string
Status of the update operation (“success”)
updated_fields
array
List of field names that were updated

Example

cURL
curl -X PATCH "https://api.cyclemate.com/user/" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "home_address": "789 Oak St, San Francisco, CA",
    "home_coords": "-122.4500,37.7600"
  }'

Success Response (200 OK)

{
  "status": "success",
  "updated_fields": ["name", "home_address", "home_coords"]
}

Error Responses

400 Bad Request - Invalid JSON or validation error
{
  "error": "Invalid JSON"
}
{
  "email": ["Enter a valid email address."]
}
404 Not Found - User not found
{
  "error": "User not found"
}

Notes

  • The auth0_user_id, email, and date_registered fields are read-only and cannot be updated
  • All address and coordinate fields are optional and can be set to null
  • For uploading profile photos, use the dedicated POST /user/upload-photo/ endpoint which handles image upload to GCS and automatically updates the image_url field
  • Coordinate format should be “longitude,latitude” as a string

  • POST /user/upload-photo/ - Upload a profile photo
  • GET /user/stats/ - Get user statistics
  • GET /user/routes/ - Get user’s route history