- Previous: CafePress API Documentation
- Up: CafePress API Documentation
- Next: Changelists
Getting Started
Here are the minimum steps needed to get started using the API by saving a product with a design on it.
1. Create a CafePress account
http://www.cafepress.com
2. Create an API account and make an appKey. The appKey is used for API calls to identify your API account.
http://developer.cafepress.com/member/register
http://developer.cafepress.com/apps/register
3. Get a userToken. The userToken is used to save and read your data (user tokens expire after 30 minutes of inactivity.)
http://open-api.cafepress.com/authentication.getUserToken.cp?v=3&appKey=YOUR_APP_KEY&email=CAFEPRESS_ACCOUNT_EMAIL&password=CAFEPRESS_ACCOUNT_PASSWORD
Returns a user token in the XML format <value>USER_TOKEN</value>
4. Upload an image using the following test script (you can use this script on your own site as well.)
http://api.cafepress.com/test/upload.htm?appKey=YOUR_APP_KEY&userToken=YOUR_USER_TOKEN
Upon successful upoad the URL will change to the following:
http://api.cafepress.com/test/upload.htm?appKey=YOUR_APP_KEY&userToken=YOUR_USER_TOKEN&value=UPLOADED_IMAGE_ID
5. Choose the merchandise for which you wish to create a product
http://open-api.cafepress.com/merchandise.list.cp?v=3&appKey=YOUR_APP_KEY
Returns a long list of merchandise. Copy the merchandise id that you are interested in.
6. Create a new product for the merchandise type
http://open-api.cafepress.com/product.create.cp?v=3&appKey=YOUR_APP_KEY&merchandiseId=MERCHANDISE_ID&fieldTypes=optional
Returns for merchandise id 2 for example
<?xml version="1.0"?>
<product id="0" name="White T-Shirt" merchandiseId="2" sellPrice="14.99" description="The most comfortable t-shirt ever! Our 100% cotton, Hanes Authentic Tagless T-Shirt is preshrunk, durable and guaranteed. 
<ul><li>6.1 oz. 100% cotton</li>
<li>Standard fit</li></ul>" storeId="" sectionId="0" defaultOrientation="Normal" defaultPerspective="Front" sortPriority="0">
<mediaConfiguration height="10" name="BackCenter" designId="0" />
<mediaConfiguration height="10" name="FrontCenter" designId="0" />
</product>
7. Modify this to the following, applying your uploaded image id to the front of the shirt (if you see any <color> elements just delete them)
<?xml version="1.0"?>
<product id="0" name="My great t-shirt" merchandiseId="2" sellPrice="14.99" description="This is my first t-shirt!">
<mediaConfiguration height="10" name="FrontCenter" designId="UPLOADED_IMAGE_ID" />
</product>
8. Encode the XML to place on in a URL
Visit http://meyerweb.com/eric/tools/dencoder/ or similar sites and paste the product XML. This results in something like:
%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cproduct%20id%3D%220%22%20name%3D%22My%20great%20t-shirt%22%20merchandiseId%3D%222%22%20sellPrice%3D%2214.99%22%20description%3D%22This%20is%20my%20first%20t-shirt!%22%3E%0A%20%20%3CmediaConfiguration%20height%3D%2210%22%20name%3D%22FrontCenter%22%20designId%3D%22UPLOADED_IMAGE_ID%22%20%2F%3E%0A%3C%2Fproduct%3E
9. Save the product:
http://open-api.cafepress.com/product.save.cp?v=3&appKey=YOUR_APP_KEY&userToken=YOUR_USER_TOKEN&value=ENCODED_PRODUCT_XML
If the save succeeds you will see a large product XML definition, like the following. If it fails you will see an error message.
<?xml version="1.0"?>
<product id="NEW_PRODUCT_ID" name="My great t-shirt" merchandiseId="2" sellPrice="14.99" marketplacePrice="22.00" currencyName="US Dollar" currencyCode="USD" currencySymbol="$" description="This is my first t-shirt!" memberId="YOUR_MEMBER_ID" storeId="3664791~" sectionId="0" defaultOrientation="Normal" defaultPerspective="Front" basePrice="14.99" shortCaption="White T-Shirt" defaultCaption="White T-Shirt" shortDescription="White T" categoryId="112" categoryCaption="Shirts (short)" stockAvailability="In Stock." stockAvailabilityStatusId="1" merchandiseAvailability="All Stores | Permanent Item" merchandiseAvailabilityStatusId="3" defaultProductUri="http://images9.cafepress.com/product/NEW_PRODUCT_IDv0_240x240_Front.jpg" marketplaceUri="http://www.cafepress.com/buy/x/-/pv_design_prod/pg_1/p_1314468.NEW_PRODUCT_ID/pNo_NEW_PRODUCT_ID" additionalPhotoCount="4" isCalendar="false" isBook="false" isCD="false" isAudioCD="false" isPoster="false" legacyHeightValue="0" legacyWidthValue="0" sortPriority="0" isSellable="true">
...
</product>
Note that normally you will use an HTTP POST to send XML to the server. We encode the product XML in the URL and send it via an HTTP GET for simpliciity here.
10. View the product on CafePress.com
From the returned product XML copy the URI value of marketplaceUri into a browser to view your new product on CafePress.com
Summary
This completes a very basic example of saving a product with a design on it. The API has many other capabilities, such as creating stores and saving products to a store. For full documentation visit the main documentation page at http://developer.cafepress.com/docs/Home. Also search the forums at http://developer.cafepress.com/forum if you have specific questions not addressed in the forum.
- Previous: CafePress API Documentation
- Up: CafePress API Documentation
- Next: Changelists

Comments
Matt Pelletier – 5 months ago
I am getting an error when trying to hit the authentication URL in step 3 to obtain a user token. I have the API key. I have tried this with both the email and password I had to pick when signing up for a Mashery ID, and I even tried it with my own CafePress account email and password (the language in this documentation is ambiguous about which one it's referring to).
The error is:
HTTP/1.1 596
X-Lighty-Magnet-Uri-Path: /authentication.getUserToken.cp
X-Mashery-Error-Code: ERR_596_SERVICE_NOT_FOUND
Content-Type: text/xml
Accept-Ranges: bytes
Content-Length: 30
Date: Fri, 19 Jun 2009 22:13:14 GMT
Server: lighttpd/1.4.20
Please sign in to post a comment.