Skip to main content

Private File Actions

https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Below are the various requests that can be performed against the Private File resource, as well as the expected parameters and the potential responses.

Delete

Deletes a private file or directory, if a directory all the contents that directory will also be removed.

Method And Url

DELETE https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Authentication

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.delete.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
PRIVATE_FILE_IDID associated with the private file575ec76c7ae143cd83dc4a96

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X DELETE \
https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Successful Responses

CodeTypeDescription
200SuccessIf private file was successfully deleted

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if private file was not found

Get

Retrieves information on a private file

Method And Url

GET https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Authentication

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, privateFile.*, or privateFile.get.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
PRIVATE_FILE_IDID associated with the private file575ec76c7ae143cd83dc4a96

Request Query Parameters

NameRequiredDescriptionDefaultExample
urlTTLNTime in seconds that the private file url will be valid for. Only applies to private files of type 'file'. If 0, no url will be returned.900urlTTL=900

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Successful Responses

CodeTypeDescription
200File SchemaPrivate file information

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if private file was not found

Move

Move a private file or the entire contents of a directory

Method And Url

POST https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID/move

Authentication

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.move.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
PRIVATE_FILE_IDID associated with the private file575ec76c7ae143cd83dc4a96

Request Query Parameters

NameRequiredDescriptionDefaultExample
nameNThe new name of the private file or directoryname=fileA
parentDirectoryNThe new parent directory for the private file or directory to move into.parentDirectory=/new/location/here
urlTTLNTime in seconds that the private file url will be valid for. Only applies to private files of type 'file'. If 0, no url will be returned.900urlTTL=900

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID/move

Successful Responses

CodeTypeDescription
201File SchemaReturns a new private file or directory that was created by the move, if a directory a job will kick off to move all the directories children.

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if private file was not found

Patch

Reupload a private file

Method And Url

PATCH https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Authentication

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.patch.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
PRIVATE_FILE_IDID associated with the private file575ec76c7ae143cd83dc4a96

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body

The body of the request should be serialized JSON that validates against the File Patch schema. For example, the following would be a valid body for this request:

{
"fileSize": 500,
"contentType": "image",
"fileDimensions": {
"width": 200,
"height": 200
}
}

Curl Example

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X PATCH \
-d '{"fileSize":500,"contentType":"image","fileDimensions":{"width":200,"height":200}}' \
https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID

Successful Responses

CodeTypeDescription
201File Upload Post ResponseSuccessfully updated private file and the information needed to upload the file content

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if private file was not found

Upload

Uploads the private file

Method And Url

POST https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID/upload

Authentication

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, privateFile.*, or privateFile.upload.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
PRIVATE_FILE_IDID associated with the private file575ec76c7ae143cd83dc4a96

Request Query Parameters

NameRequiredDescriptionDefaultExample
urlTTLNTime in seconds that the private file url will be valid for. Only applies to private files of type 'file'. If 0, no url will be returned.900urlTTL=900

Request Headers

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body

The body of the request should be a multipart form data post containing the following:

NameRequiredDescriptionDefaultExample
privateFileYThe content of the private file to upload``

Curl Example

curl -H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-F privateFile=@localfilename' \
https://api.losant.com/applications/APPLICATION_ID/privateFiles/PRIVATE_FILE_ID/upload

Successful Responses

CodeTypeDescription
200File SchemaUpdated private file content

Error Responses

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if file was not found

Schemas

Error

Schema for errors returned by the API

Error Schema

  • {} 3 keys
    • "http://json-schema.org/draft-07/schema#"
    • "object"
    • {} 2 keys
      • {} 1 key
        • {} 1 key

      Error Example

      • {} 2 keys
        • "NotFound"
        • "Application was not found"

      File Schema

      Schema for a single public or private file

      File Schema Schema

      • {} 3 keys
        • "http://json-schema.org/draft-07/schema#"
        • "object"
        • {} 16 keys
          • {} 2 keys
            • {} 2 keys
              • {} 2 keys
                • {} 2 keys
                  • {} 2 keys
                    • {} 2 keys
                      • {} 2 keys
                        • {} 3 keys
                          • {} 2 keys
                            • {} 2 keys
                              • {} 1 key
                                • {} 1 key
                                  • {} 2 keys
                                    • {} 2 keys
                                      • {} 2 keys
                                        • {} 1 key

                                      File Schema Example

                                      • {} 12 keys
                                        • "575ec8687ae143cd83dc4a97"
                                        • "575ec8687ae143cd83dc4a97"
                                        • "2016-06-13T04:00:00.000Z"
                                        • "2016-06-13T04:00:00.000Z"
                                        • "575ed70c7ae143cd83dc4aa9"
                                        • "user"
                                        • "pending"
                                        • "file.csv"
                                        • "file"
                                        • "/"
                                        • 500
                                        • "text/csv"

                                      File Patch

                                      Schema to patch a public or private file

                                      File Patch Schema

                                      • {} 3 keys
                                        • "http://json-schema.org/draft-07/schema#"
                                        • "object"
                                        • {} 3 keys
                                          • {} 1 key
                                            • {} 2 keys
                                              • {} 2 keys

                                            File Patch Example

                                            • {} 3 keys
                                              • 500
                                              • "image"
                                              • {} 2 keys

                                              File Upload Post Response

                                              Schema with the information needed to upload public or private file contents

                                              File Upload Post Response Schema

                                              • {} 2 keys
                                                • "http://json-schema.org/draft-07/schema#"
                                                • [] 2 items

                                                File Upload Post Response Example

                                                • {} 13 keys
                                                  • "575ec8687ae143cd83dc4a97"
                                                  • "575ec8687ae143cd83dc4a97"
                                                  • "2016-06-13T04:00:00.000Z"
                                                  • "2016-06-13T04:00:00.000Z"
                                                  • "575ed70c7ae143cd83dc4aa9"
                                                  • "user"
                                                  • "pending"
                                                  • "file.csv"
                                                  • "file"
                                                  • "/"
                                                  • 500
                                                  • "text/csv"
                                                  • {} 2 keys

                                                  Success

                                                  Schema for reporting a successful operation

                                                  Success Schema

                                                  • {} 3 keys
                                                    • "http://json-schema.org/draft-07/schema#"
                                                    • "object"
                                                    • {} 1 key
                                                      • {} 2 keys

                                                    Success Example

                                                    • {} 1 key
                                                      • true

                                                    Was this page helpful?


                                                    Still looking for help? You can also search the Losant Forums or submit your question there.