Skip to content
Last updated

Welcome to Juniper Health's Order Fulfillment API! This quickstart guide will help you get started with Juniper's order fulfillment API, allowing you to make your first API call and begin exploring the possibilities of offloading your inventory and fulfillment workloads to Juniper.

Step 1: Sign Up and Get Your API Key

  1. Email us at sales@juniperhealth.com to get in touch with our sales team to discuss partnering with Juniper Health for your fulfillment needs.
  2. Receive your OAuth credentials from the Juniper team.

Step 2: Generate an Access Token

Let's start by generating an access token with your client id and secret. Once we have an access token we can begin making calls to the API endpoints.

Use the following curl command to generate an access token:

curl -X POST https://auth.fulfillment.sandbox.juniperhealth.com/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET"
  • client_id: The client id provided to you by the Juniper engineering team.
  • client_secret: The client secret provided to you by the Juniper engineering team.

Response Example

{
  "access_token": "eyJraWQiOiJ...LLGFVEnZ9PhJQ",
  "expires_in": 3600,
  "token_type": "Bearer"
}

This response confirms that the access token has been generated and provides an expires_in parameter indicating how long the token is valid before a new one needs to be generated.

Step 3: Retrieve Products

Next, let's pull product information to see what products are available when creating an order.

curl -X GET https://api.fulfillment.sandbox.juniperhealth.com/v1/products \
  -H "Authorization: Bearer eyJraWQiOiJrVnRvNHBGQ...meCMjLLGFVEnZ9PhJQ"
  • Authorization: Bearer plus the access token we retrieved from step 2.

Response Example

{
  "products": [
    {
      "id": 7184241754206,
      "name": "SAMe",
      "description": "SAM-E is a naturally occurring compound in the body that aids in neurotransmitter synthesis, energy production in the brain, cell membrane function, and cartilage metabolism.",
      "recommendedUsage": {
        "morning": 1,
        "afternoon": 0,
        "evening": 0,
        "sleep": 0
      },
      "supplementFactsPanel": {
        "servingSize": 1,
        "otherIngredients": [
          "Hypromellose (cellulose capsule)",
          "Microcrystalline Cellulose",
          "Magnesium Stearate (vegetable source)",
          "Silicon Dioxide"
        ],
        "ingredientInformation": [
          {
            "name": "SAMe (S-Adenosyl-L-Methionine)",
            "value": "200",
            "unit": "mg",
            "dailyValue": null
          }
        ],
        "nutritionInformation": []
      },
      "price": "0.93",
      "discountedPrice": "0.84",
      "status": "ACTIVE",
      "form": "capsule",
      "image": "https://cdn.shopify.com/s/files/1/0570/9955/0814/files/SAMe200mg.png?v=1723484386",
      "packDescription": "Nervous System Support",
      "allergens": ["gluten_free"],
      "certifications": ["vegan", "kosher", "halal", "non_gmo"],
      "createdAt": "2025-04-02T13:24:40.388693Z",
      "updatedAt": "2025-04-02T13:24:40.388699Z"
    }
  ],
  "cursor": "eyJwayI6ICJQUk9EVUNUIzcxODQyNDEzOTM3NTgiLCAic2siOiAiUFJPRFVDVCM3MTg0MjQxMzkzNzU4In0="
}

Step 4: Retrieve Shipping Methods

Returns eligible shipping methods and pricing based on your agreement with Juniper.

curl -X GET https://api.fulfillment.sandbox.juniperhealth.com/v1/shipping-methods \
  -H "Authorization: Bearer eyJraWQi...qUSw"

Response Example

{
  "shippingMethods": [
    {
      "name": "STANDARD",
      "description": "Standard shipping delivery 5-8 business days",
      "price": "9.99"
    },
    {
      "name": "EXPRESS",
      "description": "Express shipping delivery 2-3 business days",
      "price": "19.99"
    },
    {
      "name": "OVERNIGHT",
      "description": "Overnight shipping delivery next business day",
      "price": "29.99"
    }
  ]
}

Step 5: Create an Order

Now that we have our product and shipping data we can create an order for Juniper to fulfill.

curl -X POST https://api.fulfillment.sandbox.juniperhealth.com/v1/orders \
  -H "Authorization: Bearer eyJraWQiOi...oFXfDUNQ" \
  -H "Content-Type: application/json" \
  -d '{
    "daysSupply": 30,
    "orderType": "SUBSCRIPTION",
    "shippingMethod": "STANDARD",
    "customer": {
      "sourceId": "src123",
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "phone": "5551234567",
      "address": {
        "line1": "123 Main St",
        "line2": "Suite 200",
        "city": "Anytown",
        "state": "CA",
        "zipCode": "12345"
      }
    },
    "lineItems": [
      {
        "productId": 7294312317022,
        "quantity": 2,
        "packDescription": "Daily Wellness",
        "administration": {
          "morning": 1,
          "afternoon": 0,
          "evening": 1,
          "sleep": 0
        }
      }
    ]
  }'

Response Example

{
  "id": "2vE9vnqodHisA0JJx1pvN2XqJJa",
  "status": "NEW",
  "customer": {
    "firstName": "John",
    "lastName": "Doe",
    "sourceId": "src123",
    "email": "john.doe@example.com",
    "phone": "5551234567",
    "address": {
      "line1": "123 Main St",
      "line2": "Suite 200",
      "city": "Anytown",
      "state": "CA",
      "zipCode": "12345"
    }
  },
  "discount": "10%",
  "daysSupply": 30,
  "orderType": "SUBSCRIPTION",
  "shippingMethod": "STANDARD",
  "lineItems": [
    {
      "id": "2vE8C1kTAbF7dQ5ov03iIjmSthf",
      "productId": 7294312317022,
      "name": "5-HTP",
      "quantity": 2,
      "packDescription": "Daily Wellness",
      "price": "0.53",
      "discountedPrice": "0.48",
      "totalPrice": "28.80",
      "external": false,
      "administration": {
        "morning": 1,
        "afternoon": 0,
        "evening": 1,
        "sleep": 0
      }
    }
  ],
  "subtotalPrice": "31.80",
  "totalDiscount": "3.18",
  "totalFees": "0.00",
  "totalShipping": "9.99",
  "totalVolumeDiscount": "0.00",
  "totalPrice": "38.61",
  "fulfillmentInfo": null,
  "createdAt": "2025-04-03T16:45:41.435164Z",
  "updatedAt": "2025-04-03T16:45:41.435304Z"
}

This response confirms that you've successfully created an order!

Step 6: Cancel an Order

Finally, let's cancel our order. Note: Orders can only be cancelled while in NEW status.

Use the following curl command:

curl -X POST https://api.fulfillment.sandbox.juniperhealth.com/v1/orders/2vE9vnqodHisA0JJx1pvN2XqJJa/cancel \
  -H "Authorization: Bearer eyJraWQiOi...xoFXfDUNQ"

Response Example

{
  "orderId": "2vE9vnqodHisA0JJx1pvN2XqJJa",
  "status": "CANCELLED"
}

This response indicates that your order has been cancelled.

Congratulations!

You've completed the quickstart guide! Explore more advanced features in our API documentation.

Next Steps