Updates the country information for a subscriber in the OnlyAutomator CRM system.
Endpoint
POST /api/v2/update-country
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.
Bearer token for authentication. Format: Bearer YOUR_JWT_TOKEN
Must be set to application/json
Request Body
Unique identifier of the subscriber/fan
Two-letter ISO country code (ISO 3166-1 alpha-2)
Region or state within the country (if available)
City within the country (if available)
Source of the country information. Possible values: “ip”, “profile”, “manual”, “guess”. Default: “manual”
Confidence score for the country detection (0.0 to 1.0, where 1.0 is highest confidence)
Response
Status of the request (success or error)
Location object that was created or updated
Unique identifier for the location record (UUID).
Unique identifier of the subscriber/fan this location pertains to.
Unique identifier of the OnlyAutomator user who created/updated this record.
Two-letter ISO country code (e.g., “US”).
Full name of the country (e.g., “United States”, nullable).
Region or state within the country (e.g., “California”, nullable).
City within the country (e.g., “Los Angeles”, nullable).
Latitude coordinate (nullable).
Longitude coordinate (nullable).
IP address used for location detection if source is ‘ip’ (nullable).
Source of the country information (e.g., “ip”, “profile”, “manual”, “guess”, nullable).
Confidence score for the country detection (0.0 to 1.0, nullable).
ISO timestamp of when the location record was created.
ISO timestamp of when the location record was last updated.
200 Success
{
"status": "success",
"data": {
"id": "loc_4d5e6f7g-5678-9012-ijkl-456789abcdef",
"fanId": "fan_uuid_12345",
"userId": "user_uuid_abcdef",
"countryCode": "US",
"countryName": "United States",
"region": "California",
"city": "Los Angeles",
"latitude": 34.0522,
"longitude": -118.2437,
"ipAddress": "192.0.2.1",
"source": "manual",
"confidenceScore": 1.0,
"createdAt": "2023-03-15T14:23:45Z",
"updatedAt": "2023-03-15T14:23:45Z"
}
}
400 Bad Request
{
"status": "error",
"error": {
"code": "validation_error",
"message": "Invalid country code format. Must be a valid ISO 3166-1 alpha-2 code."
}
}
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 |
invalid_country_code | The provided country code is not a valid ISO 3166-1 alpha-2 code |
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 location service is temporarily unavailable |
Notes
- This endpoint is used by the CRM panel in the Chrome extension to track subscriber locations
- Location information helps creators customize content and marketing for different regions
- Country information can be automatically detected based on IP address, but manual updates provide higher accuracy
- If a location record for the same
fanId already exists, it will be updated instead of creating a new record
- Country codes must follow the ISO 3166-1 alpha-2 standard (two-letter codes)
Standard user JWT token for authentication.
Bearer token for authentication (JWT)
Unique identifier of the subscriber/fan
Two-letter ISO country code (ISO 3166-1 alpha-2)
Region or state within the country (if available)
City within the country (if available)
source
enum<string>
default:manual
Source of the country information
Available options:
ip,
profile,
manual,
guess
Confidence score for the country detection (0.0 to 1.0)
Country information updated successfully