Nudgescribe API Reference
APIs
API types
API types
  • Authentication
  • Content
  • Campaign
APIs
API types
API types
  • Authentication
  • Content
  • Campaign
  1. Campaign Reruns
  • Nudgescribe API
  • Authentication
    • Authentication
    • Authenticate
      POST
    • Re-Authenticate
      GET
  • Content
    • Customers
      • Customer Management
      • Upload and Validate Customer Data
      • Get pages
      • Get Customers
      • Delete Customers
    • Customer Groups
      • Customer Groups
      • Create Customer Group
      • Get Customer Groups
      • Update Customer Group
      • Delete Customer Group
    • Customer Profile Fields
      • Customer Profile Fields
      • Create a Custom Profile Field
      • Get Customer Profile Fields for a Workspace
      • Update Custom Fields
      • Delete Custom Fields
  • Campaigns
    • Campaign Messages
      • Campaign Messages
      • Get All Accounts Campaigns
      • Publish Messages to Secure Storage
      • Get Campaign Messages Pages
      • Retrieve Published Messages
    • Campaign Reruns
      • Campaign Reruns
      • Get Campaign Rerun History
        POST
      • Get Run Messages
        POST
      • Initiate Campaign Rerun
        POST
APIs
API types
API types
  • Authentication
  • Content
  • Campaign
APIs
API types
API types
  • Authentication
  • Content
  • Campaign
  1. Campaign Reruns

Campaign Reruns

This API provides campaign rerun management capabilities, enabling external systems to view rerun history, inspect run-specific messages, and initiate new reruns against updated customer groups — all without manual intervention through the platform UI.

Introduction#

The Campaign Reruns API enables organisations to automate and integrate campaign refresh workflows:
Rerun History: Retrieve a complete audit trail of all campaign runs with status and customer group metadata
Run Messages: Inspect the generated messages for any specific run, including segment and review data
Rerun Initiation: Trigger a new campaign run against a different customer group in a single atomic API call
Segment Intelligence: Automatic reuse of existing approved messages where segments match, with new generation only where needed
Async Processing: Background job queue handles large-scale message generation without blocking your integration
These endpoints are designed for CRM systems, marketing automation platforms, and external integrations that need to programmatically refresh campaign messages as customer data changes over time.

Field Descriptions#

Rerun History Object

`comparison_summary` Object

Run Message Object

Rerun Object

`comparison` Object


Key Concepts#

Runs#

Every campaign starts at Run #1 (the original published campaign). Each time a rerun is initiated, the run number increments. The campaign always reflects the current run as its active state.

Segments#

Campaigns generate messages per customer segment (a unique combination of variable values). When a rerun is initiated against a new customer group, segments from the previous run are compared against the new group:
Matched segments — the segment exists in both runs; the existing approved message is reused
New segments — only present in the new group; new messages are generated
Orphaned segments — only present in the previous run; their messages are archived

Campaign Status After Rerun#

ScenarioResulting Campaign Status
New segments require generationReady for review
All segments matched (no new generation needed)Ready to publish

Endpoints#

Endpoints Overview#

EndpointMethodPurposeAccess Control
/v1/campaign/rerun/historyPOSTGet all run history for a campaignAPI Authentication (JWT + API Headers)
/v1/campaign/rerun/messagesPOSTGet messages for a specific runAPI Authentication (JWT + API Headers)
/v1/campaign/rerun/initiatePOSTInitiate a new campaign rerunAPI Authentication (JWT + API Headers)

Authentication#

All endpoints require API authentication via HTTP headers.

Required Headers#

HeaderRequiredDescription
authorizationYesBearer token (JWT) containing user_id, account_id, role_code
x-auth-contextYesJSON object: { "api_access": true, "api_code": "<API_CODE>" }
x-ipYesClient IP address for audit logging
Content-TypeYesMust be application/json

Authentication Flow#

1.
API Code Validation: Validate api_code in x-auth-context matches server configuration
2.
JWT Verification: Verify JWT token signature against API secret
3.
Access Check: Confirm api_access is set to true
4.
Account Extraction: Extract account_id from JWT for data isolation

Example Headers#

authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
x-auth-context: {"api_access": true, "api_code": "your-api-code"}
x-ip: 192.168.1.100
Content-Type: application/json

1. Get Campaign Rerun History#

Endpoint#

POST /v1/campaign/rerun/history

Description#

Returns the complete run history for a campaign, ordered from most recent to oldest. Each entry represents a distinct run, including the customer group used, the number of segments, and a summary of how messages were handled.
If the campaign has never been formally rerun (i.e. only Run #1 exists), a synthesised Run #1 entry is returned derived from the original campaign data, ensuring history is always available.

Purpose#

Enables external systems to audit the full lifecycle of a campaign's message generation across multiple customer groups and time periods.

Business Use Cases#

Audit Trails: Maintain a record of which customer group was used for each message run.
Run Selection: Allow users to choose which run's messages to retrieve or publish.
Status Monitoring: Track the outcome of each run (e.g. Published, Ready for review).
Reporting: Generate reports on campaign rerun activity over time.

Security Features#

JWT token validation with account-specific secret
API code verification against server configuration
Account-level data isolation — only runs for the authenticated account's campaign are returned

2. Get Run Messages#

Endpoint#

POST /v1/campaign/rerun/messages

Description#

Returns the generated messages for a campaign, optionally filtered to a specific run number. Each message includes its segment data, review status, approval stage, and archival state.
When a run_number is provided, archived messages for that run are included automatically (since messages from historical runs are archived when a newer run begins). When no run_number is provided, only active (non-archived) messages for the current run are returned by default.

Purpose#

Enables external systems to retrieve the full set of generated messages for a given run, supporting downstream publishing, review workflows, and data export.

Business Use Cases#

Message Review: Retrieve messages for a specific run to display in an external review interface.
Publishing Integration: Pull approved messages for delivery to a marketing or CRM platform.
Historical Audit: Inspect messages from previous runs for compliance or reporting.
Segment Analysis: Review which message was generated for each customer segment.

Security Features#

JWT token validation with account-specific secret
API code verification against server configuration
Account-level data isolation — campaign ownership is validated before returning messages

3. Initiate Campaign Rerun#

Endpoint#

POST /v1/campaign/rerun/initiate

Description#

Initiates a new campaign run against a different customer group in a single atomic operation. This endpoint combines segment preview, run record creation, campaign state update, previous-run message archival, and async processing job queuing — all in one call.
Prerequisites:
The campaign must have a status of Published
All messages in the current run must be in Published status before a rerun can be initiated
The endpoint automatically archives all messages from the previous run. Orphaned segment messages (those no longer relevant to the new customer group) are also archived during async processing.

Purpose#

Enables external integrations to fully automate the campaign refresh cycle — updating the customer group and triggering message generation without any manual steps in the platform.

Business Use Cases#

Automated Refresh: Trigger a campaign rerun when CRM data is updated (e.g. monthly customer list refresh).
Scheduled Campaigns: Integrate with scheduling systems to rerun campaigns on a regular cadence.
Dynamic Audiences: Update campaigns in response to real-time segmentation changes.
Workflow Automation: Chain rerun initiation with downstream publishing steps once the job completes.

Processing Flow#

After a successful response, background processing proceeds through the following phases:
1.
Copying — Matched segment messages are copied from the previous run to the new run
2.
Generating — New segment messages are generated using the campaign's AI configuration
3.
Archiving — Orphaned segment messages are archived
4.
Finalising — Campaign state is updated to reflect the completed run

Security Features#

JWT token validation with account-specific secret
API code verification against server configuration
Account-level data isolation — campaign ownership validated before any mutation
All messages in the current run must be Published before a rerun is permitted
Campaign must be in Published status — prevents rerunning mid-review campaigns

Common Error Codes#

Status CodeDescriptionCommon Causes
400Bad RequestCampaign not in Published status; unpublished messages exist; current run targeted for archive
401UnauthorizedMissing required request body fields
403ForbiddenMissing or invalid authentication headers, invalid API code, invalid JWT
404Not FoundCampaign not found; customer group not found
500Internal Server ErrorDatabase errors, processing failures

Specific Error Messages#

MessageCauseResolution
"auth error"Missing req.auth or entity managerEnsure a valid JWT token is present in the authorization header
"Unauthorized"API validation failedVerify x-auth-context contains a valid api_code
"Missing required fields"Required body fields absentInclude all required fields in the request body
"Campaign not found"Invalid or inaccessible campaign_idVerify the campaign exists and belongs to your account
"Customer group not found"Invalid new_customer_group_idVerify the customer group ID is correct
"Only Published campaigns can be rerun"Campaign is not in Published statusEnsure the campaign has been published before initiating a rerun
"All campaign messages must be published before initiating a rerun"One or more messages in the current run are not yet publishedPublish all current run messages before initiating a rerun

Security & Compliance#

Data Protection#

Account-Level Isolation: All data queries filtered by account_id extracted from the JWT
Encrypted Transport: All API communications over HTTPS

Access Control#

JWT Authentication: All endpoints require a valid JWT token
API Code Validation: api_code must match server configuration
Campaign Ownership: All operations validate that the campaign belongs to the authenticated account
Database Context: All operations execute within an authenticated database context

Audit Logging#

User Context: All rerun records store the user_id of the initiating user
Job Tracking: Async background jobs are tracked with unique job_uid identifiers
Timestamp Recording: started_at and completed_at timestamps recorded per run
Comparison Snapshots: Segment comparison summaries stored permanently on each run record
Modified at 2026-03-09 14:43:51
Previous
Retrieve Published Messages
Next
Get Campaign Rerun History
Built with