Updates or creates preference information for a subscriber in the OnlyAutomator CRM system.
Endpoint
POST /api/v2/update-preference
Authentication
This endpoint requires authentication via bearer token representing a valid user session managed by Supabase Auth (cookies).Testing Note: Due to the requirement for a live user session, this endpoint cannot be successfully tested directly using the ‘Send’ button in this documentation with a static token.To test:
- Call this endpoint from your web application after logging in.
- Use
curl or a similar tool with a valid, current user JWT obtained from your browser’s session after logging in.
Retrieving JWT Token for Testing:
To test endpoints requiring a user session with tools like curl, you need the JWT access token stored by Supabase Auth in your browser.
- Log in to your application normally in your browser.
- Open Developer Tools (usually F12).
- Go to the Application tab (it might be called Storage in Firefox).
- Under the Storage section, find Cookies and select your application’s domain (e.g.,
http://localhost:3000 or https://onlyautomator.com).
- Look for a cookie named similar to
sb-access-token (the exact name might vary slightly based on Supabase configuration).
- Copy the entire value of this cookie. This is your Bearer token.
- Use this copied value in the
Authorization: Bearer <your_copied_token> header for your curl or other API tool requests.
Note: This token has a limited lifetime and you’ll need to copy a fresh one after it expires.
# Available URLs:
# - Local development: http://localhost:3000/api/v2/update-preference
# - Production: https://onlyautomator.com/api/v2/update-preference
# Example with curl:
curl -X POST "https://onlyautomator.com/api/v2/update-preference" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fanId": "12345",
"category": "content",
"preference": "likes_fitness_videos",
"value": true
}'
Bearer token for authentication. Format: Bearer YOUR_JWT_TOKEN
Must be set to application/json
Request Body
Unique identifier of the subscriber/fan
Category of the preference. Common values: “content”, “messaging”, “tipping”, “scheduling”
Specific preference identifier. Should be a descriptive string without spaces
Value of the preference. Can be a boolean, string, number, or any JSON-serializable value
Response
Status of the request (success or error)
Preference object that was created or updated
Unique identifier for the preference record (UUID).
Unique identifier of the subscriber/fan this preference belongs to.
Unique identifier of the OnlyAutomator user who created/updated this preference.
Category of the preference (e.g., “content”, “messaging”).
Specific preference identifier or key (e.g., “likes_fitness_videos”).
Value of the preference (can be boolean, string, number, etc.).
Source of the preference (e.g., “manual”, “extension”, “inferred”, nullable).
ISO timestamp of when the preference record was created.
ISO timestamp of when the preference record was last updated.
200 Success
{
"status": "success",
"data": {
"id": "pref_uuid_1c2d3e4f",
"fanId": "fan_uuid_12345",
"userId": "user_uuid_abcdef",
"category": "content",
"preference": "likes_fitness_videos",
"value": true,
"source": "extension",
"createdAt": "2023-03-15T14:23:45Z",
"updatedAt": "2023-03-15T14:23:45Z"
}
}
400 Bad Request
{
"status": "error",
"error": {
"code": "validation_error",
"message": "The 'category' field is required"
}
}
401 Unauthorized
{
"status": "error",
"error": {
"code": "authentication_required",
"message": "Authentication is required to access this resource"
}
}
403 Forbidden
{
"status": "error",
"error": {
"code": "permission_denied",
"message": "Your token does not have permission to access this resource"
}
}
404 Not Found
{
"status": "error",
"error": {
"code": "resource_not_found",
"message": "Fan not found with the provided ID"
}
}
Error Codes
| Error Code | Description |
|---|
validation_error | A required parameter is missing or invalid |
authentication_required | No valid authentication token provided |
permission_denied | Token lacks required permissions |
resource_not_found | Fan not found with the provided ID |
service_unavailable | The preference service is temporarily unavailable |
Common Preference Categories
| Category | Description | Example Preferences |
|---|
content | Content preferences | likes_fitness, prefers_photos, enjoys_long_videos |
messaging | Messaging preferences | prefers_voice_messages, responds_to_text, morning_messages |
tipping | Tipping behavior | frequent_tipper, high_value_tipper, special_occasion_tipper |
scheduling | Timing preferences | active_weekends, evening_chatter, timezone_gmt_minus_8 |
Notes
- This endpoint is used by the CRM panel in the Chrome extension to track subscriber preferences
- Preferences help creators customize their content and interactions for each subscriber
- If a preference with the same
fanId, category, and preference already exists, it will be updated
- The system supports custom preference categories and names beyond the common ones listed above
Standard user JWT token for authentication.
Bearer token for authentication (JWT)
Unique identifier of the subscriber/fan
Category of the preference
Specific preference identifier
Value of the preference (can be any JSON type: boolean, string, number, object, array).
Preference created or updated successfully