Skip to main content

PeakPrivacy Files API

PeakPrivacy’s Files API allows uploading, listing, retrieving, and deleting files with supported MIME types (e.g. pdf, txt, csv, docx, images) via authenticated requests.

Fabio Duó avatar
Written by Fabio Duó
Updated over 4 months ago

Auth

HEADERS

Key

Value

Api-token

api_token from

X-Requested-With

XMLHttpRequest

Accept

application/json

401 - Unauthenticated; API Token is invalid or expired OR Subscription is inactive

{
"error": "Unauthenticated"
}

POST Upload files

https://api.peakprivacy.ch/v1/files

REQUEST BODY SCHEMA

Key

Value

files[]

file
Multiple file uploader

Example request

Path for to file must be with @ when use are using curl for uploading files.

curl --location --request POST 'https://api.peakprivacy.ch/v1/files' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \
-F "files[]=@/path/to/data1.json" \
-F "files[]=@/path/to/data2.json" \
-F "files[]=@/path/to/file3.json"

Possible Responses

200 - Success

[
{
"id": "ab4552c5-dc9e-4862-a50c-36809abe0ed9",
"name": "data1.json",
"ext": "json",
"size": 568959,
"mimetype": "application/json"
},
{
"id": "09b8310a-90b9-4d1f-80e5-ab028a8d60c8",
"name": "data3.json",
"ext": "json",
"size": 218671,
"mimetype": "application/json"
},
{
"id": "80185a61-8f84-4a56-8713-e7d0b157ecd4",
"name": "data3.json",
"ext": "json",
"size": 118531,
"mimetype": "application/json"
}
]

400 - Bad Request; Validation Error

{
"message": "Validation error",
"errors": {
"files.0": [
"The data1.txt file must be with correct mimetype."
]
}
}

401 - Unauthenticated; Form Token Expired

{
"error": "Unauthenticated"
}

403 - Forbidden; Subscription amount limit has been reached

{
"error": "Subscription amount limit has been reached"
}

413 - Forbidden;

{
"error": "Request Entity Too Large"
}

GET List files

https://api.peakprivacy.ch/v1/files

GET Parameters

Key

Value

limit

int (optional)
default: 20
Per page files

cursor

string (optional)
Pagination cursor

Example request

curl --location --request GET 'https://api.peakprivacy.ch/v1/files' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json'

Possible Responses

200 - Success

{
"data": [
{
"id": "ab4552c5-dc9e-4862-a50c-36809abe0ed9",
"name": "data1.json",
"ext": "json",
"size": 568959,
"mimetype": "application/json"
},
{
"id": "09b8310a-90b9-4d1f-80e5-ab028a8d60c8",
"name": "data3.json",
"ext": "json",
"size": 218671,
"mimetype": "application/json"
},
{
"id": "80185a61-8f84-4a56-8713-e7d0b157ecd4",
"name": "data3.json",
"ext": "json",
"size": 118531,
"mimetype": "application/json"
}
],
"links": {
"first": null,
"last": null,
"prev": "{{ $frontmatter.global.apiUrl }}/v1/files?cursor=eyJhaV9maWxlcy5pZCI6NjEsIl9wb2ludHNUb05leHRJdGVtcyI6ZmFsc2V9",
"next": "{{ $frontmatter.global.apiUrl }}/v1/files?cursor=eyJhaV9maWxlcy5pZCI6NjMsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0"
},
"meta": {
"path": "{{ $frontmatter.global.apiUrl }}/v1/files",
"per_page": 3,
"next_cursor": "eyJhaV9maWxlcy5pZCI6NjMsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": "eyJhaV9maWxlcy5pZCI6NjEsIl9wb2ludHNUb05leHRJdGVtcyI6ZmFsc2V9"
}
}

401 - Unauthenticated; Form Token Expired

{
"error": "Unauthenticated"
}

GET Retrieve file

https://api.peakprivacy.ch/v1/files/{id}

REQUEST PARAMETERS

Key

Value

id

string required

ID of the file to use.

Example request

curl --location --request GET 'https://api.peakprivacy.ch/v1/files/{id}' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json'

Possible Responses

200 - Success

{
"id": "ab4552c5-dc9e-4862-a50c-36809abe0ed9",
"name": "data1.json",
"ext": "json",
"size": 568959,
"mimetype": "application/json"
}

401 - Unauthenticated; Form Token Expired

{
"error": "Unauthenticated"
}

404 - Not Found; File not found

{
"error": "Not found"
}

DELETE Delete file

https://api.peakprivacy.ch/v1/files/{id}

HEADERS

Key

Value

Api-token

api_token from

https://app.peakprivacy.ch/api-tokens

X-Requested-With

XMLHttpRequest

Accept

application/json

REQUEST PARAMETERS

Key

Value

id

string required

ID of the file to use.

Example request

curl --location --request DELETE 'https://api.peakprivacy.ch/v1/files/{id}' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json'

Possible Responses

204 - Success

NO CONTENT

401 - Unauthenticated; Form Token Expired

{
"error": "Unauthenticated"
}

404 - Not Found; File not found

{
"error": "Not found"
}


Supported files

For text/ MIME types, the encoding must be one of utf-8, utf-16, or ascii.

FILE FORMAT

MIME TYPE

csv

application/csv

text/csv

epub

application/epub+zip

xls

application/vnd.ms-excel*

application/vnd.oasis.opendocument.spreadsheet

application/vnd.openxmlformats-officedocument.spreadsheetml.*

xlsx

application/vnd.ms-excel*
application/vnd.oasis.opendocument.spreadsheet
application/vnd.openxmlformats-officedocument.spreadsheetml.*

htm

text/html

html

text/html

md

text/markdown

odt

application/msword

application/vnd.ms-word*

application/vnd.oasis.opendocument.text

application/vnd.openxmlformats-officedocument.wordprocessingml.

application/vnd.ms-excel

application/vnd.oasis.opendocument.spreadsheet

application/vnd.openxmlformats-officedocument.spreadsheetml.

application/vnd.ms-powerpoint

application/vnd.oasis.opendocument.presentation

application/vnd.openxmlformats-officedocument.presentationml.*

pdf

application/pdf

txt

text/plain

text

text/plain

log

text/plain

ppt

application/vnd.ms-powerpoint*

application/vnd.oasis.opendocument.presentation

application/vnd.openxmlformats-officedocument.presentationml.*

pptx

application/vnd.ms-powerpoint*

application/vnd.oasis.opendocument.presentation

application/vnd.openxmlformats-officedocument.presentationml.*

rst

text/x-rst

rtf

application/rtf

text/rtf

tsv

text/tab-separated-values

doc

application/msword

application/vnd.ms-word*

application/vnd.oasis.opendocument.text

application/vnd.openxmlformats-officedocument.wordprocessingml.*

docx

application/msword

application/vnd.ms-word*

application/vnd.oasis.opendocument.text

application/vnd.openxmlformats-officedocument.wordprocessingml.*

xml

application/xml

application/xhtml+xml

text/xml

png

image/png

jpeg

image/jpeg

jpg

image/jpeg

heic

image/heic

tiff

image/tiff

jp2

image/jp2

gif

image/gif

webp

image/webp

bmp

image/bmp

pnm

image/x-portable-anymap

Did this answer your question?