Using Datasyncs via APIs
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.
Parameter | Description |
---|---|
username | api |
password | API_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.
URL | Method |
---|---|
/api/data-sync/import/DATASYNC_ID |
POST |
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:
Parameter | Description |
---|---|
file | CSV file to be imported |
The result is defined by one of the following HTTP status codes:
Code | Description | Body |
---|---|---|
200 | The operation was completed successfully | File queued |
404 | Data sync not found | |
403 | Auth failure | |
500 | Internal 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.
URL | Method |
---|---|
/api/data-sync/export/DATASYNC_ID |
GET |
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:
Code | Description | Body |
---|---|---|
200 | The operation was completed successfully | CSV File |
404 | Data sync not found | |
403 | Auth failure | |
500 | Internal 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).
URL | Method |
---|---|
/api/data-sync/DATASYNC_ID |
GET |
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:
Code | Description |
---|---|
200 | The operation was completed successfully |
404 | Data sync not found |
403 | Auth failure |
500 | Internal 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"
}
Key | Description | Possible Results |
---|---|---|
name | Data sync Name | |
status | Data sync Status | enabled , disabled |
latest-launch | Object with the latest execution status (optional) | |
next-launch | Date time (UTC) of the next execution (optional) |
Latest Launch Schema
Key | Description | Possible Results |
---|---|---|
id | Last execution ID (useful to download launch files) | |
status | Latest execution status | scheduled , finished , cancelled , running |
scheduled-time | Schedule Date time (UTC) | |
started-at | Date time (UTC) when the launch was started (optional) | |
status-message | In case of an error, a status message with useful information (optional) | |
next-launch | Date time (UTC) of the next execution (optional) |
Note: The server may return an EDN or JSON object, depending on the content of the
Accept
andContent-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).
URL | Method |
---|---|
/api/data-sync/DATASYNC_ID /latest-launches |
GET |
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:
Code | Description |
---|---|
200 | The operation was completed successfully |
404 | Data sync not found |
403 | Auth failure |
500 | Internal 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"
}
]
Key | Description | Possible Results |
---|---|---|
id | Last execution ID (useful to download launch files) | |
status | Latest execution status | scheduled , finished , cancelled , running |
scheduled-time | Schedule Date time (UTC) | |
started-at | Date time (UTC) when the launch was started (optional) | |
status-message | In case of an error, a status message with useful information (optional) | |
next-launch | Date time (UTC) of the next execution (optional) |
Note: The server may return an EDN or JSON object, depending on the content of the
Accept
andContent-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.
URL | Method |
---|---|
/api/data-sync/DATASYNC_ID /LAUNCH_ID /download |
GET |
The
DATASYNC_ID
field is a unique data sync ID provided by the Prisma campaigns platform, whereasLAUNCH_ID
field represents a unique launch ID that can be obtained by querying thelatest-launches
API.
The result is defined by one of the following HTTP status codes:
Code | Description | Body |
---|---|---|
200 | The operation was completed successfully | Generated CSV file |
404 | Data sync not found | |
403 | Auth failure | |
500 | Internal error |
Related Articles
On this page