Using Datasyncs via APIs

Last updated:
4 min read

The data syncs REST API allows you to operate with different types of synchronizations -import, export, and removal- to keep your app automatically up to date with your data sources.

Authentication

All data synchronization APIs can be authenticated if you wish. This must be enabled in each data sync and an auth token is generated that will then be sent in each API concoction.

Every request must provide a basic authentication header.

ParameterDescription
usernameapi
passwordAPI_TOKEN

Each token is data sync specific, in this way we can remove a data sync without affecting the operation of the rest.

Import

This endpoint allows you to interact with the API to import customers, customers’ campaign data, or priorities (optimized model). In the latter case, the columns of the file to be synchronized must be those that are explicit in the model import.

URLMethod
/api/data-sync/import/DATASYNC_IDPOST

The DATASYNC_ID field is a unique data sync ID provided by the Prisma campaigns platform.

Request information must be a valid multipart form-data.

The form data must meet the following schema:

ParameterDescription
fileCSV file to be imported

The result is defined by one of the following HTTP status codes:

CodeDescriptionBody
200The operation was completed successfullyFile queued
404Data sync not found
403Auth failure
500Internal error

Export

This endpoint enables you to interact with the API to export customers, campaign results, or unsubscribes. This API will return the latest successful launch.

URLMethod
/api/data-sync/export/DATASYNC_IDGET

The DATASYNC_ID field is a unique data sync ID provided by the Prisma campaigns platform.

The result is defined by one of the following HTTP status codes:

CodeDescriptionBody
200The operation was completed successfullyCSV File
404Data sync not found
403Auth failure
500Internal Error

Removal

This API uses the same spec as the Import API.

Data Sync Status

This endpoint provides a way to obtain the latest information about a data sync execution of any type (import, export, removal).

URLMethod
/api/data-sync/DATASYNC_IDGET

The DATASYNC_ID field is a unique data sync ID provided by the Prisma campaigns platform.

The result is defined by one of the following HTTP status codes:

CodeDescription
200The operation was completed successfully
404Data sync not found
403Auth failure
500Internal Error

The response is an EDN or JSON object which includes the following information:

{
  :name "Datasync Name"
  :status "enabled"
  :latest-launch {
    :id XXXXXXXXXXXXX,
    :status "cancelled",
    :scheduled-time "2022-01-14T20:00:00",
    :status-message "Cancelled by user: admin@prismacampaigns.com"
  }
  :next-launch "2022-01-17T13:00:00"
}
{
  "name": "Datasync Name",
  "status": "enabled",
  "latest-launch": {
    "id": XXXXXXXXXXXXX,
    "status": "cancelled",
    "scheduled-time": "2022-01-14T20:00:00",
    "status-message": "Cancelled by user: admin@prismacampaigns.com"
  },
  "next-launch": "2022-01-17T13:00:00"
}
KeyDescriptionPossible Results
nameData sync Name
statusData sync Statusenabled, disabled
latest-launchObject with the latest execution status (optional)
next-launchDate time (UTC) of the next execution (optional)

Latest Launch Schema

KeyDescriptionPossible Results
idLast execution ID (useful to download launch files)
statusLatest execution statusscheduled, finished, cancelled, running
scheduled-timeSchedule Date time (UTC)
started-atDate time (UTC) when the launch was started (optional)
status-messageIn case of an error, a status message with useful information (optional)
next-launchDate time (UTC) of the next execution (optional)

Note: The server may return an EDN or JSON object, depending on the content of the Accept and Content-Type headers. It is worth noting that the latter is mandatory.

Latest Launches

This endpoint returns the latest data sync launches of any type (import, export, removal).

URLMethod
/api/data-sync/DATASYNC_ID/latest-launchesGET

The DATASYNC_ID field is a unique data sync ID provided by the Prisma campaigns platform.

The result is defined by one of the following HTTP status codes:

CodeDescription
200The operation was completed successfully
404Data sync not found
403Auth failure
500Internal error

The response is an array of EDN or JSON object which includes the following information:

[{:id XXXXXXXXXXXXX
  :status "cancelled"
  :scheduled-time "2022-01-14T20:00:00"
  :status-message "Cancelled by user: admin@prismacampaigns.com"
  }

  {:id XXXXXXXXXXXXX
   :status "finished"
   :scheduled-time "2022-01-13T20:00:00"
   }
]
[{"id": XXXXXXXXXXXXX,
  "status": "cancelled",
  "scheduled-time": "2022-01-14T20:00:00",
  "status-message": "Cancelled by user: admin@prismacampaigns.com"
  },

  {"id": XXXXXXXXXXXXX,
   "status": "finished",
   "scheduled-time": "2022-01-13T20:00:00"
   }
]
KeyDescriptionPossible Results
idLast execution ID (useful to download launch files)
statusLatest execution statusscheduled, finished, cancelled, running
scheduled-timeSchedule Date time (UTC)
started-atDate time (UTC) when the launch was started (optional)
status-messageIn case of an error, a status message with useful information (optional)
next-launchDate time (UTC) of the next execution (optional)

Note: The server may return an EDN or JSON object, depending on the content of the Accept and Content-Type headers. It is worth noting that the latter is mandatory.

Launch Download

This endpoint makes it possible to download the file generated for a specific launch of a data sync of any type (import, export, removal).

This API is useful if one of the synchronization processes failed, and we want to import the files again, or if we want to examine a faulty imported file.

URLMethod
/api/data-sync/DATASYNC_ID/LAUNCH_ID/downloadGET

The DATASYNC_ID field is a unique data sync ID provided by the Prisma campaigns platform, whereas LAUNCH_ID field represents a unique launch ID that can be obtained by querying the latest-launches API.

The result is defined by one of the following HTTP status codes:

CodeDescriptionBody
200The operation was completed successfullyGenerated CSV file
404Data sync not found
403Auth failure
500Internal error

Was this article helpful?