Skip to main content

File Actions

https://api.losant.com/applications/APPLICATION_ID/file/FILE_ID

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

Delete

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

Method And Url

DELETE https://api.losant.com/applications/APPLICATION_ID/file/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, file.*, or file.delete.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
FILE_IDID associated with the 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/file/FILE_ID

Successful Responses

CodeTypeDescription
200SuccessIf file was successfully deleted

Error Responses

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

Get

Retrieves information on a file

Method And Url

GET https://api.losant.com/applications/APPLICATION_ID/file/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, file.*, or file.get.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
FILE_IDID associated with the 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 GET \
https://api.losant.com/applications/APPLICATION_ID/file/FILE_ID

Successful Responses

CodeTypeDescription
200File SchemaFile information

Error Responses

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

Move

Move a file or the entire contents of a directory

Method And Url

POST https://api.losant.com/applications/APPLICATION_ID/file/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, file.*, or file.move.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
FILE_IDID associated with the file575ec76c7ae143cd83dc4a96

Request Query Parameters

NameRequiredDescriptionDefaultExample
nameNThe new name of the file or directoryname=fileA
parentDirectoryNThe new parent directory for the file or directory to move into.parentDirectory=/new/location/here

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/file/FILE_ID/move

Successful Responses

CodeTypeDescription
201File SchemaReturns a new 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 file was not found

Patch

Reupload a file

Method And Url

PATCH https://api.losant.com/applications/APPLICATION_ID/file/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, file.*, or file.patch.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
FILE_IDID associated with the 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/file/FILE_ID

Successful Responses

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

Error Responses

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

Upload

Uploads the file

Method And Url

POST https://api.losant.com/applications/APPLICATION_ID/file/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, file.*, or file.upload.

Request Path Components

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
FILE_IDID associated with the file575ec76c7ae143cd83dc4a96

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
fileYThe content of the 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 file=@localfilename' \
https://api.losant.com/applications/APPLICATION_ID/file/FILE_ID/upload

Successful Responses

CodeTypeDescription
200File SchemaUpdated 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.