> For the complete documentation index, see [llms.txt](https://replenit.gitbook.io/replenit-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://replenit.gitbook.io/replenit-docs/readme.md).

# Replenit Ingestion API - Complete Guide

[![API Status](https://img.shields.io/badge/status-production-success)](https://status.replen.it) [![API Version](https://img.shields.io/badge/version-v1-blue)](https://api.replen.it) [![Response Time](https://img.shields.io/badge/response-%3C100ms-brightgreen)](https://status.replen.it) [![Uptime](https://img.shields.io/badge/uptime-99.9%25-success)](https://status.replen.it)

**The unified, production-ready API for real-time commerce data synchronization**

[Getting Started](/replenit-docs/getting-started.md) • [Authentication](/replenit-docs/authentication.md) • [API Reference](#-api-reference) • [Best Practices](/replenit-docs/best-practices.md)

***

## 📋 Table of Contents

* [Overview](#-overview)
* [Key Features](#-key-features)
* [Quick Start (5 minutes)](#-quick-start-5-minutes)
* [Architecture](#️-architecture)
* [Authentication](#-authentication)
* [API Reference](#-api-reference)
* [Rate Limits](#-rate-limits)
* [Data Standards](#-data-standards)
* [Error Handling](#-error-handling)
* [Support & Community](#-support--community)
* [Additional Resources](#-additional-resources)

***

## 🎯 Overview

The Replenit Ingestion API is the backbone of your marketing automation ecosystem. It provides:

* **Real-time synchronization** of customers, orders, and products
* **Bi-directional data flow** between your systems and Replenit's intelligence engine
* **Production-grade reliability** with 99.9% uptime SLA
* **Enterprise security** with API key authentication and data encryption

**Use Cases:**

* E-commerce platforms syncing purchase data
* CRM systems updating customer profiles
* Inventory management systems pushing product updates
* Marketing automation platforms triggering campaigns

***

## ✨ Key Features

| <h4>⚡ High Performance</h4><ul><li>< 100ms average response time</li><li>Batch processing up to 1000 records</li><li>Automatic retry with exponential backoff</li><li>Connection pooling & compression</li></ul> | <h4>🔒 Enterprise Security</h4><ul><li>API key authentication</li><li>TLS 1.3 encryption</li><li>Request validation & sanitization</li><li>GDPR compliant data handling</li></ul> | <h4>🛠️ Developer Friendly</h4><ul><li>RESTful JSON API</li><li>Comprehensive error messages</li><li>Field-level validation feedback</li><li>Multi-language code examples</li></ul> |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

***

## 🚀 Quick Start (5 Minutes)

### Prerequisites

Before you begin:

* ✅ Replenit account (Your dashboard access will be provided via email. Contact your Customer Success Manager if you haven't received it.)
* ✅ Your **Tenant ID** (GUID format)
* ✅ Your **API Key** (base64 encoded)

**Get your credentials:**

1. Complete signup and login via your invitation link (request it from your CSM if you haven't received one)
2. Navigate to **Settings** → **API**
3. Copy your **Tenant ID** and generate an **API Key**

### Step 1: Make Your First API Call

Choose your preferred language:

<details>

<summary>🔧 cURL (Terminal)</summary>

```bash
# Replace YOUR_TENANT_ID and YOUR_API_KEY
curl -X POST "https://api.replen.it/customers/YOUR_TENANT_ID" \
  -H "Content-Type: application/json" \
  -H "x-replenit-auth-key: YOUR_API_KEY" \
  -d '[{
    "CustomerId": "quickstart-001",
    "Email": "test@example.com",
    "Name": "Test",
    "Surname": "User",
    "EmailOptin": true,
    "GdprOptin": true
  }]'
```

</details>

<details>

<summary>🐍 Python</summary>

```python
import requests

# Configuration
TENANT_ID = "YOUR_TENANT_ID"
API_KEY = "YOUR_API_KEY"

# Make API call
response = requests.post(
    f"https://api.replen.it/customers/{TENANT_ID}",
    headers={
        "Content-Type": "application/json",
        "x-replenit-auth-key": API_KEY
    },
    json=[{
        "CustomerId": "quickstart-001",
        "Email": "test@example.com",
        "Name": "Test",
        "Surname": "User",
        "EmailOptin": True,
        "GdprOptin": True
    }]
)

# Handle response
result = response.json()
if result.get("success"):
    print(f"✅ Success! Created {result['data']['count']} customer(s)")
else:
    print(f"❌ Error: {result.get('message')}")
```

</details>

<details>

<summary>🟢 Node.js</summary>

```javascript
const axios = require('axios');

// Configuration
const TENANT_ID = 'YOUR_TENANT_ID';
const API_KEY = 'YOUR_API_KEY';

// Make API call
axios.post(
    `https://api.replen.it/customers/${TENANT_ID}`,
    [{
        CustomerId: 'quickstart-001',
        Email: 'test@example.com',
        Name: 'Test',
        Surname: 'User',
        EmailOptin: true,
        GdprOptin: true
    }],
    {
        headers: {
            'Content-Type': 'application/json',
            'x-replenit-auth-key': API_KEY
        }
    }
)
.then(response => {
    if (response.data.success) {
        console.log(`✅ Success! Created ${response.data.data.count} customer(s)`);
    }
})
.catch(error => {
    console.error('❌ Error:', error.response?.data || error.message);
});
```

</details>

### Step 2: Verify Success

**✅ Success Response:**

```json
{
  "success": true,
  "message": "Customers saved.",
  "data": {
    "count": 1,
    "processedAt": "2024-12-22T14:40:00Z"
  }
}
```

**Verify in Dashboard:** created data will reflect to Data and Health page in the panel after 24 hours

### Step 3: Next Steps

🎉 **Congratulations!** You've successfully integrated with Replenit.

**What you just did:**

* ✅ Authenticated with API key
* ✅ Created a customer profile
* ✅ Customer is now available for campaigns

**Try these next:**

```bash
# Import an order
curl -X POST "https://api.replen.it/orders/YOUR_TENANT_ID" \
  -H "Content-Type: application/json" \
  -H "x-replenit-auth-key: YOUR_API_KEY" \
  -d '[{
    "OrderId": "O-001",
    "Currency": "USD",
    "TotalRevenue": 99.99,
    "OrderItems": [
      { "ProductId": "P-001", "Sku": "SKU-001", "Quantity": 1, "Price": 99.99 }
    ]
  }]'

# Sync a product
curl -X POST "https://api.replen.it/products/YOUR_TENANT_ID" \
  -H "Content-Type: application/json" \
  -H "x-replenit-auth-key: YOUR_API_KEY" \
  -d '[{
    "ProductId": "P-001",
    "ProductVariants": [
      { "VariantId": "V-001", "Sku": "SKU-001" }
    ]
  }]'
```

***

## 🏗️ Architecture

### Core Entities

| Entity        | Purpose                | Key Fields                       | Update Frequency          |
| ------------- | ---------------------- | -------------------------------- | ------------------------- |
| **Customers** | Profiles & Preferences | Email, CustomerId, Consent flags | Real-time or daily        |
| **Orders**    | Purchase Behavior      | OrderId, Items, Revenue          | Real-time per transaction |
| **Products**  | Catalog & Inventory    | ProductId, Variants, Stock       | Hourly or on-change       |

***

## 🔐 Authentication

All API requests require the `x-replenit-auth-key` header with your base64-encoded API key.

**Quick Example:**

```http
x-replenit-auth-key: YOUR_BASE64_API_KEY
```

**Get your API key:**

1. Login to your Replenit panel (Reach out to Customer Success Manager if you don't have invitation email)
2. Navigate to **Settings** → **API Keys**
3. Click **Generate New Key** and save securely

**📖 Complete security guide:** [authentication.md](/replenit-docs/authentication.md) — includes key rotation, best practices, troubleshooting, and multi-environment setup

***

## 📚 API Reference

### Base URL

```
https://api.replen.it
```

### Endpoints Overview

| Endpoint                                                | Method | Purpose                            | Batch Size | Docs                                             |
| ------------------------------------------------------- | ------ | ---------------------------------- | ---------- | ------------------------------------------------ |
| `/customers/{tenantId}`                                 | POST   | Upsert customer profiles           | 100-500    | [→](/replenit-docs/customers.md)                 |
| `/customers/{tenantId}?customerId=&email=`              | DELETE | Delete customer (by id or email)   | -          | [→](/replenit-docs/customers.md#delete-endpoint) |
| `/orders/{tenantId}`                                    | POST   | Import orders & transactions       | 50-200     | [→](/replenit-docs/orders.md)                    |
| `/orders/{tenantId}/{orderId}`                          | DELETE | Delete entire order                | -          | [→](/replenit-docs/orders.md#delete-endpoint)    |
| `/orders/{tenantId}/{orderId}/items?productId=&sku=`    | DELETE | Delete a single line item          | -          | [→](/replenit-docs/orders.md#delete-line-item)   |
| `/products/{tenantId}`                                  | POST   | Sync product catalog               | 50-100     | [→](/replenit-docs/products.md)                  |
| `/products/{tenantId}/{productId}`                      | DELETE | Delete product (cascades variants) | -          | [→](/replenit-docs/products.md#delete-endpoint)  |
| `/products/{tenantId}/{productId}/variants/{variantId}` | DELETE | Delete a single variant            | -          | [→](/replenit-docs/products.md#delete-variant)   |

### Common Request Format

**All POST endpoints expect:**

* ✅ **Array of objects** (even for single record)
* ✅ **Content-Type**: `application/json`
* ✅ **UTF-8 encoding**

**All DELETE endpoints are asynchronous:**

* The deletion is accepted, queued, and applied idempotently downstream.
* The endpoint returns success once the request is durably accepted — it does not verify that a matching record exists.

```json
[
  {"field1": "value1"},
  {"field1": "value2"}
]
```

### Common Response Format

**Success (200 OK):**

```json
{
  "success": true,
  "message": "Records saved.",
  "data": {
    "count": 2,
    "processedAt": "2024-12-22T14:40:00Z"
  }
}
```

**Error (4xx/5xx):**

```json
{
  "success": false,
  "message": "Validation failed",
  "data": {},
  "errors": {
    "[0].Email": ["The Email field is required."]
  }
}
```

***

## ⚡ Rate Limits

**Standard Tier:** 100 requests/minute, 5,000 requests/hour

All responses include rate limit headers:

```http
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
```

**Handling 429 Responses:**

* Implement exponential backoff with jitter
* Use `Retry-After` header value
* Monitor `X-RateLimit-Remaining`

**📖 Complete optimization guide:** [rate-limits.md](/replenit-docs/rate-limits.md) — includes tier comparison, handling strategies, batch optimization, and real-world patterns

***

## ✅ Data Standards

We follow international standards for interoperability:

* **Datetime**: ISO 8601 (`2024-12-22T14:30:00.000Z` UTC)
* **Language**: IETF BCP 47 (`en-US`, `fr-FR`)
* **Currency**: ISO 4217 (`USD`, `EUR`, `GBP`)
* **Encoding**: UTF-8 required

**📖 Complete standards & production checklist:** [best-practices.md](/replenit-docs/best-practices.md)

***

## 🚨 Error Handling

### HTTP Status Codes

| Code  | Meaning          | Action Required                                                                                     |
| ----- | ---------------- | --------------------------------------------------------------------------------------------------- |
| `200` | Success          | Continue normal flow                                                                                |
| `400` | Validation Error | Fix request data, check [error decoder](/replenit-docs/error-responses.md#validation-error-decoder) |
| `401` | Unauthorized     | Verify API key                                                                                      |
| `404` | Tenant Not Found | Check tenant ID                                                                                     |
| `429` | Rate Limit       | Implement backoff, reduce request rate                                                              |
| `500` | Server Error     | Retry with exponential backoff                                                                      |

### Error Response Structure

```json
{
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-abc123...",
  "errors": {
    "[0].Email": ["The Email field is required."],
    "[0].CustomerId": ["Maximum length is 100 characters."]
  }
}
```

### Common Errors & Solutions

**"Tenant not found" (404)**

* ✅ Verify tenant ID is a GUID (36 characters)
* ✅ Copy from Dashboard → Settings → API

**"Unauthorized" (401)**

* ✅ Check `x-replenit-auth-key` header
* ✅ Verify full API key was copied

**"Validation Error" (400)**

* ✅ Request must be an array: `[{...}]`
* ✅ Check required fields per endpoint
* ✅ Verify string lengths don't exceed limits

**📖 Complete troubleshooting:** [error-responses.md](/replenit-docs/error-responses.md)

***

## 📞 Support & Community

### Getting Help

* **📧 Email Support**: <support@replen.it>
* **📖 Documentation**: You're reading it!
* **🔧 Status Page**: [status.replen.it](https://status.replen.it)

### Response Times

* **Critical Issues**: < 1 hour
* **Standard Support**: < 24 hours
* **Feature Requests**: 48-72 hours

### When Contacting Support

Include:

* ✅ Tenant ID
* ✅ Timestamp (UTC) of issue
* ✅ Full error response (sanitize sensitive data)
* ✅ Request payload example (sanitize sensitive data)
* ✅ Expected vs actual behavior

***

## 📚 Additional Resources

### Getting Started

* [🚀 Getting Started Guide](/replenit-docs/getting-started.md) - Complete 9-step tutorial with examples
* [🔐 Authentication & Security](/replenit-docs/authentication.md) - API keys, rotation, troubleshooting
* [⚡ Rate Limits & Optimization](/replenit-docs/rate-limits.md) - Tier comparison, handling strategies

### API Reference

* [👥 Customers API](/replenit-docs/customers.md) - Complete customer endpoint reference
* [🛒 Orders API](/replenit-docs/orders.md) - Order & transaction management
* [📦 Products API](/replenit-docs/products.md) - Product catalog synchronization

### Production Guides

* [🌟 Best Practices](/replenit-docs/best-practices.md) - Production patterns & optimization
* [🚨 Error Responses](/replenit-docs/error-responses.md) - Troubleshooting & validation decoder
