User temporary key

We'll assume you've already got the API authentication settled and you have our API token with you.

 

Create temporary key #

Temporary keys are used to perform files download. Temporary key lives for one hour. You can create user temporary making POST request to the /api/keys endpoint.

curl -X POST https://privasfer.com/api/keys \
    -H 'Authorization: Bearer 7xcB5XlinBWGzajPdSW7bHr12erWZICIJN4jk0RpasoLYLpoiD6ErYnVSzld' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"pin":"1a2s3d"}'

Form fields #

name description type
pin User pin code. You can read more about pin code here. string

If the API call succeeded, you'll be given output like this.

{
    "data": {
            "key": "FLJevKp6lzyigDQVCB3TReB1mK8iePRZ",
            "expires_at": "2019-05-15 16:42:16"
      }
}

Return properties #

  • key: user temporary key
  • expires_at: date ant time when key will expire

 

Error handling #

If an error occurred, you'll be given a non-HTTP/200 response code. The resulting payload might look like this.

{
    "message": "The given data was invalid.",
    "errors": {
        "pin": [
            "Invalid PIN."
        ]
    }
}

 

Deleting a temporary key #

Use the DELETE request to delete a temporary key through the API. In this example, we'll delete a key fad2027a-ac89-4ef4-baab-95b2fb316cf1.

curl -X DELETE https://privasfer.com/api/keys/FLJevKp6lzyigDQVCB3TReB1mK8iePRZ \
    -H 'Authorization: Bearer 7xcB5XlinBWGzajPdSW7bHr12erWZICIJN4jk0RpasoLYLpoiD6ErYnVSzld' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json'

After successful delete request you will receive a 204 HTTP status.