Pricient REST API v1.0

Developer Integration & API Reference

Learn how to connect your storefront, e-commerce cart, or internal catalog with Pricient's real-time pricing agent in minutes.

Platform Overview & Flow

Pricient provides an ultra-low latency, real-time reinforcement learning pricing agent. External merchants query Pricient for dynamic price discovery and report subsequent conversion events to continuously optimize yield and conversion rates.

Security Architecture (Dual-Token Pattern)
Your private Merchant API Key should never be exposed to the user browser. Client-side applications (such as storefront Single Page Apps) exchange the Merchant API Key via a server-side proxy or public exchange endpoint for a short-lived JWT Access Token (with limited_access privileges restricted only to pricing and checkout conversion calls).

End-to-End Integration Flow

1

Authenticate

Exchange Merchant API Key for a scoped 1-hour JWT token.

2

Query Price

Call /request_price/ on product page load to get the dynamic recommended price.

3

Customer Buys

Display the final price and capture customer transaction session.

4

Record Purchase

Call /record_purchase/ with request_id so the elastic pricing model learns from success.

Base URLs & Environments

All API requests must use HTTPS and send JSON bodies with standard HTTP headers.

Environment Base URL Description
Production https://api.pricient.co Live high-availability infrastructure with global multi-region low latency routing.

Standard Request Headers

HTTP Headers
Content-Type: application/json
Accept: application/json
Authorization: Bearer <YOUR_ACCESS_TOKEN>

Web Frontend & Zero-Flicker Pricing Architecture

When integrating dynamic pricing into websites, e-commerce storefronts, or Single Page Apps (SPAs), the primary UX requirement is zero visual flickering—ensuring visitors never see a hardcoded fallback price flash or jump before the dynamic price appears.

Recommended Production Patterns for 0% Flicker
  • Pattern 1: Server-Side Rendering (SSR / Backend Pre-fetch) — *Gold Standard*: Query Pricient on your server (Next.js getServerSideProps, Django template view, Rails, Laravel, or Node.js) with your Merchant API Key before serving HTML. The rendered page immediately loads with the true dynamic price without any client-side JavaScript delay or visual jump.
  • Pattern 2: Skeleton Placeholder (CSR): If using Client-Side Rendering (React, Vue, Vite), display a subtle animated pulse skeleton while /multi_request_price/ resolves, or render the dynamic price silently without color flashes.

1. Server-Side Rendering (Next.js / Node.js Backend Example)

Next.js Server Component / SSR
// Next.js (Pages Router or App Router Server Component)
export async function getServerSideProps(context) {
  const customerId = context.req.cookies['pricient_uid'] || 'guest_user';
  
  // Server-to-server call with private API key - Zero browser flicker!
  const res = await fetch('https://api.pricient.co/multi_request_price/', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.PRICIENT_SECRET_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      context: {
        merchant_id: process.env.PRICIENT_MERCHANT_ID,
        campaign_id: process.env.PRICIENT_CAMPAIGN_ID,
        customer_id: customerId,
        products: [
          { product_id: '0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda' },
          { product_id: '681a0ed6-01c5-4b53-a84a-dbc879ef06f0' }
        ]
      }
    })
  });
  
  const pricingData = await res.json();
  return { props: { dynamicPrices: pricingData.results } };
}

2. Client-Side Web SDK (pricient-sdk.js)

For client-side web applications, include the CDN tag and initialize the SDK:

HTML Script Tag (CDN)
<script 
  src="https://api.pricient.co/static/sdk/pricient-sdk.js" 
  data-api-key="YOUR_MERCHANT_API_KEY"
  data-merchant-id="YOUR_MERCHANT_UUID"
  data-campaign-id="YOUR_CAMPAIGN_UUID"
  async>
</script>
Client Storefront JavaScript
// Initialize SDK (or use auto-initialized window.pricient)
const pricient = new Pricient({
  apiKey: 'YOUR_MERCHANT_API_KEY',
  merchantId: 'YOUR_MERCHANT_UUID',
  campaignId: 'YOUR_CAMPAIGN_UUID'
});

// Optional: Identify a logged-in customer (defaults to persistent anonymous cookie)
pricient.identify('user_987654');

// Request dynamic price on product page
pricient.requestPrice({
  productId: '0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda'
}).then(res => {
  // Update price display and attach request_id for checkout
  document.getElementById('price-label').textContent = `$${res.final_price.toFixed(2)}`;
  document.getElementById('buy-btn').setAttribute('data-request-id', res.request_id);
});

// Record a conversion when customer checks out
pricient.recordPurchase({
  requestId: document.getElementById('buy-btn').getAttribute('data-request-id'),
  revenue: 129.00,
  quantity: 1
});

Mobile Apps (iOS / Android) & Server Proxy

Pricient is engineered for any platform architecture—from native mobile apps (iOS, Android, Flutter, React Native) to cloud microservices and POS hardware (Toast, Square).

Web & SSR

SSR hydration for zero-flicker or pricient-sdk.js for automated cookie identity and telemetry.

Native Mobile & POS

Direct REST calls from iOS Swift, Android Kotlin, React Native, or POS hardware with native TCP socket telemetry.

Server-to-Server

Forward X-Forwarded-For and User-Agent headers or pass explicit context fields in request body.

Native Mobile Code Examples

// iOS Swift Example (URLSession & async/await)
func fetchDynamicPrices(accessToken: String, productIds: [String]) async throws -> [PricingResult] {
    let url = URL(string: "https://api.pricient.co/multi_request_price/")!
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    
    let payload: [String: Any] = [
        "context": [
            "merchant_id": "YOUR_MERCHANT_UUID",
            "campaign_id": "YOUR_CAMPAIGN_UUID",
            "customer_id": UserDefaults.standard.string(forKey: "userId") ?? UIDevice.current.identifierForVendor?.uuidString,
            "products": productIds.map { ["product_id": $0] }
        ]
    ]
    request.httpBody = try JSONSerialization.data(withJSONObject: payload)
    
    let (data, _) = try await URLSession.shared.data(for: request)
    let response = try JSONDecoder().decode(MultiPriceResponse.self, from: data)
    return response.results
}
// Android Kotlin Example (Coroutines & OkHttp)
suspend fun fetchDynamicPrices(accessToken: String, productIds: List<String>): List<PricingResult> = withContext(Dispatchers.IO) {
    val jsonBody = JSONObject().apply {
        put("context", JSONObject().apply {
            put("merchant_id", "YOUR_MERCHANT_UUID")
            put("campaign_id", "YOUR_CAMPAIGN_UUID")
            put("customer_id", getAppUserIdOrDeviceId())
            put("products", JSONArray(productIds.map { JSONObject().put("product_id", it) }))
        })
    }
    val request = Request.Builder()
        .url("https://api.pricient.co/multi_request_price/")
        .addHeader("Authorization", "Bearer $accessToken")
        .post(jsonBody.toString().toRequestBody("application/json".toMediaType()))
        .build()
    
    val response = okHttpClient.newCall(request).execute()
    parsePricingResults(response.body?.string())
}
// React Native Example
export async function getDynamicPrices(accessToken, productIds) {
  const response = await fetch('https://api.pricient.co/multi_request_price/', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      context: {
        merchant_id: 'YOUR_MERCHANT_UUID',
        campaign_id: 'YOUR_CAMPAIGN_UUID',
        customer_id: await AsyncStorage.getItem('user_id'),
        products: productIds.map(id => ({ product_id: id }))
      }
    })
  });
  const data = await response.json();
  return data.results;
}

Server-to-Server Header Forwarding

If your backend server proxies pricing calls on behalf of shoppers, forward their client headers:

Proxy HTTP Headers
POST /request_price/
Authorization: Bearer <YOUR_ACCESS_TOKEN>
Content-Type: application/json
X-Forwarded-For: 198.51.100.42
User-Agent: Spotify/8.9.2 iOS/17.4 (iPhone15,2)
X-Pricient-Customer-Id: usr_98124

Automated End-User Telemetry Matrix

Pricient automatically extracts and indexes the following telemetry parameters for every pricing request to power bandit context vectors and analytics:

Parameter Description Resolution Source
ip Client IPv4 / IPv6 network address Socket / CF-Connecting-IP / X-Forwarded-For
location City, State, Country, Lat/Lon GPS coordinates MaxMind GeoIP2 / Cloudflare Edge Geolocation
timezone Customer or Physical Store IANA Timezone Client Intl API / GeoIP / Store Config (e.g. Toast)
local_time Exact local ISO timestamp, hour of day, and day of week Timezone-aware clock evaluation
device Device channel (ios, android, web) and hardware type User-Agent Parser & Client screen dimensions
os & browser Granular OS & Browser name and version (iOS, macOS, Android, Windows, Chrome, Safari, SpotifyApp, ToastPOS) Automated Regex & User-Agent Tokenizer
rfm Customer Recency (days), Frequency (30-day count), Monetary (lifetime revenue) Aggregated from past customer purchases in DB
weather Real-time weather condition (Sunny, Cloudy, Rainy, Cold) Open-Meteo Weather API cache

1. Authentication (Token Exchange)

Obtain an access_token by passing your private merchant API Key. You can find or regenerate your API Key in your Merchant Dashboard Settings.

POST /get_public_token/ Public Endpoint

Request Parameters

Field Type Description
api_key Required string Your private Merchant API Key generated from Pricient Merchant Settings.

Code Examples

curl -X POST "https://api.pricient.co/get_public_token/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "SCNJ8vDZOeNn87LXj8w8UU1d_89LWb7lWLAbmqIEU9M"
  }'
const response = await fetch('https://api.pricient.co/get_public_token/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    api_key: 'YOUR_MERCHANT_API_KEY'
  })
});

const data = await response.json();
console.log('Access Token:', data.access_token);
// Store token for subsequent pricing requests
const axios = require('axios');

async function getAccessToken(apiKey) {
  const { data } = await axios.post('https://api.pricient.co/get_public_token/', {
    api_key: apiKey
  });
  return data.access_token;
}
import requests

url = "https://api.pricient.co/get_public_token/"
payload = {"api_key": "YOUR_MERCHANT_API_KEY"}

response = requests.post(url, json=payload)
data = response.json()
access_token = data.get("access_token")
print("Access Token:", access_token)
// Swift / iOS
let url = URL(string: "https://api.pricient.co/get_public_token/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload = ["api_key": "YOUR_MERCHANT_API_KEY"]
request.httpBody = try JSONSerialization.data(withJSONObject: payload)

let (data, _) = try await URLSession.shared.data(for: request)
if let json = try JSONSerialization.jsonObject(with: data) as? [String: Any],
   let token = json["access_token"] as? String {
    print("Access Token: \(token)")
}
// Android / Kotlin (OkHttp & Coroutines)
suspend fun fetchAccessToken(apiKey: String): String? = withContext(Dispatchers.IO) {
    val json = JSONObject().put("api_key", apiKey).toString()
    val request = Request.Builder()
        .url("https://api.pricient.co/get_public_token/")
        .post(json.toRequestBody("application/json".toMediaType()))
        .build()
    val response = okHttpClient.newCall(request).execute()
    val responseBody = response.body?.string()
    JSONObject(responseBody ?: "{}").optString("access_token")
}

Response (200 OK)

Status: 200 OK
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxLCJwZXJtcyI6ImxpbWl0ZWRfYWNjZXNzIiwiZXhwIjoxNzM1NzE4NDAwfQ.sZ7..."
}

2. Request Price (Single Product)

Queries the elastic pricing agent to retrieve the optimized price for a specific product item in a campaign.

POST /request_price/ Bearer Auth

Request Body Schema

Field Type Description
context.merchant_id Required UUID Merchant UUID identifier.
context.campaign_id Required UUID Campaign UUID identifier containing the product.
context.product_id Required* UUID UUID of the Product (*or provide product_name).
context.customer_id Optional string Unique customer/visitor ID. If omitted, Pricient auto-resolves via cookie/anonymous UUID.
context.customer_ip Optional string Explicit client IP override for server proxies (or pass via X-Forwarded-For header).
context.customer_timezone Optional string Client IANA Timezone (e.g. America/New_York). Auto-resolved if omitted.
context.customer_device_channel Optional string Client platform channel (ios, android, web). Auto-detected from User-Agent if omitted.
context.customer_screen_resolution Optional string Customer screen dimensions (e.g. 1920x1080). Auto-captured by Web SDK.
context.customer_language Optional string Customer locale / browser language (e.g. en-US, es-ES).
context.customer_page_url Optional string Current product storefront URL. Auto-captured by Web SDK.
context.customer_referrer Optional string Referring URL / traffic source (e.g. https://google.com).
context.customer_user_agent Optional string Explicit User-Agent override for server proxies (or pass via User-Agent header).

Code Examples

curl -X POST "https://api.pricient.co/request_price/" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "context": {
      "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
      "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
      "product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
      "customer_id": "cust_sess_9a87d12f"
    }
  }'
const res = await fetch('https://api.pricient.co/request_price/', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    context: {
      merchant_id: "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
      campaign_id: "a69453b6-77ef-446d-808d-fe7f9738f01f",
      product_id: "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
      customer_id: "cust_sess_9a87d12f"
    }
  })
});

const { request_id, final_price, original_price } = await res.json();
console.log(`Optimized price: $${final_price} (Original: $${original_price})`);
// Node.js / SSR
const axios = require('axios');

async function getPrice(token, context) {
  const response = await axios.post('https://api.pricient.co/request_price/', 
    { context }, 
    { headers: { Authorization: `Bearer ${token}` } }
  );
  return response.data;
}
import requests

headers = {"Authorization": f"Bearer {access_token}"}
payload = {
    "context": {
        "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
        "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
        "product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
        "customer_id": "cust_sess_9a87d12f"
    }
}

r = requests.post("https://api.pricient.co/request_price/", json=payload, headers=headers)
data = r.json()
print("Returned Price:", data["final_price"])
print("Tracking Request ID:", data["request_id"])
// Swift / iOS
let url = URL(string: "https://api.pricient.co/request_price/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let payload: [String: Any] = [
    "context": [
        "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
        "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
        "product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
        "customer_id": "cust_sess_9a87d12f"
    ]
]
request.httpBody = try JSONSerialization.data(withJSONObject: payload)
let (data, _) = try await URLSession.shared.data(for: request)
// Android / Kotlin (OkHttp & Coroutines)
suspend fun fetchSinglePrice(accessToken: String, productId: String, customerId: String): PricingResult = withContext(Dispatchers.IO) {
    val json = JSONObject().apply {
        put("context", JSONObject().apply {
            put("merchant_id", "YOUR_MERCHANT_UUID")
            put("campaign_id", "YOUR_CAMPAIGN_UUID")
            put("product_id", productId)
            put("customer_id", customerId)
        })
    }.toString()
    val request = Request.Builder()
        .url("https://api.pricient.co/request_price/")
        .addHeader("Authorization", "Bearer $accessToken")
        .post(json.toRequestBody("application/json".toMediaType()))
        .build()
    val response = okHttpClient.newCall(request).execute()
    parsePricingResult(response.body?.string())
}

Response (200 OK)

Status: 200 OK
{
  "request_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0",
  "final_price": 129,
  "original_price": 129
}

3. Request Prices (Bulk / Multi-Product)

Retrieve optimized dynamic prices for multiple catalog products in a single high-performance roundtrip. Ideal for category pages, cart pages, or grid storefronts.

POST /multi_request_price/ Bearer Auth

Request Body Schema

Field Type Description
context.merchant_id Required UUID Merchant UUID identifier.
context.campaign_id Required UUID Campaign UUID identifier.
context.products Required array<object> List of product items to price: [{"product_id": "UUID"}, ...]
context.customer_id Optional string Unique customer/visitor ID. If omitted, Pricient auto-resolves via cookie/anonymous UUID.
context.customer_ip Optional string Explicit client IP override for server proxies (or pass via X-Forwarded-For header).
context.customer_timezone Optional string Client IANA Timezone (e.g. America/New_York). Auto-resolved if omitted.
context.customer_device_channel Optional string Client platform channel (ios, android, web). Auto-detected from User-Agent if omitted.
context.customer_screen_resolution Optional string Customer screen dimensions (e.g. 1920x1080). Auto-captured by Web SDK.
context.customer_language Optional string Customer locale / browser language (e.g. en-US, es-ES).
context.customer_page_url Optional string Current storefront URL. Auto-captured by Web SDK.
context.customer_referrer Optional string Referring URL / traffic source (e.g. https://google.com).
context.customer_user_agent Optional string Explicit User-Agent override for server proxies (or pass via User-Agent header).

Code Examples

curl -X POST "https://api.pricient.co/multi_request_price/" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "context": {
      "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
      "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
      "customer_id": "cust_sess_9a87d12f",
      "products": [
        {"product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda"},
        {"product_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0"}
      ]
    }
  }'
const res = await fetch('https://api.pricient.co/multi_request_price/', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    context: {
      merchant_id: "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
      campaign_id: "a69453b6-77ef-446d-808d-fe7f9738f01f",
      customer_id: "cust_sess_9a87d12f",
      products: [
        { product_id: "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda" },
        { product_id: "681a0ed6-01c5-4b53-a84a-dbc879ef06f0" }
      ]
    }
  })
});
const { results } = await res.json();
results.forEach(item => {
  console.log(`Product ${item.product_identifier} -> Price: $${item.final_price}`);
});
// Node.js / Next.js Server-Side Call (Zero-Flicker)
import axios from 'axios';

export async function fetchCatalogPrices(customerId, productIds) {
  const { data } = await axios.post('https://api.pricient.co/multi_request_price/', {
    context: {
      merchant_id: process.env.PRICIENT_MERCHANT_ID,
      campaign_id: process.env.PRICIENT_CAMPAIGN_ID,
      customer_id: customerId,
      products: productIds.map(id => ({ product_id: id }))
    }
  }, {
    headers: { Authorization: `Bearer ${process.env.PRICIENT_API_KEY}` }
  });
  return data.results;
}
import requests

payload = {
    "context": {
        "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
        "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
        "customer_id": "cust_sess_9a87d12f",
        "products": [
            {"product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda"},
            {"product_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0"}
        ]
    }
}
r = requests.post("https://api.pricient.co/multi_request_price/", json=payload, headers={"Authorization": f"Bearer {access_token}"})
print(r.json())
// Swift / iOS
let url = URL(string: "https://api.pricient.co/multi_request_price/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let payload: [String: Any] = [
    "context": [
        "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
        "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
        "customer_id": "cust_sess_9a87d12f",
        "products": [
            ["product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda"],
            ["product_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0"]
        ]
    ]
]
request.httpBody = try JSONSerialization.data(withJSONObject: payload)
let (data, _) = try await URLSession.shared.data(for: request)
// Android / Kotlin (OkHttp & Coroutines)
suspend fun fetchBulkPrices(accessToken: String, productIds: List<String>, customerId: String): List<PricingResult> = withContext(Dispatchers.IO) {
    val json = JSONObject().apply {
        put("context", JSONObject().apply {
            put("merchant_id", "YOUR_MERCHANT_UUID")
            put("campaign_id", "YOUR_CAMPAIGN_UUID")
            put("customer_id", customerId)
            put("products", JSONArray(productIds.map { JSONObject().put("product_id", it) }))
        })
    }.toString()
    val request = Request.Builder()
        .url("https://api.pricient.co/multi_request_price/")
        .addHeader("Authorization", "Bearer $accessToken")
        .post(json.toRequestBody("application/json".toMediaType()))
        .build()
    val response = okHttpClient.newCall(request).execute()
    parsePricingResults(response.body?.string())
}

Response (200 OK)

Status: 200 OK
{
  "results": [
    {
      "product_identifier": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
      "final_price": 129,
      "request_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d"
    },
    {
      "product_identifier": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0",
      "final_price": 199,
      "request_id": "f6e5d4c3-b2a1-0f9e-8d7c-6b5a4f3e2d1c"
    }
  ]
}

4. Record Purchase (Conversion Feedback)

Informs the reinforcement learning engine that a pricing request resulted in a purchase. This updates the model to continuously optimize future price recommendations.

POST /record_purchase/ Bearer Auth

Request Body Schema

Field Type Description
request_id Required UUID The tracking request_id obtained from a previous /request_price/ call.
purchased Required boolean Must be true to record a completed conversion.

Code Examples

curl -X POST "https://api.pricient.co/record_purchase/" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0",
    "purchased": true
  }'
const res = await fetch('https://api.pricient.co/record_purchase/', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    request_id: storedRequestId,
    purchased: true
  })
});
const data = await res.json();
console.log('Purchase recorded:', data.message);
// Node.js / SSR
const axios = require('axios');

async function logPurchase(token, requestId) {
  const { data } = await axios.post('https://api.pricient.co/record_purchase/', {
    request_id: requestId,
    purchased: true
  }, {
    headers: { Authorization: `Bearer ${token}` }
  });
  return data;
}
import requests

payload = {
    "request_id": "681a0ed6-01c5-4b53-a84a-dbc879ef06f0",
    "purchased": True
}
r = requests.post("https://api.pricient.co/record_purchase/", json=payload, headers={"Authorization": f"Bearer {access_token}"})
print(r.json())
// Swift / iOS
let url = URL(string: "https://api.pricient.co/record_purchase/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let payload: [String: Any] = [
    "request_id": storedRequestId,
    "purchased": true
]
request.httpBody = try JSONSerialization.data(withJSONObject: payload)
let (data, _) = try await URLSession.shared.data(for: request)
// Android / Kotlin (OkHttp & Coroutines)
suspend fun logPurchase(accessToken: String, requestId: String): Boolean = withContext(Dispatchers.IO) {
    val json = JSONObject().apply {
        put("request_id", requestId)
        put("purchased", true)
    }.toString()
    val request = Request.Builder()
        .url("https://api.pricient.co/record_purchase/")
        .addHeader("Authorization", "Bearer $accessToken")
        .post(json.toRequestBody("application/json".toMediaType()))
        .build()
    val response = okHttpClient.newCall(request).execute()
    response.isSuccessful
}

Response (200 OK)

Status: 200 OK
{
  "status": "success",
  "message": "Purchase recorded successfully."
}

5. Record Purchases (Bulk / Cart Conversion)

Logs conversions for multiple cart items simultaneously when a customer finishes checkout.

POST /multi_record_purchase/ Bearer Auth

Code Examples

curl -X POST "https://api.pricient.co/multi_record_purchase/" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
    "items": [
      {
        "request_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d",
        "purchased": true,
        "quantity": 1
      },
      {
        "request_id": "f6e5d4c3-b2a1-0f9e-8d7c-6b5a4f3e2d1c",
        "purchased": true,
        "quantity": 2
      }
    ]
  }'
const res = await fetch('https://api.pricient.co/multi_record_purchase/', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    campaign_id: "a69453b6-77ef-446d-808d-fe7f9738f01f",
    items: [
      { request_id: "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d", purchased: true, quantity: 1 },
      { request_id: "f6e5d4c3-b2a1-0f9e-8d7c-6b5a4f3e2d1c", purchased: true, quantity: 2 }
    ]
  })
});
const data = await res.json();
console.log('Purchases recorded:', data.message);
// Node.js / SSR
const axios = require('axios');

async function logCartPurchases(token, campaignId, items) {
  const { data } = await axios.post('https://api.pricient.co/multi_record_purchase/', {
    campaign_id: campaignId,
    items: items
  }, {
    headers: { Authorization: `Bearer ${token}` }
  });
  return data;
}
import requests

payload = {
    "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
    "items": [
        {"request_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d", "purchased": True, "quantity": 1},
        {"request_id": "f6e5d4c3-b2a1-0f9e-8d7c-6b5a4f3e2d1c", "purchased": True, "quantity": 2}
    ]
}
r = requests.post("https://api.pricient.co/multi_record_purchase/", json=payload, headers={"Authorization": f"Bearer {access_token}"})
print(r.json())
// Swift / iOS
let url = URL(string: "https://api.pricient.co/multi_record_purchase/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let payload: [String: Any] = [
    "campaign_id": "a69453b6-77ef-446d-808d-fe7f9738f01f",
    "items": [
        ["request_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d", "purchased": true, "quantity": 1],
        ["request_id": "f6e5d4c3-b2a1-0f9e-8d7c-6b5a4f3e2d1c", "purchased": true, "quantity": 2]
    ]
]
request.httpBody = try JSONSerialization.data(withJSONObject: payload)
let (data, _) = try await URLSession.shared.data(for: request)
// Android / Kotlin (OkHttp & Coroutines)
suspend fun logCartPurchases(accessToken: String, campaignId: String, items: List<CartPurchaseItem>): Boolean = withContext(Dispatchers.IO) {
    val itemsArray = JSONArray().apply {
        items.forEach { item ->
            put(JSONObject().apply {
                put("request_id", item.requestId)
                put("purchased", true)
                put("quantity", item.quantity)
            })
        }
    }
    val json = JSONObject().apply {
        put("campaign_id", campaignId)
        put("items", itemsArray)
    }.toString()
    val request = Request.Builder()
        .url("https://api.pricient.co/multi_record_purchase/")
        .addHeader("Authorization", "Bearer $accessToken")
        .post(json.toRequestBody("application/json".toMediaType()))
        .build()
    val response = okHttpClient.newCall(request).execute()
    response.isSuccessful
}

Response (200 OK)

Status: 200 OK
{
  "status": "success",
  "message": "Purchases recorded successfully."
}

6. Inventory Synchronization

Keep Pricient's scarcity and inventory elasticity models up to date by synchronizing stock levels from your ERP or warehouse management system.

POST /update_inventory/ Merchant Key

Code Example

Payload Format
{
  "merchant_id": "b64aa6bd-379c-4155-828e-ce7a3fa59f5b",
  "inventory_data": [
    {
      "product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
      "inventory": 42
    },
    {
      "product_name": "Premium Leather Jacket",
      "inventory": 5
    }
  ]
}

Response (200 OK)

Status: 200 OK
{
  "status": "success",
  "updated_count": 2
}

7. Product Performance Statistics

Query real-time pricing statistics, evaluated price points, conversions, and expected revenue values for any active product.

GET /product-stats/{product_id}/ Session / Bearer

Response (200 OK)

Status: 200 OK
{
  "product_id": "0b74233e-80ef-4dfc-9b2b-3f4d8bd87eda",
  "product_name": "Enterprise Subscription",
  "current_price": 199.00,
  "min_price": 149.00,
  "max_price": 249.00,
  "total_requests": 1420,
  "total_purchases": 284,
  "conversion_rate": 0.20
}

Interactive API Tester

Test the pricing endpoint right from your browser. Input your Merchant API Key to fetch a real token, or test with demo credentials.

Credits & API Usage Quotas

Pricient uses a Credit Wallet model where credits represent price recommendation quotas. Only price calculation requests deduct credits from your balance. Conversion reporting, authentication, inventory updates, and statistics endpoints are completely free.

Credit Consumption by Endpoint

Endpoint Operation Credit Cost
POST /request_price/ Single product elastic price evaluation 1 credit
POST /multi_request_price/ Bulk catalog / cart pricing ($N$ products) 1 credit per product
POST /get_public_token/ Merchant API Key → JWT exchange 0 credits (Free)
POST /record_purchase/ Single checkout conversion logging 0 credits (Free)
POST /multi_record_purchase/ Multi-item cart conversion logging 0 credits (Free)
POST /update_inventory/ Catalog stock & inventory sync 0 credits (Free)
GET /product-stats/{id}/ Real-time performance & conversion stats 0 credits (Free)
Wallet Rules & Refills
  • New Signups: All new merchants automatically receive 300 free starting credits upon account creation.
  • Subscription Refills: Active subscriptions (Starter: 300 credits/month, Growth: 500+ credits/month) automatically refresh every billing cycle.
  • Exhaustion Handling: If your credit balance drops below 1, pricing endpoints return 400 Bad Request with {"error": "Insufficient credits."}. Top up your wallet in your Merchant Settings.

Error Codes & Troubleshooting

Pricient returns standard HTTP status codes along with descriptive JSON error messages.

Status Code Meaning Typical Reason & Solution
200 OK Success The request succeeded and returned elastic pricing or recorded conversion.
400 Bad Request Validation Error Missing required field (e.g. customer_id is required) or insufficient merchant credits.
401 Unauthorized Auth Failure Expired or invalid JWT Bearer token or invalid merchant API Key. Exchange a new token via /get_public_token/.
404 Not Found Resource Missing Campaign or product identifier not found for the merchant.
405 Method Not Allowed Invalid Method Attempted GET on a POST-only route.