# Compatibility APIs

{% hint style="info" %}
These APIs are designed as a stop-gap solution to ease transition onto the Mindful platform, and will eventually be shut down. New implementations should use the Analytics or Query APIs directly, and existing implementations should be updated as soon as possible.
{% endhint %}

## BaseCMS / Content API

The BaseCMS compatibility API provides the same shape as the current BaseCMS GraphQL API. It will be available soon

## NativeX / EmailX (AdX) API

The AdX compatibility APIs provide a limited subset of previous API functionality for both legacy items (entered within AdX) and current items (entered in Mindful).

### Delivery

The delivery APIs are JSON APIs that can be used to fetch creatives for email banner and native ads.

{% hint style="info" %}
In most cases, the workspace key in the URLs below will be `default`.

For more information, see the [tenancy](https://docs.parameter1.com/mindful-apis/getting-started#tenancy) section of the Mindful API overview.
{% endhint %}

#### Email Banner

Old: https\://<mark style="color:yellow;">\<org-key></mark>.serve.email-x.parameter1.com/data/<mark style="color:blue;">\<ad-unit-id></mark>?date=...

New: <https://delivery.mindfulcms.com/><mark style="color:yellow;">\<org-key></mark>/<mark style="color:purple;">\<workspace-key></mark>/compat/email-banner/data/<mark style="color:blue;">\<ad-unit-id></mark>?date=...

#### Email Native

Old: https\://<mark style="color:yellow;">\<org-key></mark>.native-x.parameter1.com/email-placement/<mark style="color:blue;">\<ad-unit-id></mark>.json

New: <https://delivery.mindfulcms.com/><mark style="color:yellow;">\<org-key></mark>/<mark style="color:purple;">\<workspace-key></mark>/compat/native-email/email-placement/<mark style="color:blue;">\<ad-unit-id></mark>.json

### Metrics / Reporting

The NativeX reporting queries are preserved in the Mindful Compatibility API. To use the compatibility API, update your implementation to use the new URI following the pattern below:

Old URL: https\://<mark style="color:yellow;">\<org-key></mark>.native-x.parameter1.com/graphql

New URL:  <https://delivery.mindfulcms.com/><mark style="color:yellow;">\<org-key></mark>/<mark style="color:purple;">\<workspace-key></mark>/compat/native-website/graph

{% hint style="warning" %}
Backwards-compatibility changes

Topics no longer exist in the Mindful ecosystem. The `Topic`, `Template`, and `Ad Unit` models from the NativeX architecture have been combined into a single model in Mindful (targeting an Email or Website Channel, depending on the variant form). For most use cases, this will be a Website Channel (aka section).

For implementations using Topics, read the topic information from the `placement` name field. It follows the pattern `<topic name> - <template name>`.
{% endhint %}

Expand the queries below to see the supported fields from the legacy APIs.

<details>

<summary>All Campaigns</summary>

This query returns all campaigns, from newest to oldest, and supports/requires pagination.

```graphql
query AllCampaigns(
  $pagination: PaginationInput,
  $sort: CampaignSortInput
) {
  allCampaigns(pagination: $pagination, sort: $sort) {
    totalCount
    pageInfo { endCursor hasNextPage }
    edges {
      cursor
      node {
        criteria {
          end
          id
          start
          placements {
            name
            # Topics are no longer supported. For BC, returns placement data.
            topic {
              name
              id
              createdAt
              externalId
              publisher { id name }
            }
            publisher {
              name
              id
              createdAt
              updatedAt
            }
            id
            createdAt
          }
        }
        description
        name
        advertiser { name id }
        id
        creatives {
          id
          title
          teaser
          active
        }
        hash
        url
        status
      }
    }
  }
}
```

</details>

<details>

<summary>Campaign Metrics</summary>

This query returns metrics for a single campaign. Note that the start/end dates are supported, but are not used.

```graphql
query MyQuery($input: CampaignHashInput! , $startDate: Date!, $endDate: Date!){
  campaignHash(input: $input) {
    id
    name
    hash
    reports {
      byDay(startDate: $startDate, endDate: $endDate) {
        date: day(format: "YYYYMMDD")
        metrics {
          clicks
          views
          ctr
        }
      }
    }
    creatives {
      id
      title
    }
  }
}
```

</details>

<details>

<summary>Creative Metrics</summary>

This query returns metrics for a single creative. Note that the start/end dates are supported, but are not used.

```graphql
query CampaignCreativeReportByDay($input: CampaignCreativeInput!, $startDate: Date!, $endDate: Date!) {
  campaignCreative(input: $input) {
    reports {
      byDay(startDate: $startDate, endDate: $endDate) {
        date: day(format: "YYYYMMDD")
        metrics {
          views
          clicks
          ctr
        }
      }
    }
  }
}
```

</details>
