collection.setBackgroundImage

Uploads a background image to the specified collection.

Note: Requests must be made to https://upload.flipsnack.com/v1.

Request parameters

Name

Type

Description

apiKey (required)

string

The API key provided for your user. If it is not specified, the request will return the error code "30 - Missing mandatory parameter". If the key is incorrect the request returns the error code "41 - Invalid credentials".

signature (required)

string

The signature must be calculated by you and added to the request. See How to sign a request for more information. If the parameter is missing the request will return the error code "30 - Missing mandatory parameter". If the signature is incorrect the request will return the error code "44 - Invalid signature".

action (required)

string

The API method that should be called. In this case the value should be collection.setBackgroundImage. If it is not specified, the request will return the error code "30 - Missing mandatory parameter".

collectionHash (required)

string

The hash of the collection to which the background image will be added. If it is not specified, the request will return the error code "30 - Missing authentication".

file (required)

file

The image file that will be used as background for the widget. Images can be uploaded either using a local file, through the file parameter, or from an external URL, using the fileUrl parameter. You must specify at least one of them. If both parameters are specified, the API will take into consideration only the file parameter. If neither file or fileUrl are specified the request will return the error code "30 - Missing mandatory parameter". Also, file uploads are bound to API limitations.

fileUrl (required)

string

The URL of an image file that will be used as background for the widget. Images can be uploaded either using a local file, through the file parameter, or from an external URL, using the fileUrl parameter. You must specify at least one of them. If both parameters are specified, the API will take into consideration only the file parameter. If neither file or fileUrl are specified the request will return the error code "30 - Missing mandatory parameter". Also, file uploads are bound to API limitations.

format

string

The format of the response from the server. Possible values are json, jsonp and xml. If you set format to jsonp, you must also specify the callback parameter. Default: json.

callback

string

The name of the callback function used for the jsonp response. This parameter is required if format is set to jsonp. Otherwise it is ignored.

Response parameters

If the request is successful, the API call returns information about the specified collection.

This action method has the same response as collection.getCollection method.

Error codes

Code

Message

Explanation

30

Missing mandatory parameter

The request does not contain one or more required parameters. There are at least 3 required parameters for every request: apiKey, signature and action. Other methods may also have extra mandatory parameters. Please check the API Reference for more information.

31

Requests per second limit exceeded

There were too many requests per second made with the same API key.

32

Requests per minute limit exceeded

There were too many requests per minute made with the same API key.

34

File size too large

The file you have uploaded has a size that exceeds the maximum file size allowed. For more information please see the limitations imposed by the API.

36

Multiple files upload not allowed

Flipsnack API allows only one file per upload request. Upload requests are made via the collection.create, collection.setLogo, collection.setBackgroundImage and flipbook.add.

40

Bad request

  • You made a POST request for an API call that is not uploading files.

  • You made a GET request for an API call that uploads files.

  • Your request is incorrectly formatted or the URL is invalid.

41

Invalid credentials

The API key provided in the request is invalid.

42

Invalid action

The API method you specified in the request is incorrect. Please see the API Reference for the list of possible methods.

43

Forbidden

You are not allowed to access the specified collection: it has been deleted or the collection belongs to another user.

44

Invalid signature

The signature you provided is incorrect - it does not match the request.

45

Invalid file format

The file you are trying to upload has an incorrect file type. For more information please see the limitations imposed by the API.

46

Invalid collection hash

You are trying to access a collection that does not exist.

Example

HTML form example

<form method="post" action="https://upload.flipsnack.com/v1/" enctype="multipart/form-data">
<input type="hidden" name="action" value="collection.setBackgroundImage">
<input type="hidden" name="apiKey" value="LK12NS-0-IOBW3S89VVJH12Z">
<input type="text" name="collectionHash">
<input type="file" name="file">
<button type="submit">Submit</button>
</form>

Curl example

curl -F "action=collection.setBackgroundImage"\
-F "apiKey=LK12NS-0-IOBW3S89VVJH12Z"\
-F "collectionHash=d3m0h45h"\
-F "[email protected]\"/mydocs/background.jpg\";filename=\"background.jpg\""\
-F "signature=2298a6456c1dd2d12b895ce4688ffe31"\
https://upload.flipsnack.com/v1/

Responses

XML

<?xml version="1.0" encoding="utf-8"?>
<response>
<code>20</code>
<status>OK</status>
<data>
<collectionHash>d3m0h45h</collectionHash>
<collectionTitle>Lorem ipsum</collectionTitle>
<collectionStatus>published</collectionStatus>
<collectionItems>
<collectionItem>
<flipbookHash>7c5e600d4459fe4e04d23ae5ei188777</flipbookHash>
<flipbookTitle>Lorem ipsum</flipbookTitle>
<extension>pdf</extension>
<convertStatus>COMPLETE</convertStatus>
</collectionItem>
</collectionItems>
<settings>
<collectionWidth>640</collectionWidth>
<collectionHeight>385</collectionHeight>
</settings>
</data>
</response>

JSON

{
"code": 20,
"status": "OK",
"data": {
"collectionHash": "d3m0h45h",
"collectionTitle": "Lorem ipsum",
"collectionStatus": "published",
"collectionItems": [
{
"flipbookHash": "7c5e600d4459fe4e04d23ae5ei188777",
"flipbookTitle": "Lorem ipsum",
"extension": "pdf",
"convertStatus": "COMPLETE"
}
],
"settings": {
"collectionWidth": "640",
"collectionHeight": "385"
}
}
}

JSONP

callbackFunctionName({data});
// callbackFunctionName is the function name specified by the callback parameter, in the request
// the {data} is the actual JSON response