POST /v3/downloads/{scanId}/export/{exportId}

One of the most common patterns, when integrating with our services, is to submit a scan and download the full results as soon as the scan is completed. When the scan is completed, Copyleaks triggers a ‘Completed’ webhook to inform that the scan has been completed. At this point, you will have all the needed information (i.e. the ‘result ids’) to download and present the reports on your side. Since you may have large number of documents to download (the results, crawled version of the text and the pdf-report), you may need to send many HTTP REST calls to execute to export the data from our services.

The ‘Export’ method makes this process easier by specifying the content you would like to export in a single call and we will copy all the data according to your request. Then, we will fire an ‘export-completed; webhook with the export results summary.

If you are using a distributed cloud storage system (like AWS buckets, Google buckets or Azure Storage), we are able to export the data directly to your storage without the involvement of your servers. In order to do so, create a Signed URL for each data item that you would like to export. By specifying the request method (verb) and optionally added headers, the writing to this storage will be triggered, as per your definition.

You need to login with a user and api key in order to access this method.
Add this HTTP header to your request:
Authorization: Bearer <Your-Login-Token>
Not sure how to generate your login token? Read here.

Request

URI Parameters

Name Description

scanId Required

The scan ID of the specific scan to export.

String
Length: 3-36 characters.

Allowed characters are [a-zA-Z0-9] and the following symobols: [email protected]$^&-+%=_(){}<>';:/.",~`|

exportId Required

A new Id for the export process.

String
Length: 3-36 characters.

Allowed characters are [a-zA-Z0-9] and the following symobols: [email protected]$^&-+%=_(){}<>';:/.",~`|

Body Parameters

Name Description

completionWebhook Required

This webhook event is triggered once the export is completed.

String (URI)

maxRetries

How many retries to send before giving up. Using high value (12) may lead to a longer time until the completionWebhook being executed. A low value (1) may lead to errors while your service is temporary having problems.

Unsigned int

Range: 1-12

Default: 3

developerPayload

Add a custom developer payload that will then be provided on the Export-Completed webhook.

String

Max Length: 512

results

An array of results to be exported.

The equivalent of downloading results manually.

Array

Max Legnth: 498 items

results.id Required

Result identification to be downloaded. You get these identifications from the completed webhook.

String

results.endpoint Required

The HTTP url to upload the data.

String (Uri)

results.verb Required

The HTTP verb (also called "HTTP Methods") to upload the data to your specified endpoint.

String

Example: POST

results.headers

List of headers to be submitted with the upload request. You may use this field to provide additional request headers, such as "Authorization" header.

Jagged Array (String)

Example: [["header-key1", "header-value1"], ["header-key2", "header-value2"]]

pdfReport

Download the PDF report. Allowed only when `properties.pdf.create` was set to true on the scan submittion.

The equivalent of downloading results manually.

Object

pdfReport.endpoint Required

The HTTP url to upload the data.

String (Uri)

pdfReport.verb Required

The HTTP verb (also called "HTTP Methods") to upload the data to your specified endpoint.

String

Example: POST

pdfReport.headers

List of headers to be submitted with the upload request. You may use this field to provide additional request headers, such as "Authorization" header.

Jagged Array (String)

Example: [["header-key1", "header-value1"], ["header-key2", "header-value2"]]

crawledVersion

Download the crawled version of the submitted text.

The equivalent of downloading crawled version manually.

Object

crawledVersion.endpoint Required

The HTTP url to upload the data.

String (Uri)

crawledVersion.verb Required

The HTTP verb (also called "HTTP Methods") to upload the data to your specified endpoint.

String

Example: POST

crawledVersion.headers

List of headers to be submitted with the upload request. You may use this field to provide additional request headers, such as "Authorization" header.

Jagged Array (String)

Example: [["header-key1", "header-value1"], ["header-key2", "header-value2"]]

Request Example

curl --location --request POST 'https://api.copyleaks.com/v3/downloads/scan-id/export/export-id' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR-LOGIN-TOKEN' \
--data-raw '{
	"results": [
		{
			"id": "my-result-id",
			"verb": "POST",
			"headers": [
				["header-key", "header-value"]
			],
			"endpoint": "https://yourserver.com/export/export-id/results/my-result-id"
		}
	],
	"pdfReport": {
		"verb": "POST",
		"headers": [
			["header-key", "header-value"]
		],
		"endpoint": "https://yourserver.com/export/export-id/pdf-report"
	},
	"crawledVersion": {
		"verb": "POST",
		"headers": [
			["header-key", "header-value"]
		],
		"endpoint": "https://yourserver.com/export/export-id/crawled-version"
	},
	"completionWebhook": "https://yourserver.com/export/export-id/completed",
	"maxRetries": 3
}'
POST https://api.copyleaks.com/v3/downloads/scan-id/export/export-id

Authorization: Bearer YOUR-LOGIN-TOKEN;

{
	"results": [
		{
			"id": "my-result-id",
			"verb": "POST",
			"headers": [
				["header-key", "header-value"]
			],
			"endpoint": "https://yourserver.com/export/export-id/results/my-result-id"
		}
	],
	"pdfReport": {
		"verb": "POST",
		"headers": [
			["header-key", "header-value"]
		],
		"endpoint": "https://yourserver.com/export/export-id/pdf-report"
	},
	"crawledVersion": {
		"verb": "POST",
		"headers": [
			["header-key", "header-value"]
		],
		"endpoint": "https://yourserver.com/export/export-id/crawled-version"
	},
	"completionWebhook": "https://yourserver.com/export/export-id/completed",
	"maxRetries": 3
}
import requests

url = "https://api.copyleaks.com/v3/downloads/scan-id/export/export-id"

payload = "{\"results\": [{\"id\": \"my-result-id\",\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/results/my-result-id\"}],\"pdfReport\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/pdf-report\"},\"crawledVersion\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/crawled-version\"},\"completionWebhook\": \"https://yourserver.com/export/export-id/completed\",\"maxRetries\": 3}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR-LOGIN-TOKEN'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.copyleaks.com/v3/downloads/scan-id/export/export-id"))
    {
        request.Headers.TryAddWithoutValidation("Authorization", "Bearer YOUR-LOGIN-TOKEN"); 

        request.Content = new StringContent("{\"results\": [{\"id\": \"my-result-id\",\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/results/my-result-id\"}],\"pdfReport\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/pdf-report\"},\"crawledVersion\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/crawled-version\"},\"completionWebhook\": \"https://yourserver.com/export/export-id/completed\",\"maxRetries\": 3}");
        request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); 

        var response = await httpClient.SendAsync(request);
    }
}
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.copyleaks.com',
  'path': '/v3/downloads/scan-id/export/export-id',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR-LOGIN-TOKEN'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({"results":[{"id":"my-result-id","verb":"POST","headers":[["header-key","header-value"]],"endpoint":"https://yourserver.com/export/export-id/results/my-result-id"}],"pdfReport":{"verb":"POST","headers":[["header-key","header-value"]],"endpoint":"https://yourserver.com/export/export-id/pdf-report"},"crawledVersion":{"verb":"POST","headers":[["header-key","header-value"]],"endpoint":"https://yourserver.com/export/export-id/crawled-version"},"completionWebhook":"https://yourserver.com/export/export-id/completed","maxRetries":3});

req.write(postData);

req.end();
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.copyleaks.com/v3/downloads/scan-id/export/export-id",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\"results\": [{\"id\": \"my-result-id\",\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/results/my-result-id\"}],\"pdfReport\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/pdf-report\"},\"crawledVersion\": {\"verb\": \"POST\",\"headers\": [[\"header-key\", \"header-value\"]],\"endpoint\": \"https://yourserver.com/export/export-id/crawled-version\"},\"completionWebhook\": \"https://yourserver.com/export/export-id/completed\",\"maxRetries\": 3\r\n}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer YOUR-LOGIN-TOKEN"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response

Codes

Status Code Description
204

The command was executed. The export started.

400

Bad request. One or more details in your request is wrong.

401

Authorization has been denied for this request

404

The scan id that was specified doesn't exist.

409

Conflict. An export task with the same Id already exists in the system.