Adding Products to the Social Print Studio Shopify Cart

Overview

Social Print Studio provides an API endpoint that lets external applications add products to our Shopify cart. Your app sends a simple JSON payload describing what to add, and receives a URL to redirect the customer to. The customer lands on our Shopify cart with the product already added, and can then checkout and pay for their order directly on our website. We will process and print the order and handle any customer service or issues.

You do not need

You do need:


Endpoint

POST https://editor-staging.socialprintstudio.com/api/cart/external-app-addToCart
Content-Type: application/json

Request Body

Required Fields

FieldTypeDescription
sku string The Shopify product SKU. Must exactly match a variant SKU in our Shopify store.
source string An identifier for your application (e.g. "my-app-name"). Used for tracking and debugging.
projectData object Project/order data to persist for fulfillment. All products offered via this API are custom printed and require project data. See Project Data below.

Optional Fields

FieldTypeDefaultDescription
quantity number 1 How many copies of this exact product to add to the cart. Must be a positive integer.
properties object {} Extra key-value pairs to attach to the Shopify line item. See Line Item Properties below.

Project Data

The projectData object contains the custom content (photos, designs, etc.) that our fulfillment team needs to access when producing the order. Since all products offered via this API are custom printed, this field is required.

When you include projectData, the data is saved to our project database and a unique projectId is generated. This ID is automatically attached to the Shopify line item so our fulfillment team can access your photos and project data when producing the order.

FieldTypeDescription
projectData.photos string[] Array of image URLs used in the product. These must be publicly accessible URLs that our fulfillment system can download when producing the order. At least one photo URL is required. If your app doesn't have its own image hosting, you can use our Image Upload API to get public URLs.
projectData.metadata object Any arbitrary data you want to persist with the project — editor state, template options, customer preferences, etc. Can contain any JSON-serializable structure. Only several products require specific metadata; in general it is not required.

Photo URL Requirements

RequirementDetails
Formats JPG or PNG recommended.
Max file size 50 MB per image.
URL validity URLs must remain publicly accessible for at least one week after the order is placed. Our fulfillment system downloads images during production, which may not happen immediately after checkout.
Image quality tip: If your app exports or compresses images before uploading, make sure you are using 100% quality (no lossy compression) when appropriate. These images are used for physical printing — maintaining the highest resolution and quality ensures print-ready output. Downsampled or heavily compressed images may result in visible artifacts in the final print.

Line Item Properties

The properties object lets you attach key-value string pairs directly to the Shopify cart line item. These are visible in the Shopify order admin and available to our fulfillment systems.

Convention: Prefix property keys with _ (underscore) to hide them from the customer on the storefront. Properties without the underscore prefix will be visible to the customer in their cart and order confirmation.
Example KeyDescription
_project_Id A project ID from your app (hidden from customer, visible in our admin). Useful for troubleshooting or looking up an order later.
_cover_preview_url Optional URL shown as a preview/thumbnail image of the finished product in the cart.
Edit Project Link A URL that lets someone go back to your app to edit the project from the cart.
Project Name An optional customer-facing name. Visible to the customer with their item in the cart (no underscore prefix = visible).

Response

Success (200)

{
  "success": true,
  "redirectUrl": "https://socialprintstudio.com/pages/newcart?cartKey=prod_1707400000_abc123def",
  "projectId": "65a1b2c3d4e5f6a7b8c9d0e1"
}
FieldTypeDescription
success boolean true if the item was staged successfully.
redirectUrl string The URL to redirect the customer's browser to. This adds the item to their Shopify cart.
projectId string The database ID of the saved project. You can store this for your own records.
After receiving the response, redirect the customer's browser to redirectUrl. The redirect URL is single-use — it works once and then expires.

Error Responses

StatusMeaning
400Missing or invalid required field (sku, source, or projectData). Check the error message for details.
405Wrong HTTP method. Use POST.
502The SKU could not be resolved to a Shopify product. It likely doesn't match any variant in our store.
500Internal server error. Contact us if this persists.

All error responses include an error field with a human-readable message:

{
  "error": "Missing required field: \"sku\" (string). This should be the Shopify product SKU."
}

Examples

Minimal Example — Simple Photo Product

A minimal request with required fields. All products offered via this API are custom printed and require project data with at least one photo URL.

const response = await fetch(
  'https://editor-staging.socialprintstudio.com/api/cart/external-app-addToCart',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      sku: 'metal-print-4x4',
      source: 'my-partner-app',
      projectData: {
        photos: [
          'https://cdn.example.com/uploads/user123/photo-sunset.jpg',
        ],
      },
    }),
  }
);

const { redirectUrl } = await response.json();

// Send the customer to the Shopify cart
window.location.href = redirectUrl;

Full Example — Photo Product with Metadata

A product that includes customer photos and extra metadata for fulfillment.

const response = await fetch(
  'https://editor-staging.socialprintstudio.com/api/cart/external-app-addToCart',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      sku: 'softcover-8x8-40',
      quantity: 1,
      source: 'my-partner-app',

      projectData: {
        photos: [
          'https://cdn.example.com/uploads/user123/cover-file.jpg',
          'https://cdn.example.com/uploads/user123/photo-beach-sunset.jpg',
          'https://cdn.example.com/uploads/user123/photo-family-portrait.jpg',
        ],
        metadata: {
          bookTitle: 'Summer Vacation 2025',
          customerNotes: 'Extra information stored on the order as a record',
        },
      },

      properties: {
        'Project Name': 'Summer Vacation 2025',
        _cover_preview_url:
          'https://cdn.example.com/previews/user123/cover-thumb.jpg',
      },
    }),
  }
);

const data = await response.json();

if (!response.ok) {
  console.error('Failed to add to cart:', data.error);
  return;
}

// Optionally save the projectId for your own records
console.log('Project saved with ID:', data.projectId);

// Redirect the customer to the Shopify cart
window.location.href = data.redirectUrl;

Example with Multiple Quantity

const response = await fetch(
  'https://editor-staging.socialprintstudio.com/api/cart/external-app-addToCart',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      sku: 'photo-print-30x40',
      quantity: 3,
      source: 'my-partner-app',
      projectData: {
        photos: [
          'https://cdn.example.com/photo1.jpg'
        ],
      },
    }),
  }
);

const { redirectUrl } = await response.json();
window.location.href = redirectUrl;

SKU Requirements

The sku value must exactly match a product variant SKU in our Shopify store. If the SKU doesn't match, the API will return a 502 error.

Things to keep in mind:


Integration Flow Diagram

┌─────────────────────┐
│   Your Application   │
│                     │
│  1. User finishes   │
│     creating their  │
│     product         │
│                     │
│  2. POST to         │
│     /api/cart/      │
│     external-app-   │
│     addToCart        │
│     with SKU +      │
│     project data    │
└────────┬────────────┘
         │
         ▼
┌─────────────────────┐
│   Our API Endpoint   │
│                     │
│  3. Saves project   │
│     data to our DB  │
│                     │
│  4. Resolves SKU to │
│     Shopify variant │
│                     │
│  5. Stages cart     │
│     items           │
│                     │
│  6. Returns         │
│     redirectUrl     │
└────────┬────────────┘
         │
         ▼
┌─────────────────────┐
│  Your app redirects  │
│  the user's browser  │
│  to redirectUrl      │
└────────┬────────────┘
         │
         ▼
┌─────────────────────┐
│   Shopify Cart Page  │
│                     │
│  7. Fetches staged  │
│     cart data       │
│                     │
│  8. Adds items to   │
│     the Shopify     │
│     cart             │
│                     │
│  9. Customer sees   │
│     their cart and  │
│     can check out   │
└─────────────────────┘

Important Notes

  1. The redirect URL is single-use. Once the Shopify cart page retrieves the cart data, the key is deleted. Do not attempt to reuse it.
  2. Photo URLs must be publicly accessible. Our fulfillment system needs to download these images when producing the order. URLs behind authentication or on localhost will not work. URLs must remain valid for at least one week — see Photo URL Requirements for format, size, and quality guidance. If you need a simple way to host images, we provide an optional Image Upload API that returns public URLs you can use directly in projectData.photos.
  3. The source field is important. It helps us track which app generated the order and debug issues. Pick a consistent, descriptive identifier for your app and use it on every request.
  4. CORS is enabled. You can call this endpoint from client-side JavaScript in the browser. If you call it from a backend server, just pass the redirect URL to the customer's browser for the final redirect step.
  5. Request size limit is 10 MB. If you're including many photo URLs or large metadata objects, keep the total payload under 10 MB.
  6. The projectId in the response is the database reference for the saved project. You may want to store this in your own system for debugging or support conversations.