Campaigns

This object allows you to create custom Campaigns. A Campaign is characterized by a set of rules, defined as a SQL query created in Redash and associated with the Campaign. A Campaign can be triggered at predefined intervals. For example, a Campaign can be triggered every day to add borrowers who are 30 days past due. Campaigns can also be manually triggered. When a Campaign is triggered by schedule or manually, a query is executed against the lender’s replica data and returns a list of person IDs. The output is sent to the configured Contact Exporter to be written as a configurable CSV file with contact information required by auto dialers and other systems.

Get campaign runs

Get a list of campaign runs.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
companyId
required
string

The unique company identifier.

borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

query Parameters
limit
integer [ 1 .. 100 ]
Default: 25

The maximum count of results to retrieve.

startingAfter
string

Return results starting after the provided object identifier.

Responses
200

Success

get/companies/{companyId}/campaigns/{borrowerCampaignId}/runs
Response samples
application/json
{
  • "status": 0,
  • "total": 0,
  • "count": 0,
  • "nextUrl": "string",
  • "previousUrl": "string",
  • "data": [
    ]
}

Create campaign

Create a new campaign by associating a Redash query that returns a single column containing borrower IDs labeled “id”. The campaign can also be scheduled.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
Request Body schema: application/json
(General (string or null)) or (bulkSender (string or null)) or (bulkSender: paymentDueDateReminder (string or null)) or (bulkSender: loanOverdueNthNotice (string or null)) or (bulkSender: autopayPaymentReminder (string or null)) or (bulkSender: loginFirstPaymentReminder (string or null)) or (bulkSender: autopayEnableReminder (string or null)) or (bulkSender: autopayAmountChanged (string or null)) or (bulkSender: futurepayPaymentDueReminder (string or null)) or (bulkSender: loanRightToCurePersonalUnsecured (string or null)) or (bulkSender: cardExpiresReminder (string or null))
redashApiKey
string or null

The API key to use for querying Redash.

You can find your API key at https://{YOUR_REDASH_DOMAIN}/users/me.

schedule
string or null

The schedule to run a campaign on, given in Peachy crontab time specification format.

Peachy crontab is an extension to crontab(5) that adds a time specification value 'P', which means "Peach decides". Currently, the minute and hour fields must be 'P' (i.e., you can not specify the time of the day), and the day-of-month, month, and day-of-week fields must NOT be 'P'.

Some examples of Peachy crontabs: P P 1,15 * *: Run on the 1st and 15th of every month P P * * wed: Run every Wednesday P P * 10 *: Run every day in October

See https://crontab.guru/ for an expression builder.

If null the campaign does not run on a schedule (and therefore must be run manually).

contactExporterId
string or null

The ID of an existing contact exporter to use for this campaign.

bulkSenderId
string or null

The ID of an existing bulk sender to use for this campaign.

object or null

The SFTP settings to be used to upload the results of a campaign run.

At the completion of a campaign run, if these settings are specified, they are used to SFTP upload the files created as a result of the run.

These files include the exporter contacts .csv file and the log file.

The file names for these files will be:

  • {CAMPAIGN_ID}_{TIMESTAMP}_query_results.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}_log.txt
Responses
200

Success

post/campaigns
Request samples
application/json
{
  • "redashApiKey": "string",
  • "schedule": "string",
  • "contactExporterId": "string",
  • "bulkSenderId": "string",
  • "sftpSettings": {
    }
}
Response samples
application/json
{
  • "status": 0,
  • "message": "string",
  • "data": {
    }
}

Get campaigns

Get a list of all campaigns.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
query Parameters
sortBy
Array of strings

The data attributes by which to sort the results.

limit
integer [ 1 .. 100 ]
Default: 25

The maximum count of results to retrieve.

startingAfter
string

Return results starting after the provided object identifier.

Responses
200

Success

get/campaigns
Response samples
application/json
{
  • "status": 0,
  • "total": 0,
  • "count": 0,
  • "nextUrl": "string",
  • "previousUrl": "string",
  • "data": [
    ]
}

Get campaign by ID

Get a campaign by ID.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

Responses
200

Success

get/campaigns/{borrowerCampaignId}
Response samples
application/json
{
  • "status": 0,
  • "message": "string",
  • "data": {
    }
}

Update campaign

Update a campaign by ID.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

Request Body schema: application/json
(General (string or null)) or (bulkSender (string or null)) or (bulkSender: paymentDueDateReminder (string or null)) or (bulkSender: loanOverdueNthNotice (string or null)) or (bulkSender: autopayPaymentReminder (string or null)) or (bulkSender: loginFirstPaymentReminder (string or null)) or (bulkSender: autopayEnableReminder (string or null)) or (bulkSender: autopayAmountChanged (string or null)) or (bulkSender: futurepayPaymentDueReminder (string or null)) or (bulkSender: loanRightToCurePersonalUnsecured (string or null)) or (bulkSender: cardExpiresReminder (string or null))
redashApiKey
string or null

The API key to use for querying Redash.

You can find your API key at https://{YOUR_REDASH_DOMAIN}/users/me.

schedule
string or null

The schedule to run a campaign on, given in Peachy crontab time specification format.

Peachy crontab is an extension to crontab(5) that adds a time specification value 'P', which means "Peach decides". Currently, the minute and hour fields must be 'P' (i.e., you can not specify the time of the day), and the day-of-month, month, and day-of-week fields must NOT be 'P'.

Some examples of Peachy crontabs: P P 1,15 * *: Run on the 1st and 15th of every month P P * * wed: Run every Wednesday P P * 10 *: Run every day in October

See https://crontab.guru/ for an expression builder.

If null the campaign does not run on a schedule (and therefore must be run manually).

contactExporterId
string or null

The ID of an existing contact exporter to use for this campaign.

bulkSenderId
string or null

The ID of an existing bulk sender to use for this campaign.

object or null

The SFTP settings to be used to upload the results of a campaign run.

At the completion of a campaign run, if these settings are specified, they are used to SFTP upload the files created as a result of the run.

These files include the exporter contacts .csv file and the log file.

The file names for these files will be:

  • {CAMPAIGN_ID}_{TIMESTAMP}_query_results.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}.csv
  • {CAMPAIGN_ID}_{EXPORTER_ID}_{TIMESTAMP}_log.txt
Responses
200

Success

put/campaigns/{borrowerCampaignId}
Request samples
application/json
{
  • "redashApiKey": "string",
  • "schedule": "string",
  • "contactExporterId": "string",
  • "bulkSenderId": "string",
  • "sftpSettings": {
    }
}
Response samples
application/json
{
  • "status": 0,
  • "message": "string",
  • "data": {
    }
}

Run campaign

Start a new borrower campaign run and save results.

The behavior of the campaign run is controlled by configured settings on the campaign object and via the associated BulkSender and ContextExporter objects.

By default when the campaign runs, it executes the Redash query referenced in the redashQueryUrl and feeds the query results as input to the campaign run.

Optionally, you can override this by specifing a queryResultsOverride field as input.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

Request Body schema: application/json
queryResultsOverride
Array of arrays

Instead of running the Redash query specified in the Campaign object at queryRedashUrl you can overide that query by providing a query results override.

Instead of the query being run and its results being used as campaign input, the data provided here is fed into the campaign as input.

Responses
200

Success

post/campaigns/{borrowerCampaignId}/runs
Request samples
application/json
{
  • "queryResultsOverride": [
    ]
}
Response samples
application/json
{
  • "status": "failed",
  • "borrowerCampaignId": "string",
  • "availableFiles": [
    ]
}

Get campaign runs

Get a list of campaign runs.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

query Parameters
limit
integer [ 1 .. 100 ]
Default: 25

The maximum count of results to retrieve.

startingAfter
string

Return results starting after the provided object identifier.

Responses
200

Success

get/campaigns/{borrowerCampaignId}/runs
Response samples
application/json
{
  • "status": 0,
  • "total": 0,
  • "count": 0,
  • "nextUrl": "string",
  • "previousUrl": "string",
  • "data": [
    ]
}

Update campaign run

Update campaign run data.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

Request Body schema: application/json
status
string (BorrowerCampaignRunStatus)

The status of a campaign run

Enum: "failed" "success" "processing" "initializing"
queryResultsFileId
string
campaignInputFileId
string
contactsOutputFileId
string
logFileId
string
borrowerCampaignId
string

The ID of the borrower campaign to which this campaign run belongs.

availableFiles
Array of strings

The list of files currently available for download via this campaign run's .../download endpoint.

Items Enum: "query_results.csv" "campaign_input.json" "contacts.csv" "log.txt"
Responses
200

Success

put/campaigns/{borrowerCampaignId}/runs/{borrowerCampaignRunId}
Request samples
application/json
{
  • "status": "failed",
  • "queryResultsFileId": "string",
  • "campaignInputFileId": "string",
  • "contactsOutputFileId": "string",
  • "logFileId": "string",
  • "borrowerCampaignId": "string",
  • "availableFiles": [
    ]
}
Response samples
application/json
{
  • "status": "failed",
  • "borrowerCampaignId": "string",
  • "availableFiles": [
    ]
}

Get campaign run

Get campaign run data by ID.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

Responses
200

Success

get/campaigns/{borrowerCampaignId}/runs/{borrowerCampaignRunId}
Response samples
application/json
{
  • "status": "failed",
  • "borrowerCampaignId": "string",
  • "availableFiles": [
    ]
}

Download all files

Download files generated by a campaign run.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string (AnyId) ^ext-|^[A-Z][A-Z0-9]-[A-Z0-9]+-[A-Z0-9]+|^\d+...

Peach's unique or lender's external identifier.

query Parameters
file
string
Default: "all"

Specify which file should be downloaded from this campaign run. The requested files will be returned as a .zip file.

  • query_results.csv - A CSV formatted file of the query results received from Redash
  • campaign_input.json - A JSON formatted file of the parsed query results used as input to the campaign
  • contacts.csv - The exported contacts as CSV—i.e., the output.
  • log.txt - A log of the campaign run process.
Enum: "all" "query_results.csv" "campaign_input.json" "contacts.csv" "log.txt"
Responses
200

Success

get/campaigns/{borrowerCampaignId}/runs/{borrowerCampaignRunId}/download