Use this endpoint to view (GET) all existing Library folders, and to create (POST) a new folder.
Click a method to view its documentation
Privileges required: campaign:write
Create a new event using a properly formatted JSON request payload, as shown in the Example JSON Request Body.
Privileges required: mylibrary:file:create
The POST method adds a file to a Library folder using the multipart form content-type. If there are no folders in the account, set folder_id = 0.
NOTE: Set the Content-Type header to multipart/form-data.
The currently supported file types you can add using POST are:
The multipart request needs to include the parts defined in the Structure section.
Here's an example of a multipart encoded post in Java that uploads an image file (dinnerplate-special.jpg) to a user's Library:
import java.io.File;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
public class Test {
/** * @param args
* @throws IOException
* @throws ClientProtocolException
*/
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://api.constantcontact.com/v2/library/files");
httppost.addHeader("Authorization", "Bearer 70e8e17d-e1ed-4b7a-8a8a-40383d74d467");
httppost.addHeader("Accept", "application/json");
httppost.addHeader("Content-type", "multipart/form-data");
File fileToUse = new File("/path_to_file/YOLO.jpg"); //e.g. /temp/dinnerplate-special.jpg
FileBody data = new FileBody(fileToUse);
String file_type = "JPG" ;
String description = "Oppa Gangnam Style";
String folder_id = "-1";
String source = "MYCOMPUTER" ;
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("file_name", new StringBody( fileToUse.getName() ) );
reqEntity.addPart("folder_id", new StringBody(folder_id));
reqEntity.addPart("description", new StringBody(description));
reqEntity.addPart("source", new StringBody(source));
reqEntity.addPart("file_type", new StringBody(file_type));
reqEntity.addPart("data", data);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
System.out.println( response ) ;
HttpEntity resEntity = response.getEntity();
System.out.println( resEntity ) ;
System.out.println( EntityUtils.toString(resEntity) );
EntityUtils.consume(resEntity);
httpclient.getConnectionManager().shutdown();
}
}
See an example coded in Ruby in our Github repository.
The API performs multiple operations in order to POST a file, including performing a virus scan, so processing the POST can take a certain amount of time. You can monitor the request status using the location value in the response header.
See File Upload Status for more information.
Privileges required: mylibrary:folder:create
Create a new MyLibrary folder by providing the name of the folder and the id of the parent folder if the new folder is to be a child folder (nested in another folder) in the JSON request body. See the example JSON request in the following sections.
Privileges required: campaign:write
Create a new item for an event specified using the eventId
path parameter. To create an item, include the following items in the JSON request body:
name
- each item for an event must have a unique name, with mininum length of 1 characterprice
- if an item is available at no cost to registrants and guest, set = 0.00default_quantity_total
- starting quantity of this item available to registrants and guestsper_registrant_limit
- maximum quantity available to each registrant or guestshow_quantity_available
- use this setting to display, or not, the remaining quantity available on the registration page.Optionally you can include a description of the item in the request body as well.
After you create an item, you can then add attributes to it, such as sizes, colors, just to name a few, using the Item Attribute Collection endpoint.
Privileges required: campaign:write
Create a promotional code for an existing event (specified using eventId
). Promotional codes can be:
Privileges required: campaign:write
Create a new fee for the event specified using the eventId
path parameter.
Privileges required: campaign:write
Create a new attribute for an event item; specify the event and item using the eventId
and itemId
path parameters. To create an attribute, include the attribute name
and quantity_total
(minimum = 0) in the JSON request body. Each attribute for an item must have a unique name with a minimum length of 1 character.
Privileges required: campaign:activate
Schedule an email campaign specified by the campaignId
path parameter to run and be sent out. Define the date and time that the email campaign will be submitted to the send queue (in ISO 8601 format) using the scheduled_date
property. You can create a schedule only for an email campaign in DRAFT or SENT status.
When scheduling a campaign, please provide a lead time of at least 20 minutes; otherwise, you may receive an invalid schedule error response.
NOTE: The account must be in good standing to be able to schedule and send an email campaign.
To send a campaign "now", only include {} in the JSON request payload. When using the Send Now function, the response body will show the time that the scheduling request was made, not the time the email campaign will be sent. Send Now puts the campaign into the queue for the next send window, which occur on a regular basis, generally every 5 minutes.
You can resend an existing campaign that has a SENT status using this endpoint. The campaign will only be sent to contacts that have been added to the contact lists since the last time the campaign was sent (based on the last_run_date
value)
Privileges required: campaign:create
When creating a new email campaign, template_type
is automatically set to CUSTOM; There are several campaign properties that are optional by default, but become REQUIRED once another property is used. See Structure table below for specific properties.
POST: https://api.constantcontact.com/v2/library/folders |
|||
name |
type |
default |
description |
---|---|---|---|
api_key |
query |
REQUIRED; The API key for the application |
{ "name": "wildflowers", "parent_id": "-2" }
code |
description |
---|---|
201 |
Library folder was successfully created |
400 |
Either JSON was malformed or there was a data validation error |
401 |
Authentication failure |
406 |
Unsupported accept header value, must be application/json |
409 |
A folder with that name at this level already exists |
415 |
Unsupported content-type in the header, use application/json |
500 |
Internal server error occurred |
property |
type(max length) |
description |
---|
{ "id": "-6", "name": "wildflowers", "level": 2, "children": [], "item_count": 0, "parent_id": "-2", "modified_date": "2013-06-24T13:12:10.000-04:00", "created_date": "2013-06-05T09:31:55.000-04:00" }