# Order Fulfillment API

API for creating/managing supplements orders within the Juniper Health platform.

## Authentication

This API uses OAuth 2.0 Client Credentials flow. To obtain an access token:

**Token Endpoints:**
- Sandbox: `https://auth.fulfillment.sandbox.juniperhealth.com/oauth2/token`
- Production: `https://auth.fulfillment.juniperhealth.com/oauth2/token`

**Request:**
```
POST /oauth2/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET
```

**Response:**
```json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in": 3600,
  "token_type": "Bearer"
}
```

Include the token in API requests using the Authorization header:
```
Authorization: Bearer YOUR_ACCESS_TOKEN
```

Version: 1.0.2

## Servers

Sandbox API Server for testing
```
https://api.fulfillment.sandbox.juniperhealth.com/v1
```

Production API Server
```
https://api.fulfillment.juniperhealth.com/v1
```

## Security

### oauth2ClientCredentials

OAuth 2.0 Client Credentials flow for API authentication

Type: oauth2

## Download OpenAPI description

[Order Fulfillment API](https://docs.fulfillment.juniperhealth.com/_bundle/apis/index.yaml)

## Orders

Create, retrieve, and manage customer orders

### Create a New Order

 - [POST /orders](https://docs.fulfillment.juniperhealth.com/apis/orders/createorder.md): Submit a new customer order with product line items and shipping details

### Retrieve Orders

 - [GET /orders](https://docs.fulfillment.juniperhealth.com/apis/orders/listorders.md): Retrieve a list of orders with optional filtering

### Retrieve Order Details

 - [GET /orders/{orderId}](https://docs.fulfillment.juniperhealth.com/apis/orders/getorderbyid.md): Get detailed information for a specific order

### Cancel an Order

 - [POST /orders/{orderId}/cancel](https://docs.fulfillment.juniperhealth.com/apis/orders/cancelorder.md): Cancel an order that has not yet entered processing. Orders can only be cancelled while in NEW status.

## Protocols

Create and manage reusable order protocols/templates

### Create a New Protocol

 - [POST /protocols](https://docs.fulfillment.juniperhealth.com/apis/protocols/createprotocol.md): Create a reusable order protocol/template with customer information,
product line items, and shipping details. Protocols can be used to
quickly generate orders with pre-configured settings.

### List Protocols

 - [GET /protocols](https://docs.fulfillment.juniperhealth.com/apis/protocols/listprotocols.md): Retrieve a paginated list of protocols with optional search

### Get Protocol Details

 - [GET /protocols/{protocolId}](https://docs.fulfillment.juniperhealth.com/apis/protocols/getprotocolbyid.md): Retrieve detailed information for a specific protocol

### Update Protocol

 - [PUT /protocols/{protocolId}](https://docs.fulfillment.juniperhealth.com/apis/protocols/updateprotocol.md): Update an existing protocol with new customer, product, or shipping information

### Delete Protocol

 - [DELETE /protocols/{protocolId}](https://docs.fulfillment.juniperhealth.com/apis/protocols/deleteprotocol.md): Delete an existing protocol

## Products

Access product catalog and inventory details

### Get Product Catalog

 - [GET /products](https://docs.fulfillment.juniperhealth.com/apis/products/listproducts.md): Retrieve paginated list of available products

### Get Product Details

 - [GET /products/{productId}](https://docs.fulfillment.juniperhealth.com/apis/products/getproductbyid.md): Retrieve detailed information for a specific product

## Shipping

Retrieve available shipping methods

### Get Available Shipping Methods

 - [GET /shipping-methods](https://docs.fulfillment.juniperhealth.com/apis/shipping/listshippingmethods.md): Retrieve list of available shipping methods with details

## Partner Settings

Manage partner account settings and branding

### Get Partner Settings

 - [GET /partners/settings](https://docs.fulfillment.juniperhealth.com/apis/partner-settings/getpartnersettings.md): Retrieve the authenticated partner's current settings including branding, contact info, and billing address

### Update Partner Settings

 - [PATCH /partners/settings](https://docs.fulfillment.juniperhealth.com/apis/partner-settings/updatepartnersettings.md): Update the authenticated partner's settings. All fields are optional -
only provided fields will be updated. Partners cannot change their name or ID.

### Get Webhook Secret

 - [GET /partners/settings/webhook-secret](https://docs.fulfillment.juniperhealth.com/apis/partner-settings/getwebhooksecret.md): Retrieve your webhook secret for signature verification.
The secret is not included in the general settings response for security.
You must have a webhookUrl configured to have a secret.

### Rotate Webhook Secret

 - [POST /partners/settings/rotate-webhook-secret](https://docs.fulfillment.juniperhealth.com/apis/partner-settings/rotatewebhooksecret.md): Generate a new webhook secret. The old secret becomes invalid immediately.
Use this endpoint to rotate your secret if it may have been compromised.

