POST
/
api
/
test
/
sync-user
Test User Sync
curl --request POST \
  --url https://onlyautomator.com/api/test/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": "resend",
      "status": "would_sync",
      "details": "User would be added to the audience"
    }
  ]
}

Test Sync User to Marketing

This endpoint allows testing the functionality of adding a single contact to the configured Resend marketing audience (MARKETING_AUDIENCE_ID). It’s primarily for development and testing purposes.

Authentication

This endpoint requires a secret API key (MARKETING_SYNC_API_KEY environment variable) passed as a query parameter (apiKey). This is not the standard user JWT token.Do not expose this endpoint or the API key publicly.

Request (GET or POST)

apiKey
string
required
The secret marketing sync API key.
email
string
required
The email address to test syncing.
dryRun
boolean
default:"true"
If true (default), logs the contact data that would be sent but doesn’t actually call the Resend API. Set to false to perform a real sync.

Response

success
boolean
Indicates if the test process completed successfully (even in dry run).
dryRun
boolean
Reflects the dryRun parameter from the request.
contact
object
The contact data object formatted for Resend.
audience
string
The MARKETING_AUDIENCE_ID used, or a placeholder if not configured.
result
object | null
The response from the Resend API addContactsToAudience call if dryRun was false, otherwise null.

Error Codes

Status CodeDescription
400Missing or invalid email parameter.
401Invalid or missing apiKey parameter.
500Internal server error (e.g., Resend API error during actual sync).

Code Examples

# Test without actually syncing
curl "http://localhost:3000/api/test/sync-user?apiKey=YOUR_MARKETING_SYNC_API_KEY&email=test@example.com"

Notes

  • Authorization: Uses a dedicated marketing sync API key passed as a query parameter.
  • Purpose: Primarily for testing the Resend integration and contact formatting.
  • Methods: Accepts both GET and POST requests.
  • Dry Run: Defaults to true to prevent accidental syncs during testing.
  • Audience ID: Requires MARKETING_AUDIENCE_ID environment variable for actual syncing.

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[]