Create a session

Sessions in the FastSpring API are point-in-time order sessions, or custom carts, that can be accessed by a session URL. FastSpring returns the URL as a response when you call the /sessions endpoint.

You can then send the URL to a buyer so that they can complete a purchase. FastSpring keeps the session alive for 24 hours.

You can create a session with either a known account identifier or by passing a contact information block, which creates an account ID before generating the session.

After you create a session and send it to a buyer, the buyer has to fill in a number of fields to complete the order.

Unlike custom orders or quotes, sessions you create with the /sessions aren't indexed or searchable in the FastSpring app.

Create a custom order session with single product and no overrides

{
   "account": "uKj7izONRfanVwBL9eiG_A",   // FastSpring-generated customer account ID (previously established via a prior order from this customer, or via the /accounts endpoint)
   "items": [
       {
           "product": "falcon",           // Catalog product path of the product(s) to be included in the order
           "quantity": 1                  // quantity of the current product to be included in the order
       }
   ]
}

Override the price or attach coupon on the session, use contact block to create new account for the session

// Using contact block in lieu of known account ID
{
   "contact": { 
      "first":"John",
      "last":"Doe",     
      "email":"[email protected]",  // If an account already exists with email, it will be latched onto and update
      "company":"String",       			// optional
      "phone":"String",         				// optional
      "country":"US"              			//ISO valid country code
   },
   "language":"en",             			//ISO valid language code
   "lookup":{                     		//optional
      "custom":"customKey"            //a-zA-Z0-9_- String with length greater than or equal to 4 (Alphanumeric unique lookup phrase for searching account)
   },  
   "items": [
       {
           "product": "falcon",       // Catalog product path of the product(s) to be included in the order
           "quantity": 1,             // quantity of the current product to be included in the order
           "pricing": {               // Only needed if overriding catalog price
               "price": {
                   "USD": 7.95        // other currencies supported by the Store may be specified
               }
           }
       }
   ]
}
{
   "account": "uKj7izONRfanVwBL9eiG_A",    // FastSpring-generated customer account ID (previously established via a prior order from this customer, or via the /accounts endpoint)
   "items": [
       {
           "product": "nest",              // product path of the product(s) to be included in the order
           "quantity": 2                   // quantity of the current product to be included in the order
       }
   ],
   "coupon": "0BXB6NMMCT"                  // valid coupon code (not coupon ID) to be applied to the order
}

Update Order session custom tags and product custom attributes on the items in the order

A more complex example where we add 2 products to custom session, then add order tags and custom attributes for each product, also apply arbitrary discount on one.

{
   "account": "N8FjcSWcQNeYCc-suM1O8g",            // FastSpring-generated known customer account ID (previously established via a prior order from this customer, or via the /accounts endpoint) - Alternately you can use contact block 
   "tags":
   {
        "TagKey1": "TagValue1",                   // order tag to be added
        "TagKey2": "TagValue2"                    // order tag to be added
   },
   "items": [
     {
       "product": "product-path",                 // Catalog product path of the product in cart/session
       "attributes": {
         "AttributeKey1": "AttributeValue1",      // product attribute to be added
         "AttributeKey2": "AttributeValue2"       // product attribute to be added
       }
     },{ 
       "product":"some-monthly-subscription",     // catalog product-path of second item in cart/session whose pricing is overridden
       "quantity":1,
       "pricing":{
          "trial":0,                              // days
          "renew":"auto",                         // or "manual", "opt-auto", "opt-manual"
          "interval":"month",                     // or "adhoc", "day", "week", "year"
          "intervalLength":1,                     // required if "interval" is specified and is not "adhoc"
          "quantityBehavior":"allow",             // or "lock" or "hide"
          "quantityDefault":1,
          "price": {
             "USD": 14.95,
             "EUR": 10.99
          },
          "discountType": "percent", // percent or amount
          "discountDuration": 2,
          "quantityDiscounts": {
            "1": 50.0 // percent if type = percent; "1": {"USD": 0.00} // if type = amount
          }
       },
       "attributes": {
          "ATTRIBUTE1": "value1"
       }
     }
   ]
Language
Authorization
Basic
base64
:
Click Try It! to start a request and see the response here!