Skip to content

Generate

The Generate endpoint is the core of the JustAI API. It selects and returns personalized content variants, learning which variants perform best for different user segments.

POST https://worker.justwords.ai/api/generate/:org_slug
GET https://worker.justwords.ai/api/generate/:org_slug

Both POST and GET methods are supported. POST is recommended for requests with complex parameters.

This endpoint requires authentication via an API key. Include your key in the X-Api-Key header or as a Bearer token in the Authorization header.

See the Quickstart for details on creating and managing API keys.

ParameterTypeRequiredDescription
org_slugstringYesYour organization identifier (e.g., your-company-name).
FieldTypeRequiredDefaultDescription
template_idstringYes-Unique identifier for the template for which content is being fetched.
user_idstringNo-Unique identifier for the end user (used for personalization and tracking).
tracking_idstringNo-Unique identifier for tracking this message through downstream events (opens, clicks, conversions).
fieldsobjectNo{}Key-value pairs for LiquidJS template variable substitution.
attrsobjectNo{}Key-value pairs for targeting/filtering (all values converted to lowercase).

Generate content for a welcome email:

Terminal window
curl -X POST https://worker.justwords.ai/api/generate/your-org \
-H "X-Api-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template_id": "welcome-email",
"user_id": "user_123"
}'

Pass user-specific data to personalize the content:

{
"template_id": "welcome-email",
"user_id": "user_123",
"fields": {
"user_name": "Alice",
"account_type": "premium",
"signup_date": "2024-01-15"
}
}

These fields are used by your template’s LiquidJS variables (e.g., {{ user_name }} becomes “Alice”).

Filter which variants are eligible based on user attributes:

{
"template_id": "welcome-email",
"user_id": "user_123",
"attrs": {
"plan": "premium",
"region": "us-east",
"language": "en"
}
}

Only variants matching these attributes will be considered for selection.

Link this generation to downstream events for performance measurement:

{
"template_id": "welcome-email",
"user_id": "user_123",
"tracking_id": "msg_xyz789"
}

Use this tracking_id when sending open/click/conversion events via webhooks.

{
"copy": {
"id": "variant_abc123",
"vars": {
"subject": "Welcome to our platform, Alice!",
"body": "We're excited to have you join us.",
"preheader": "Get started in minutes"
}
}
}
FieldTypeDescription
copy.idstringUnique identifier for the selected variant.
copy.varsobjectKey-value pairs of rendered template variables.

When no variants match the criteria:

{
"copy": {},
"message": "No candidates found"
}

This can happen if:

  • All variants are filtered out by targeting rules.
  • No variants are active for this template.
  • Seasonality rules exclude all variants at this time.