POST
/
api
/
marketing
/
sync-user
Single User Sync
curl --request POST \
  --url https://onlyautomator.com/api/marketing/sync-user \
  --header 'Content-Type: application/json' \
  --data '{
  "email": "<string>",
  "dryRun": false
}'
{
  "success": true,
  "user": {
    "id": "user_123abc",
    "email": "test@example.com",
    "first_name": "John",
    "last_name": "Doe"
  },
  "dryRun": true,
  "platforms": [
    {
      "name": "mailchimp",
      "status": "would_sync",
      "details": "User would be added to the 'active-clients' list"
    }
  ]
}
This endpoint allows you to synchronize a specific individual user with connected marketing platforms. Unlike the bulk synchronization endpoint, this API is designed for targeted, on-demand synchronization of a single user account.

Use Cases

  • Testing marketing platform integration with a specific user
  • Manually fixing synchronization issues for individual users
  • Immediately synchronizing a new user without waiting for scheduled bulk sync
  • Verifying marketing platform integration for specific user profiles
  • Development and debugging of user data synchronization

Authentication

This endpoint requires an API key for authentication.

Query Parameters

email
string
required
Email address of the user to synchronize
apiKey
string
required
API key for authentication
dryRun
boolean
default:"false"
If set to true, simulates synchronization without making actual changes
first_name
string
User’s first name (optional, to override the value in the database)

Request Body (alternative to URL parameters)

email
string
required
Email address of the user to synchronize
dryRun
boolean
default:"false"
If set to true, simulates synchronization without making actual changes

Response

success
boolean
Indicates whether the operation was successful
user
object
Data of the synchronized user
dryRun
boolean
Indicates whether the operation was a simulation
platforms
array
List of marketing platforms with which the user was synchronized

200 OK

{
  "success": true,
  "user": {
    "id": "user_123abc",
    "email": "test@example.com",
    "first_name": "John",
    "last_name": "Doe"
  },
  "dryRun": true,
  "platforms": [
    {
      "name": "mailchimp",
      "status": "would_sync",
      "details": "User would be added to the 'active-clients' list"
    },
    {
      "name": "sendgrid",
      "status": "would_sync",
      "details": "Tags 'onlyautomator-user' would be applied"
    }
  ]
}

200 OK (real mode)

{
  "success": true,
  "user": {
    "id": "user_123abc",
    "email": "test@example.com",
    "first_name": "John",
    "last_name": "Doe"
  },
  "dryRun": false,
  "platforms": [
    {
      "name": "mailchimp",
      "status": "synced",
      "details": "User added to the 'active-clients' list"
    },
    {
      "name": "sendgrid",
      "status": "synced",
      "details": "Tags 'onlyautomator-user' have been applied"
    }
  ]
}

400 Bad Request

{
  "success": false,
  "message": "Invalid parameters",
  "errors": [
    "email is required"
  ]
}

401 Unauthorized

{
  "success": false,
  "message": "Unauthorized. Invalid or missing API key."
}

404 Not Found

{
  "success": false,
  "message": "User not found with the specified email"
}

API Playground

Example Usage

// Example: Test user synchronization in simulation mode
const testUserSync = async () => {
  const email = "test@example.com";
  const apiKey = "YOUR_API_KEY";
  
  const response = await fetch(`http://localhost:3000/api/marketing/sync-user?email=${email}&apiKey=${apiKey}&dryRun=true&first_name=John`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiKey}`    }
  });
  
  const data = await response.json();
  console.log(data);
};

// Example: Perform a real synchronization with request body
const syncUser = async () => {
  const apiKey = "YOUR_API_KEY";
  
  const response = await fetch(`http://localhost:3000/api/marketing/sync-user?apiKey=${apiKey}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiKey}`
    },
    body: JSON.stringify({
      email: "client@example.com",
      dryRun: false
    })
  });
  
  const data = await response.json();
  console.log(data);
};

Usage Notes

  • This endpoint is designed for synchronizing individual users on demand
  • Use the Bulk User Synchronization endpoint instead when you need to:
    • Synchronize multiple users at once
    • Perform scheduled or automated synchronization
    • Update all users after a system change
  • The dryRun parameter is useful for checking what would happen without making actual changes
  • In dryRun=false mode, real changes will be made to connected marketing platforms
  • Authentication can be done either with the apiKey query parameter or with an Authorization: Bearer YOUR_API_KEY header

Query Parameters

email
string
required

Email address of the user to synchronize

apiKey
string
required

API key for authentication

dryRun
boolean
default:false

If set to true, simulates synchronization without making actual changes

first_name
string

User's first name (optional, to override the value in the database)

Body

application/json
email
string

Email address of the user to synchronize

dryRun
boolean
default:false

If set to true, simulates synchronization without making actual changes

Response

User successfully synchronized or simulation completed

success
boolean
Example:

true

user
object
dryRun
boolean
Example:

true

platforms
object[]