POST
/
api
/
v2
/
update-country
Update Country
curl --request POST \
  --url https://onlyautomator.com/api/v2/update-country \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "fanId": "12345",
  "countryCode": "US",
  "countryName": "United States",
  "region": "California",
  "city": "Los Angeles",
  "source": "manual",
  "confidence": 1
}'
{
  "status": "success",
  "data": {
    "id": "loc_4d5e6f7g-5678-9012-ijkl-456789abcdef",
    "fanId": "12345",
    "countryCode": "US",
    "countryName": "United States",
    "region": "California",
    "city": "Los Angeles",
    "source": "manual",
    "confidence": 1,
    "createdAt": "2023-03-15T14:23:45Z",
    "updatedAt": "2023-03-15T14:23:45Z"
  }
}
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:
  1. Call this endpoint from your web application after logging in.
  2. 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.
  1. Log in to your application normally in your browser.
  2. Open Developer Tools (usually F12).
  3. Go to the Application tab (it might be called Storage in Firefox).
  4. Under the Storage section, find Cookies and select your application’s domain (e.g., http://localhost:3000 or https://onlyautomator.com).
  5. Look for a cookie named similar to sb-access-token (the exact name might vary slightly based on Supabase configuration).
  6. Copy the entire value of this cookie. This is your Bearer token.
  7. 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.

Request Headers

Authorization
string
required
Bearer token for authentication. Format: Bearer YOUR_JWT_TOKEN
Content-Type
string
required
Must be set to application/json

Request Body

fanId
string
required
Unique identifier of the subscriber/fan
countryCode
string
required
Two-letter ISO country code (ISO 3166-1 alpha-2)
countryName
string
required
Full name of the country
region
string
Region or state within the country (if available)
city
string
City within the country (if available)
source
string
Source of the country information. Possible values: “ip”, “profile”, “manual”, “guess”. Default: “manual”
confidence
number
Confidence score for the country detection (0.0 to 1.0, where 1.0 is highest confidence)

Response

status
string
Status of the request (success or error)
data
object
Location object that was created or updated
data.id
string
Unique identifier for the location record
data.fanId
string
Unique identifier of the subscriber/fan
data.countryCode
string
Two-letter ISO country code
data.countryName
string
Full name of the country
data.region
string
Region or state within the country (if available)
data.city
string
City within the country (if available)
data.source
string
Source of the country information
data.confidence
number
Confidence score for the country detection
data.createdAt
string
ISO timestamp of when the location record was created
data.updatedAt
string
ISO timestamp of when the location record was last updated

200 Success

{
  "status": "success",
  "data": {
    "id": "loc_4d5e6f7g-5678-9012-ijkl-456789abcdef",
    "fanId": "12345",
    "countryCode": "US",
    "countryName": "United States",
    "region": "California",
    "city": "Los Angeles",
    "source": "manual",
    "confidence": 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 CodeDescription
validation_errorA required parameter is missing or invalid
invalid_country_codeThe provided country code is not a valid ISO 3166-1 alpha-2 code
authentication_requiredNo valid authentication token provided
permission_deniedToken lacks required permissions
resource_not_foundFan not found with the provided ID
service_unavailableThe location service is temporarily unavailable

Notes

  1. This endpoint is used by the CRM panel in the Chrome extension to track subscriber locations
  2. Location information helps creators customize content and marketing for different regions
  3. Country information can be automatically detected based on IP address, but manual updates provide higher accuracy
  4. If a location record for the same fanId already exists, it will be updated instead of creating a new record
  5. Country codes must follow the ISO 3166-1 alpha-2 standard (two-letter codes)

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Authorization
string
required

Bearer token for authentication (JWT)

Body

application/json
fanId
string
required

Unique identifier of the subscriber/fan

Example:

"12345"

countryCode
string
required

Two-letter ISO country code (ISO 3166-1 alpha-2)

Example:

"US"

countryName
string
required

Full name of the country

Example:

"United States"

region
string

Region or state within the country (if available)

Example:

"California"

city
string

City within the country (if available)

Example:

"Los Angeles"

source
enum<string>
default:manual

Source of the country information

Available options:
ip,
profile,
manual,
guess
Example:

"manual"

confidence
number

Confidence score for the country detection (0.0 to 1.0)

Example:

1

Response

Country information updated successfully

status
string
Example:

"success"

data
object