Overview
The Household API enables you to manage household membership, including initialization, inviting members, accepting/declining invitations, and managing member roles.
Endpoints
Initialize Household
Gets or creates a household for the authenticated user.
Authentication : Required
Response
The ID of the user’s household (created if it doesn’t exist)
curl -X GET https://your-domain.com/api/household/init \
-H "Authorization: Bearer YOUR_CLERK_TOKEN"
Example Response
{
"householdId" : "clx456def"
}
This endpoint calls getOrCreateHousehold(userId, email) which automatically creates a household if the user doesn’t have one.
Get Household Members
GET /api/household/members
Retrieves all members of the user’s household, including pending invitations.
Authentication : Required
Response
Array of household member objects
User ID of the household owner (first owner by ID)
Email address of the household owner
Show Member Object Fields
Clerk user ID (null for pending invitations)
Email of invited user (null for accepted members)
Member role: “owner”, “member”, or “guest”
Status: “accepted” or “pending”
Display name (fetched from Clerk or email)
When the member was added
curl -X GET https://your-domain.com/api/household/members \
-H "Authorization: Bearer YOUR_CLERK_TOKEN"
Example Response
{
"members" : [
{
"id" : "clxmem1" ,
"householdId" : "clx456def" ,
"userId" : "user_abc123" ,
"invitedEmail" : null ,
"role" : "owner" ,
"status" : "accepted" ,
"name" : "John Doe" ,
"createdAt" : "2024-03-01T10:00:00Z"
},
{
"id" : "clxmem2" ,
"householdId" : "clx456def" ,
"userId" : "user_xyz789" ,
"invitedEmail" : null ,
"role" : "member" ,
"status" : "accepted" ,
"name" : "Sarah Smith" ,
"createdAt" : "2024-03-05T14:30:00Z"
},
{
"id" : "clxmem3" ,
"householdId" : "clx456def" ,
"userId" : null ,
"invitedEmail" : "[email protected] " ,
"role" : "member" ,
"status" : "pending" ,
"name" : "[email protected] " ,
"createdAt" : "2024-03-10T09:00:00Z"
}
],
"trueOwnerId" : "user_abc123" ,
"trueOwnerEmail" : "[email protected] "
}
Manage Household Members
POST /api/household/members
Multi-purpose endpoint for inviting members, updating roles, and removing members.
Authentication : Required
Request Body (Invite Member)
Request Body (Update Role)
Request Body (Remove Member)
Request Body (Self-Removal)
Invite Member
Update Role
Remove Member
Leave Household
Invite Member
curl -X POST https://your-domain.com/api/household/members \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected] "}'
Response (Invite)
{
"id" : "clxmem4" ,
"householdId" : "clx456def" ,
"invitedEmail" : "[email protected] " ,
"role" : "member" ,
"status" : "pending" ,
"createdAt" : "2024-03-15T12:00:00Z"
}
If already invited:
{
"message" : "Already invited"
}
Response (Update Role)
{
"message" : "Role updated"
}
Response (Remove)
{
"message" : "Member removed"
}
Response (Self-Removal)
{
"message" : "You have exited the household"
}
Check Invite Status
GET /api/household/invite-status
Checks if the authenticated user has any pending household invitations.
Authentication : Required
Response
Whether the user has a pending invitation
ID of the household (if invited)
ID of the invitation record (if invited)
Name of the household (if invited)
curl -X GET https://your-domain.com/api/household/invite-status \
-H "Authorization: Bearer YOUR_CLERK_TOKEN"
Example Response (No Invite)
Example Response (Has Invite)
{
"hasInvite" : true ,
"householdId" : "clx456def" ,
"inviteId" : "clxmem5" ,
"householdName" : "Smith Family"
}
Accept Invitation
POST /api/household/accept
Accepts a pending household invitation.
Authentication : Required
Request Body
curl -X POST https://your-domain.com/api/household/accept \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"inviteId": "clxmem5"}'
Response
When accepting an invitation, the member record is updated with the user’s userId and the status is changed to “accepted”.
Decline Invitation
POST /api/household/decline
Declines and deletes a pending household invitation.
Authentication : Required
Request Body
curl -X POST https://your-domain.com/api/household/decline \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"inviteId": "clxmem5"}'
Response
Error Responses
User is not authenticated
Missing or invalid parameters
Missing or invalid invite ID
or
or
500 Internal Server Error
Unexpected server error
or
Member Roles
The API supports three member roles:
owner : Full access, can manage members and settings
member : Standard access, can view and edit household data
guest : Limited access (implementation-dependent)
Source Code Reference
Initialize: ~/workspace/source/src/app/api/household/init/route.ts:4
Members: ~/workspace/source/src/app/api/household/members/route.ts:12
Invite status: ~/workspace/source/src/app/api/household/invite-status/route.ts:5
Accept: ~/workspace/source/src/app/api/household/accept/route.ts:5
Decline: ~/workspace/source/src/app/api/household/decline/route.ts:5