addFolder

Creates a new Folder.

addFolder

Creates a new Folder.

Top ↑

Syntax

int addFolder( string api_key, array folder_details );

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

folder_details (array)

An associative array of Folder details. See remarks below for a description of the values in the folder_details array.

Return Value

Returns the ID of the newly added Folder on success.

Examples

The following example shows PHP and JSON code that adds a Folder to your system.

$folder_details = array(
    'name' => $name,
    'type' => 'list'
);

$api = new Api($url, 'YOURAPIKEY');
$new_folder_id = $api->invokeMethod('addFolder', $folder_details);
{
    "id": 1,
    "method": "addFolder",
    "params": [
        "YOURAPIKEY",
        {
            "name": "Newsletters",
            "type": "message"
        }
    ]
}
{
    "id": 1,
    "result": 123456,
    "error": null
}

Remarks

The following table shows the structure of the folder_details array.

Key Type Mandatory Description
name string Yes The name of the Folder. Should be unique.
type string Yes The type of folder. Valid values are: list, message or file.

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
310 Invalid Method Parameters name is empty or missing from the folder_details array.
310 Invalid Method Parameters type is invalid. Must be one of list, message, or file.
302 Undefined Error An internal error occurred.

See Also