Neptune Integration API
Sync products, stock and orders between your system and Neptune: Neptune Shopping (the marketplace) and Neptune App Manager (branded mobile apps).
Overview
The API serves two kinds of integrators with the same endpoints:
| You are | How you connect | Credential |
|---|---|---|
| A commerce platform (a SaaS store builder, an ERP, a marketplace connector) that wants its merchants to sell on Neptune | Register an app with Neptune, then each merchant approves it through OAuth | One access token per merchant, npat_… |
| A merchant with your own website or back office | Create a key in Neptune Partner > API and integrations | A custom key, npk_… |
Every credential acts on exactly one account: one Neptune Shopping store, or one App Manager brand. No endpoint takes a store or brand id; the token decides. Base URL:
https://neptune.tn/api/integrations/v1
403 store_not_approved, brand_inactive or owner_changed).Getting access
Merchants (custom integration)
- Sign in to Neptune Partner and open API and integrations.
- Choose the store or brand, tick the permissions (scopes) your integration needs, and create the key.
- Copy the key and the webhook signing secret. They are shown once; Neptune only keeps a hash of the key.
You can rotate a key (the old one stops at once) or revoke it at any time from the same page. Up to 10 active keys per account.
Platforms (app)
Write to contact@neptune.tn with your company name, website, support email, logo, the exact redirect URLs you will use, the scopes you need and whether you connect stores, brands or both. Neptune reviews the request and gives you a client_id and a client_secret (shown once). Until the app is approved, authorization requests are refused.
Scopes
| Scope | Allows |
|---|---|
read_products | View your products |
write_products | Create and edit your products |
read_inventory | View your inventory |
write_inventory | Update your inventory |
read_orders | View your orders and your customers' delivery details |
write_orders | Update the status of your orders |
A write_ scope includes the matching read_ scope.
Authentication
Send the token on every request, over HTTPS:
curl https://neptune.tn/api/integrations/v1/shop \
-H "Authorization: Bearer npk_your_key"
Keys are server-side secrets. Never put them in a mobile app, a browser, a public repository or a URL.
OAuth for platforms
Standard OAuth 2.0 authorization code flow. PKCE (S256) is supported and recommended.
1. Send the merchant to Neptune
https://partner.neptune.tn/integrations/oauth/authorize/?response_type=code
&client_id=npapp_…
&redirect_uri=https://yourplatform.com/neptune/callback
&scope=write_products write_inventory write_orders
&state=RANDOM_VALUE_YOU_CHECK_LATER
&target=store (optional: store or brand)
&code_challenge=… (optional, PKCE)
&code_challenge_method=S256
The merchant signs in, picks which of their accounts to connect and approves. redirect_uri must match one of your registered URLs exactly.
2. Neptune redirects back
https://yourplatform.com/neptune/callback?code=…&state=RANDOM_VALUE_YOU_CHECK_LATER
Check that state is the value you sent. If the merchant refused: ?error=access_denied&state=….
3. Exchange the code from your server
curl -X POST https://neptune.tn/api/integrations/v1/oauth/token \
-d grant_type=authorization_code \
-d code=… \
-d redirect_uri=https://yourplatform.com/neptune/callback \
-d client_id=npapp_… \
-d client_secret=npsec_… \
-d code_verifier=…
{
"access_token": "npat_…",
"token_type": "bearer",
"scope": "read_products write_products read_inventory write_inventory read_orders write_orders",
"installation_id": "3f0c…",
"target": "store",
"store_id": "42",
"store_name": "Boutique Exemple",
"webhook_secret": "npwhs_…"
}
Codes are single use and expire after 10 minutes. Access tokens do not expire; they end when the merchant disconnects your app, when you call /oauth/revoke, or when the merchant installs your app again (the new token replaces the old one).
Conventions
- JSON in and out, UTF-8. Send
Content-Type: application/jsonon writes. - All ids are strings. Money is a decimal string (
"49.90"), never a float. Stores sell in TND; a brand uses its own currency (GET /shop). - Dates are ISO 8601 with a time zone.
- Pagination: lists return
next_cursor. Pass it back as?cursor=until it isnull. Results are ordered by last update, oldest first, so a sync job can store the last cursor, or useupdated_at_min.limitis 1 to 250 (default 50). - Rate limit: 600 requests per minute per installation. Over it you get
429 rate_limitedwith aRetry-Afterheader in seconds. - Your ids: products are written by your id (
external_id). Writes are idempotent: sending the same product twice updates it.
Shop
GET /shop: the installation (scopes, kind) and the account it acts on: store (id, name, slug, url, currency) or brand (id, name, slug, currency, business_type). Needs no scope. Call it first to know which account a token belongs to.
GET /categories: Neptune Shopping categories, for category_id. Stores only.
Products
| PUT | /products/external/{external_id} | Create or replace. write_products. 201 when created, 200 when updated. |
| GET | /products/external/{external_id} | Read by your id. read_products. |
| DELETE | /products/external/{external_id} | Archive: off sale, kept for past orders. write_products. |
| GET | /products | Every product of the account, including the ones the merchant created on Neptune. read_products. |
| GET | /products/{id} | Read by Neptune id. |
Product body
PUT https://neptune.tn/api/integrations/v1/products/external/SKU-1001
{
"title": "Sneakers Atlas",
"description": "Light running shoe.\n\nLeather upper.",
"price": "189.00",
"compare_at_price": "229.00",
"status": "active",
"track_inventory": true,
"images": ["https://cdn.example.com/atlas-1.jpg", "https://cdn.example.com/atlas-2.jpg"],
"options": [
{"name": "Size", "values": ["40", "41", "42"]},
{"name": "Color", "values": ["Black", "White"]}
],
"variants": [
{"external_id": "SKU-1001-40-BLK", "option1": "40", "option2": "Black", "quantity": 3, "sku": "AT40B"},
{"external_id": "SKU-1001-41-BLK", "option1": "41", "option2": "Black", "quantity": 0, "price": "195.00"}
]
}
| Field | Rules |
|---|---|
title | Required, up to 200 characters. |
description | Plain text, up to 20,000 characters. HTML tags are removed; blank lines make paragraphs. |
price | Required. With variants, the product shows the lowest variant price. |
compare_at_price | Optional "was" price. Ignored unless above the price. |
status | active (on sale), draft (hidden, the default) or archived. |
track_inventory | When false, the product never runs out (a stock of 999 is shown). |
quantity | Stock for a product without variants. |
images | Up to 10 public https URLs. Store images are downloaded by Neptune within a minute (JPEG, PNG, WebP or GIF, 10 MB max); photos the merchant added on Neptune are kept. |
options | Up to 3, each with up to 100 values. Neptune Shopping shows two of them, size and colour, recognised by name (Size/Taille/Pointure, Color/Couleur); other options are folded into the size label. |
variants | Up to 100. Each needs your external_id and one value per option. A variant without price uses the product price. |
category_id | Stores only, from GET /categories. |
weight | Kilograms, optional. |
409 plan_limit_reached; updates always work.Inventory
POST /inventory/set with write_inventory: absolute stock levels, up to 250 per call.
{
"items": [
{"product_external_id": "SKU-1001", "variant_external_id": "SKU-1001-40-BLK", "quantity": 7},
{"product_external_id": "MUG-7", "quantity": 120}
]
}
The answer lists every item with result: updated, product_not_found, variant_not_found, or variant_required (the product has variants; send the variant). One bad item does not stop the others.
Neptune also lowers stock itself when it sells. Push your levels after every change on your side, and use the order webhooks to lower stock in your system when Neptune sells.
Orders
| GET | /orders | Orders containing the account's products. Filters: status, updated_at_min, cursor. read_orders. |
| GET | /orders/{id} | One order. Brands also accept the order number. |
| PATCH | /orders/{id} | Change status, payment_status (brands) and your external_id. write_orders. |
An order shows only the lines of the account's own products, the customer's name and phone, and the delivery address: what the merchant sees in their dashboard. Each line carries your product_external_id and variant_external_id when the product came from you.
Neptune Shopping store orders
Statuses: pending → processing → shipped → delivered, or cancelled.
- When
delivery_methodisneptune(fulfilled_by_neptune: true), Neptune's courier setsshippedanddelivered. You may setprocessing(preparing) andcancelleduntil the courier collects the parcel. Other changes return409 managed_by_neptuneor409 already_collected. - Cancelling puts the stock back.
- Payment status is set by Neptune for marketplace orders.
neptune_commissionis what Neptune charges the store on this order.
App Manager brand orders
Statuses: pending, confirmed, processing, ready (restaurants), shipped, delivered, cancelled, failed, refunded. Payment statuses: pending, authorized, paid, failed, refunded. Restaurants follow their kitchen flow: a change it does not allow returns 409 invalid_status_transition with the allowed next statuses. The customer gets a push notification on every status change, exactly as when the merchant changes it in App Manager.
PATCH https://neptune.tn/api/integrations/v1/orders/1234
{"status": "processing", "external_id": "WEB-55012"}
Webhooks
Subscribe once per topic. Neptune POSTs JSON to your HTTPS URL.
| Topic | Needs | Sent when |
|---|---|---|
order.created | read_orders | A new order contains the account's products |
order.updated | read_orders | An order's status changes |
order.cancelled | read_orders | An order is cancelled (also sent as order.updated) |
app.uninstalled | none | The merchant disconnected your app; the token no longer works |
POST https://neptune.tn/api/integrations/v1/webhooks
{"topic": "order.created", "url": "https://yourplatform.com/hooks/neptune"}
GET https://neptune.tn/api/integrations/v1/webhooks
DELETE https://neptune.tn/api/integrations/v1/webhooks/{id}
Delivery
POST https://yourplatform.com/hooks/neptune
Content-Type: application/json
X-Neptune-Topic: order.created
X-Neptune-Event-Id: 7c1d… (same for every retry of this event)
X-Neptune-Installation-Id: 3f0c…
X-Neptune-Signature: t=1767225600,v1=5f2b…
{"id": "7c1d…", "topic": "order.created", "created_at": "…", "installation_id": "3f0c…", "data": { …order… }}
- Answer any
2xxwithin 10 seconds, then do the work. Redirects are not followed. - Failed deliveries are retried after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h. A subscription whose events fail every retry five times in a row is switched off; subscribe again with the same topic and URL to switch it back on.
- Events can arrive more than once and out of order. Deduplicate on
X-Neptune-Event-Id, and when order matters comparedata.updated_ator re-readGET /orders/{id}.
Verifying the signature
Compute HMAC-SHA256 of "<t>.<raw body>" with your webhook secret, compare in constant time with v1, and reject timestamps older than 5 minutes.
# Python
import hashlib, hmac, time
def verify(secret: str, header: str, raw_body: bytes) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False
expected = hmac.new(secret.encode(), f'{parts["t"]}.'.encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts["v1"])
// Node.js
const crypto = require("crypto");
function verify(secret, header, rawBody) {
const parts = Object.fromEntries(header.split(",").map(p => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.`).update(rawBody).digest("hex");
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}
// PHP
function verify(string $secret, string $header, string $rawBody): bool {
parse_str(str_replace(',', '&', $header), $parts);
if (abs(time() - (int)$parts['t']) > 300) return false;
$expected = hash_hmac('sha256', $parts['t'] . '.' . $rawBody, $secret);
return hash_equals($expected, $parts['v1']);
}
Uninstalling
When a merchant removes the Neptune connection on your side, call POST /oauth/revoke with their token. The token stops working at once. When they disconnect your app on Neptune's side, you receive app.uninstalled.
Products already created stay on Neptune: a disconnected store's products remain in the merchant's catalog, where they manage them by hand.
Errors
{"error": {"code": "validation_failed", "message": "Some fields are invalid.",
"details": {"fields": {"price": "This field is required.", "variants[1].option2": "Must be one of the values of option \"Color\"."}}}}
| HTTP | code | Meaning |
|---|---|---|
| 400 | invalid_json, invalid_body, invalid_parameter | The request itself is malformed. |
| 401 | missing_token, invalid_token | No token, or a revoked one. |
| 403 | missing_scope | The token lacks the scope in details.required_scope. |
| 403 | store_not_approved, brand_inactive, owner_changed, app_suspended | The account or app may not use the API right now. |
| 404 | not_found | Unknown id, or one that belongs to another account. |
| 409 | plan_limit_reached, managed_by_neptune, already_collected, invalid_transition, invalid_status_transition, limit_reached | Valid request, refused by the business rules. |
| 422 | validation_failed | See details.fields. |
| 429 | rate_limited | Wait Retry-After seconds. |
Retry 429 and 5xx with exponential backoff. Do not retry other 4xx without fixing the request.
Security checklist
- Keep keys, client secrets and webhook secrets on your server, encrypted at rest.
- Ask only for the scopes you use; merchants see them on the approval screen.
- Always check
statein the OAuth callback, and use PKCE. - Verify every webhook signature and timestamp before trusting it.
- Customer details in orders are personal data: use them only to fulfil the order, and delete them when the merchant disconnects.
- Report a vulnerability to security@neptune.tn.
Version 1. Changes that could break an integration will ship under /api/integrations/v2/; v1 then stays available for at least 6 months. New fields may be added to responses at any time: ignore fields you do not know.