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.

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
externalId
string

A lender's identifier for a campaign. After the object is successfully created, a lender can use ID or externalId identifiers to fetch the object.

To fetch the object using externalId you need to add ext- to the URL.

Note: Don't add ext- to the identifier value. For example: if the external identifier is ABCDE, then pass externalId=ACBCE and NOT ext-ABCDE when creating the object.

redashQueryUrl
string or null

The URL of the Redash query from which to build the input list of borrowers.

The URL should look like https://{YOUR_REDASH_DOMAIN}/queries/{QUERY_ID}.

The query must produce a column named id (of type integer) in query results. It will interpret these as borrower IDs, and use this as the input list of borrowers for a new campaign run.

Note that on each execution of a campaign run a fresh list of borrowers is queried from this Redash query.

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 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).

Responses
200

Success

post/campaigns
Request samples
application/json
{}
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
{
  • "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^ext-|^[A-Z]{2}-[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^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

Request Body schema: application/json
externalId
string

A lender's identifier for a campaign. After the object is successfully created, a lender can use ID or externalId identifiers to fetch the object.

To fetch the object using externalId you need to add ext- to the URL.

Note: Don't add ext- to the identifier value. For example: if the external identifier is ABCDE, then pass externalId=ACBCE and NOT ext-ABCDE when creating the object.

redashQueryUrl
string or null

The URL of the Redash query from which to build the input list of borrowers.

The URL should look like https://{YOUR_REDASH_DOMAIN}/queries/{QUERY_ID}.

The query must produce a column named id (of type integer) in query results. It will interpret these as borrower IDs, and use this as the input list of borrowers for a new campaign run.

Note that on each execution of a campaign run a fresh list of borrowers is queried from this Redash query.

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 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).

Responses
200

Success

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

Run campaign

Start a new borrower campaign run and export results using the Campaign’s configured Contact Exporter

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

Request Body schema: application/json
borrowerIds
Array of strings

Manually specify borrower IDs as input (overriding any values returned by the Campaign’s Redash query).

If left unspecified or null, the campaign borrower input data is fetched from the Redash query attached to the campaign.

Responses
200

Success

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

Update campaign run

Update campaign run data.

Securityoauth2 or bearerAuth or apiKeyHeader
Request
path Parameters
borrowerCampaignId
required
string^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

Request Body schema: application/json
status
string

The status of a campaign run

Enum: "failed" "success" "processing" "initializing"
borrowersInputFileId
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: "borrowers.txt" "contacts.csv" "events.log"
Responses
200

Success

put/campaigns/{borrowerCampaignId}/runs/{borrowerCampaignRunId}
Request samples
application/json
{
  • "status": "failed",
  • "borrowersInputFileId": "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^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string^ext-|^[A-Z]{2}-[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^ext-|^[A-Z]{2}-[A-Z0-9]+-[A-Z0-9]+|^\d+$

Peach's unique or lender's external identifier.

borrowerCampaignRunId
required
string^ext-|^[A-Z]{2}-[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.

  • input_borrowers.txt - A newline separated list of borrower IDs used to create the contacts export.
  • contacts.csv - The exported contacts as CSV—i.e., the output.
  • log.txt - A log of the campaign run process.
Enum: "all" "borrowers.txt" "contacts.csv" "events.log"
Responses
200

Success

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

Request sandbox access