Prescient AI API Reference

This GraphQL API allows programmatic access to Prescient data for use in your own apps.

Getting API Access: API access must be enabled on your account before you can generate a token. Please reach out to your Customer Support Manager to have your account enabled for API access.

Once your account has been enabled, log in to your Prescient AI dashboard and go to Settings > API and click "Generate Token". This will be the token you use for authentication. Note that you will only be able to view this token at the time of generation - if you lose the token, you'll have to generate a new one.

You can view the changelog for the api here.

API Endpoints
# Production
# HTTP Method - POST:
https://api.prescient-ai.io/graphql
Headers
# You must create a token from your Prescient settings
Authorization: apikey <YOUR_TOKEN_HERE>

Queries

channelNames

Description

Returns the source names of all channels you have in use.

Response

Returns [String!]!

Example

Query
query channelNames {
  channelNames
}
Response
{"data": {"channelNames": ["xyz789"]}}

modeledMetrics

Description

Get modeled metrics for a given date range. We recommend pulling data updates once per day. Results will be paginated, so implementations should handle making multiple calls using the after argument.

Response

Returns a ModeledMetricQuery!

Arguments
Name Description
after - BigInt The cursor to indicate where the pagination should begin. Value comes from the pageInfo>endCursor field in the previous response.
campaignIds - [String!] Filter by campaign ids. These correspond to the ids of your campaigns in their respective source channels.
endDate - ISO8601Date End date for the reporting records. Defaults to today.
processDate - ISO8601Date Filters out any records that have not been created or updated since this date. We recommend using this field in all implementations to avoid pulling large, unchanged data sets.
salesChannel - [SalesChannelEnum!] Sales channels to filter modeled output by. When omitted, returns both ECOMMERCE and RETAIL.
startDate - ISO8601Date Start date for the reporting records. Defaults to 30 days ago.

Example

Query
query modeledMetrics(
  $after: BigInt,
  $campaignIds: [String!],
  $endDate: ISO8601Date,
  $processDate: ISO8601Date,
  $salesChannel: [SalesChannelEnum!],
  $startDate: ISO8601Date
) {
  modeledMetrics(
    after: $after,
    campaignIds: $campaignIds,
    endDate: $endDate,
    processDate: $processDate,
    salesChannel: $salesChannel,
    startDate: $startDate
  ) {
    data {
      metricName
      metricValue
      processDate
      reportedDate
      sourceCampaignId
      sourceCampaignName
      sourceChannelName
      target
      targetChannelName
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
Variables
{
  "after": {},
  "campaignIds": ["xyz789"],
  "endDate": ISO8601Date,
  "processDate": ISO8601Date,
  "salesChannel": ["ECOMMERCE"],
  "startDate": ISO8601Date
}
Response
{
  "data": {
    "modeledMetrics": {
      "data": [ModeledMetricRow],
      "pageInfo": PageInfo
    }
  }
}

models

Description

Returns all of the available models.

Response

Returns [Model!]!

Example

Query
query models {
  models {
    name
    unit
  }
}
Response
{
  "data": {
    "models": [
      {
        "name": "abc123",
        "unit": "CUSTOMERS"
      }
    ]
  }
}

reportedMetrics

Description

Get reported spend metrics for campaigns by date. Returns spend data per campaign/day. Results will be paginated, so implementations should handle making multiple calls using the after argument.

Response

Returns a ReportedMetricQuery!

Arguments
Name Description
after - BigInt The cursor to indicate where the pagination should begin. Value comes from the pageInfo>endCursor field in the previous response.
campaignIds - [String!] Filter by campaign ids. These correspond to the ids of your campaigns in their respective source channels.
endDate - ISO8601Date End date for the reporting records. Defaults to today.
processDate - ISO8601Date Filters out any records that have not been created or updated since this date. We recommend using this field in all implementations to avoid pulling large, unchanged data sets.
startDate - ISO8601Date Start date for the reporting records. Defaults to 30 days ago.

Example

Query
query reportedMetrics(
  $after: BigInt,
  $campaignIds: [String!],
  $endDate: ISO8601Date,
  $processDate: ISO8601Date,
  $startDate: ISO8601Date
) {
  reportedMetrics(
    after: $after,
    campaignIds: $campaignIds,
    endDate: $endDate,
    processDate: $processDate,
    startDate: $startDate
  ) {
    data {
      campaignId
      campaignName
      channelName
      processDate
      reportedDate
      spend
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
Variables
{
  "after": {},
  "campaignIds": ["abc123"],
  "endDate": ISO8601Date,
  "processDate": ISO8601Date,
  "startDate": ISO8601Date
}
Response
{
  "data": {
    "reportedMetrics": {
      "data": [ReportedMetricRow],
      "pageInfo": PageInfo
    }
  }
}

Types

BigInt

Description

Represents non-fractional signed whole numeric values. Since the value may exceed the size of a 32-bit integer, it's encoded as a string.

Example
{}

Boolean

Description

The Boolean scalar type represents true or false.

Example
true

Float

Description

The Float scalar type represents signed double-precision fractional values as specified by IEEE 754.

Example
987.65

ISO8601Date

Description

An ISO 8601-encoded date

Example
ISO8601Date

ISO8601DateTime

Description

An ISO 8601-encoded datetime

Example
ISO8601DateTime

MetricName

Values
Enum Value Description

FIRST_ORDER_CONVERSIONS

New customers attributed to direct conversions from the campaign, such as last click attribution

FIRST_ORDER_REVENUE

Revenue attributed to direct conversions from the campaign, such as last click attribution

FIRST_ORDER_SUBSCRIPTIONS

Subscriptions attributed to direct conversions from the campaign, such as last click attribution

SECOND_ORDER_CONVERSIONS

New customers attributed to halo effects from the campaign

SECOND_ORDER_REVENUE

Revenue attributed to halo effects from the campaign

SECOND_ORDER_SUBSCRIPTIONS

Subscriptions attributed to halo effects from the campaign
Example
"FIRST_ORDER_CONVERSIONS"

MetricUnit

Values
Enum Value Description

CUSTOMERS

The metrics are measured in new customers

REVENUE

The metrics are measured by revenue in USD

SUBSCRIPTIONS

The metrics are measured in subscriptions
Example
"CUSTOMERS"

Model

Fields
Field Name Description
name - String! The name of the model
unit - MetricUnit! The unit in which this model's metrics are measured in
Example
{"name": "abc123", "unit": "CUSTOMERS"}

ModeledMetricQuery

Fields
Field Name Description
data - [ModeledMetricRow!]! The array containing the modeled metric rows
pageInfo - PageInfo! Pagination info for the query
Example
{
  "data": [ModeledMetricRow],
  "pageInfo": PageInfo
}

ModeledMetricRow

Fields
Field Name Description
metricName - MetricName! The type of the metric
metricValue - Float! The value of the metric
processDate - ISO8601DateTime! The date the metric was created or last updated
reportedDate - String! The date the metric corresponds to. This is a date string in the format of YYYY-MM-DD
sourceCampaignId - String! The ID for the campaign
sourceCampaignName - String The name of the campaign
sourceChannelName - String! The data source channel of the campaign
target - String! The name of the model that produced this metric
targetChannelName - String The channel that the modeling attributes credit for this metric. Only applies to second order metrics.
Example
{
  "metricName": "FIRST_ORDER_CONVERSIONS",
  "metricValue": 987.65,
  "processDate": ISO8601DateTime,
  "reportedDate": "xyz789",
  "sourceCampaignId": "xyz789",
  "sourceCampaignName": "xyz789",
  "sourceChannelName": "xyz789",
  "target": "abc123",
  "targetChannelName": "abc123"
}

PageInfo

Fields
Field Name Description
endCursor - String The cursor for the next page, if there is one
hasNextPage - Boolean Whether a next page exists or not
Example
{"endCursor": "xyz789", "hasNextPage": true}

ReportedMetricQuery

Fields
Field Name Description
data - [ReportedMetricRow!]! The array containing the reported metric rows
pageInfo - PageInfo! Pagination info for the query
Example
{
  "data": [ReportedMetricRow],
  "pageInfo": PageInfo
}

ReportedMetricRow

Fields
Field Name Description
campaignId - String! The ID for the campaign
campaignName - String The name of the campaign
channelName - String! The data source channel of the campaign
processDate - ISO8601Date! The date the metric was created or last updated
reportedDate - ISO8601Date! The date the metric corresponds to
spend - Float! The spend amount for the campaign on this date
Example
{
  "campaignId": "xyz789",
  "campaignName": "xyz789",
  "channelName": "abc123",
  "processDate": ISO8601Date,
  "reportedDate": ISO8601Date,
  "spend": 987.65
}

SalesChannelEnum

Description

Sales channel for filtering modeled metrics output

Values
Enum Value Description

ECOMMERCE

RETAIL

Example
"ECOMMERCE"

String

Description

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Example
"xyz789"