Overview
All requests go to https://panel.ladnai.com/api/v1 over HTTPS. Request and response bodies are UTF-8 JSON. The company is determined only by the key:
another company's data is never reachable through the API.
- Available now: the key and its access (
/v1/me), company dictionaries, products (creation and batch updates of prices and stock), clients, orders (from a website, status, waybill), messages to clients in an existing conversation, the call log with recordings; webhooks — events about new messages, calls, order statuses, a client confirming an order, and stock. - Changes without notice are only backwards-compatible ones: new response fields, new endpoints, new error codes. Your code must ignore unknown fields.
Breaking changes come only in a new version (
/v2) with advance notice.
Keys
Keys are created by the owner or by a person with the Settings permission: Settings → Integrations → API. There are two:
- Live —
ld_live_…, works with the company's data. - Sandbox —
ld_test_…, works with a copy of the catalog and dictionaries (see "Sandbox").
There is also a store module key — ld_shop_…: the Settings → Integrations → Connection → Store module wizard issues it for the WooCommerce module.
It works only inside the module (/v1/me, dictionaries and the module's own endpoints); for your own integrations use the keys above
(module_key).
A key is 56 characters: a prefix, a 10-character identifier, a 32-character secret and a 6-character checksum. The prefix helps secret scanners find a key that ended up in code or a chat by accident; the checksum rejects truncated or made-up keys before any database lookup.
A key is shown once — right after it is created. We store only its fingerprint (HMAC-SHA-256 with a server secret), so nobody, including us, can show the key again. Lost it? Manage → New key.
Send the key only in the header of every request:
Authorization: Bearer ld_live_…A key in the URL (?api_key=, ?token= etc.) is rejected with key_in_url — URLs end up in logs,
browser history and proxies. There are no cookies and no CORS: the API is for your server only, not for website pages in a browser.
Key access
A new key can do nothing except read dictionaries — you enable each section yourself. Sections are the same for the live and sandbox keys: what you tested in the sandbox will work live. Without access you get 403 insufficient_scope, checked before any data is read.
| Section | Name in /v1/me | Levels |
|---|---|---|
| Products | products | none · read · read_write |
| Orders | orders | none · read · read_write |
| Clients | clients | none · read · read_write |
| Messages | messages | none · send |
| Call log | calls | none · read |
| Dictionaries | dictionaries | read — always read |
Products with read_write — reading and changes, including creating new products (POST /v1/products) and batch updates of prices, stock, minimum order and order step.
IP allowlist
Each key can be limited to certain addresses — up to 20 addresses or networks, comma-separated: 203.0.113.10, 198.51.100.0/24. IPv4 networks no wider than /8, IPv6 no wider than /32. A request from another address gets 403 ip_not_allowed with your address in detail. If your server has a fixed address, restrict the key: even a leaked key will not work from someone else's server.
Rotation and revocation
New key in Manage: the old key stops working immediately or keeps working for 24 more hours so you can replace it everywhere. The new key inherits sections and addresses from the old one. After the switch the old key gets 401 api_key_expired.
Revoke stops the key immediately (401 api_key_revoked). Do it when the key may be in the wrong hands: a person with access left, the key ended up in code or a chat, the request log shows unknown addresses.
Every key action is recorded in the account's Activity log. If someone tries to guess the secret for a real key identifier, the owner gets a notification.
Sandbox
The ld_test_… key works with a separate copy of the company: products with prices, stock and variants, warehouses, price lists, currencies, units, groups, statuses, funnels and line names. The company's clients, orders, conversations, calls, people, files and logs are not there, and lines are never connected, so the sandbox never sends anything to anyone. Change prices and stock, create clients and orders as much as you like — real data is not touched. There are no conversations in the sandbox, so POST /v1/messages always answers 422 no_dialog there — use it to test your error handling.
- Identifiers (
idof products, warehouses, price lists) are the same as in the company at the moment of copying: code tested in the sandbox works with the live key unchanged. - The sandbox also shows the demo set examples of a new company — the live key does not return them.
- Copy again (in the sandbox key's Manage dialog) makes a fresh copy; everything changed in the sandbox is lost. While copying, responses are 503 sandbox_unavailable.
- Sandbox responses carry the
Ladnai-Mode: testheader, and/v1/mereturns"livemode": false.
Requests and responses
| What | How |
|---|---|
| Methods | GET — read, POST — create, PATCH — change only the fields sent. Nothing can be deleted through the API |
Retrying POST | The Idempotency-Key header — a retry after a dropped connection creates no duplicate (see "Idempotent retries") |
| Body | Content-Type: application/json, a single object, UTF-8, up to 1 MB and 20,000 values, nesting up to 32 levels, uncompressed |
| Response | application/json; errors — application/problem+json. Do not cache: Cache-Control: no-store |
| Money | A string with two decimals: "1180.00" — so no cents are lost converting numbers |
| Quantity | A number with up to 3 decimals: 12.5; fractions only for fractional units (kg, l) |
| Date and time | RFC 3339 in UTC with milliseconds: 2026-10-18T09:12:54.947Z |
| Identifiers | Strings ("p1", "kyiv") — do not parse or build them yourself |
| Text | Normalized to NFC; control characters (except line breaks where they make sense), invisible and direction-changing characters are removed. The U+200D joiner is kept — compound emoji are built with it (👩💻, ❤️🔥, 👨👩👧). Field lengths are in characters (Unicode code points); when text is trimmed, compound emoji are never cut in half |
| Unknown input | Unknown query parameters and body fields are errors, not silently ignored |
| Request id | X-Request-Id header in every response and request_id in errors — give it to support |
Pagination
Lists are paginated: limit from 1 to 100 (default 50). The response has has_more and next_cursor; to get the next page pass cursor=next_cursor with the same parameters. The cursor is opaque and signed: do not parse or build it; it is valid for 3 days and only with the same filters (otherwise 400 invalid_cursor). Pages do not shift when products are added between requests.
{
"object": "list",
"data": [
"…"
],
"has_more": true,
"next_cursor": "eyJwIjpbInAxMCJdLCJ0Ijo…"
}Idempotent retries
The connection dropped after a POST and you do not know whether the order was created? Send an Idempotency-Key header with every POST (8–255 letters, digits, _ - : . — e.g. a UUID per new order) and retry with the same key: if the first request already succeeded, you get the same response with Idempotent-Replayed: true instead of a second order. Responses are kept for 24 hours; the same key with a different body gives 422, and while the first request is still running — 409. Errors (4xx / 5xx) are not stored — fix the request and resend with the same key.
Website orders also have external_id — the order number on your website: a second order with the same number is never created (409 already_exists with the existing number).
Idempotency-Key: 6f1d2c3e-0a4b-4c1e-9d3a-7b2f1e5c8a90Rate limits
Limits depend on the company's plan and are counted separately for the live and sandbox keys. Current numbers are in /v1/me (limits) and on the account's API tab. By default:
| What | How much | Over the limit |
|---|---|---|
| Per minute | 60 requests | 429 rate_limited, Retry-After — until the minute ends |
| Per day | 50,000 requests, resets at 00:00 Kyiv time | 429 rate_limited, Retry-After — until midnight |
| Concurrent | 2 requests per company | 429 too_many_concurrent |
| Batch | 500 products per request — counts as one | 422, too_many |
| Order | 200 items per order | 422, too_many |
| Messages to clients | 20 per minute and 500 per day per company — on top of request limits: messengers ban numbers for bulk messaging | 429 rate_limited, Retry-After |
| Wrong key | 10 per minute or 50 per hour from one address (IPv6 — per /64 network) | 429 too_many_failed_auth, 15-minute pause |
Every response shows what is left (RateLimit headers): r — remaining, t — seconds until reset.
RateLimit-Policy: "minute";q=60;w=60, "day";q=50000;w=86400
RateLimit: "minute";r=57;t=21, "day";r=49120;t=40210
Retry-After: 21Got a 429? Wait for the number of seconds in Retry-After and retry. Do not retry immediately in a loop — that only keeps you limited longer.
Errors
Errors follow RFC 9457 (application/problem+json). Rely on code — it is stable; detail is a human explanation in English and its wording may change. type links to the code's description here. Errors never contain internal details (database queries, paths, stack traces).
{
"type": "https://ladnai.com/docs/api#error-insufficient_scope",
"title": "Forbidden",
"status": 403,
"code": "insufficient_scope",
"detail": "This key has no access to «prod» (write). The owner can allow it in Settings → Integrations → API.",
"request_id": "9f2c4be1a07d4c55b3e1f2a6c8d90e17"
}| Code | HTTP | Description | What to do |
|---|---|---|---|
https_required | 400 | Plain HTTP request. | Use https://panel.ladnai.com/api/v1 only. There is deliberately no redirect: the key has already travelled in clear text — create a new one. |
key_in_url | 400 | The key was sent in the URL (api_key=, token= etc.). | URLs end up in logs and history — treat the key as leaked, create a new one and send it only in the Authorization header. |
invalid_json | 400 | The body is not a UTF-8 JSON object or is nested deeper than 32 levels. | Send a single JSON object encoded as UTF-8. |
unknown_parameter | 400 | Unknown query parameter. | A typo never silently returns everything — check the name; allowed ones are listed in detail. |
invalid_parameter | 400 | Invalid parameter (format, length, repeated). | Each parameter's format is described in its resource section. |
invalid_cursor | 400 | The cursor is corrupted, expired (3 days) or from other filters. | Use next_cursor only from the previous response with the same parameters; if expired, start over. |
missing_api_key | 401 | No Authorization header. | Add Authorization: Bearer |
invalid_api_key | 401 | The key is not valid (truncated, has a space, made up). | Copy the whole key. Requests from unknown addresses with a wrong key are a reason to create a new key and restrict IPs. |
api_key_revoked | 401 | The key was revoked or replaced. | Put the current key into your system. |
api_key_expired | 401 | The old key kept working for 24 hours after "New key" — that time is over. | Use the new key. |
read_only | 402 | Read-only mode: the company plan was not renewed — new orders and messages to clients are not created. | Top up the balance in the account (Subscription) — writing resumes at once. Reading, the catalog (products, prices, stock) and incoming messages keep working in read-only mode. |
blocked | 402 | The company subscription is suspended. | The company owner should contact Ladnai support. |
trial_limit | 402 | A trial limit is used up (outgoing messages, bulk sending, new people per day). | Continue after paying for a plan (Subscription); the new-people-per-day limit resets tomorrow. What exactly is used up — in detail. |
plan_limit | 402 | The plan's monthly limit is used up (for example, outgoing messages). | Buy a pack in Subscription (with auto top-up — top up the balance) or wait for the new limit on the 1st. Incoming messages are still received. |
line_paused | 402 | The line is paused: more numbers are connected than the plan allows. | Incoming messages are still received; replies from this line work again after buying extra numbers (Subscription → Extra numbers) or disconnecting extra lines. |
ip_not_allowed | 403 | Your address is not in the key's allowlist. | Add the address under the key's Manage dialog or call from an allowed one. Your address is in detail. |
insufficient_scope | 403 | The key has no access to this section or action. | The owner changes access in Settings → Integrations → API → Key access. |
recording_download_disabled | 403 | Downloading call recordings is turned off in the company. | Turn it on in Settings → Calls. |
module_key | 403 | A store module key (ld_shop_…) does not work outside the module. | For your own integration create a key in Settings → Integrations → API. |
module_only | 403 | The store module endpoints accept only the module key. | Install the module on the site and paste its key from Integrations → Connection → Store module. |
module_off | 403 | The store module is disconnected in the account. | Connect it again — the wizard issues a new module key. |
not_found | 404 | No such record or endpoint (or it belongs to another company). | Check the id and path. Foreign and missing records look the same. |
method_not_allowed | 405 | The path does not accept this method. | Allowed methods are in the Allow header. |
not_acceptable | 406 | Accept does not allow JSON. | Send Accept: application/json or omit Accept. |
conflict | 409 | Not saved: the data changed or failed a check. | Read fresh data and retry. |
already_exists | 409 | Already exists: an order with this external_id or a client with this phone / email. | The existing number or id is in detail and errors. Do not create it again — update the existing one. |
idempotency_in_progress | 409 | A request with this Idempotency-Key is still running. | Retry in a second (Retry-After). |
client_blocked | 409 | The client is in the company block list. | Messages are not sent. Unblock in the account. |
payload_too_large | 413 | Body over 1 MB or over 20,000 values. | Split the batch into several requests. |
unsupported_media_type | 415 | POST / PATCH without Content-Type: application/json. | Add Content-Type: application/json. |
unsupported_encoding | 415 | Compressed body (Content-Encoding). | Send the body uncompressed. |
validation_failed | 422 | Validation failed. | Fields with problems are in errors (pointer — where, code — what). |
idempotency_key_reused | 422 | The Idempotency-Key was already used with a different request. | Use a new key for a new request. |
no_dialog | 422 | The client has no messenger conversation with the company (or on this line). | The API never writes first — wait until the client writes. |
rate_limited | 429 | The plan's per-minute or per-day limit is used up. | Retry after Retry-After seconds. Update prices and stock in batches of up to 500. |
too_many_concurrent | 429 | More than 2 concurrent requests per company. | Wait for the previous response. |
too_many_failed_auth | 429 | Too many requests with a wrong key from this address. | 15-minute pause. Check the key in your system's settings. |
server_error | 500 | Something went wrong on our side. | Retry later. If it repeats, contact support with the request_id. |
sandbox_unavailable | 503 | The sandbox is being copied right now. | Retry in a minute (Retry-After). |
unavailable | 503 | The company temporarily does not accept changes. | Retry later. |
storage_unavailable | 503 | The call recording is in file storage that is not responding right now. | Retry after Retry-After seconds — the recording is not lost. |
402 means a limit of the company subscription, not a mistake in your request: read-only mode, a suspended subscription, a trial or plan limit, a paused line. Retrying the same request in a loop does not help — detail says in English what the company owner should do (usually in the account, Subscription); once the reason is gone, the same request goes through. Reading and the catalog (products, prices, stock) keep working meanwhile.
In validation_failed and in batch results each problem is a separate entry: pointer (JSON Pointer to the field), code and detail. Field codes:
| Code | Description |
|---|---|
required | a field is required or there is nothing to change |
unknown_field | unknown field — typos are not ignored |
invalid_type | wrong type (string, object, number) |
invalid_format | price or quantity format |
invalid_value | value not allowed (unit, fractional quantity, empty SKU, minimum not a multiple of the step) |
not_found | no such product, variant, price list or warehouse |
duplicate | the same product (variant) twice in the batch; on create — this SKU or variant name already exists |
not_allowed | not allowed: price, minimum or step of a variant, stock of a service or of a product with variants |
below_reserved | on hand below the quantity reserved for orders |
conflict | the sku points to another variant than variant |
too_long | text longer than allowed |
insufficient_stock | more than is free in stock while pre-orders are disabled |
too_many | more than 500 items in a batch, 200 in an order, 200 variants or 10 packs in a product |
Key: /v1/me
/v1/meKey check: company, mode (live / test), section access and limits. A good first request after setup.
{
"object": "api_key",
"mode": "live",
"livemode": true,
"company": {
"name": "Кава й чай"
},
"scopes": {
"products": "read_write",
"orders": "none",
"clients": "none",
"messages": "none",
"calls": "none",
"dictionaries": "read"
},
"limits": {
"per_minute": 60,
"per_day": 50000,
"concurrent": 2,
"batch": 500
}
}Dictionaries
/v1/dict/{name}Company dictionaries — always read-only, with any key. This is where the ids of price lists, warehouses, statuses, payment methods, lines, people and tags for other requests come from.
| Dictionary | Contents |
|---|---|
price-lists | price lists: id, name, currency, default — the main one |
units | units: id (e.g. кг), name, fractional — whether fractions are allowed |
payment-methods | payment methods: id, name, kind, currencies, enabled |
currencies | currencies: code, name, symbol, base — the base one, rate — rate to base as a string |
statuses | order statuses: name, color, step, system — new / done / cancel |
warehouses | warehouses: id, name |
product-groups | product groups: id, name |
lines | lines (channels): id, name, channel |
managers | company people: id, name, role — no phones or emails |
stages | funnel stages: id, funnel, name, kind |
tags | client tags: id, name (label), color |
GET /v1/dict/price-lists{
"object": "list",
"data": [
{
"id": "retail",
"name": "Роздріб",
"currency": "UAH",
"default": true
},
{
"id": "opt",
"name": "Опт",
"currency": "USD",
"default": false
}
]
}Products
Company products with prices per price list, stock per warehouse and variants. Purchase prices and internal fields are never exposed.
/v1/productsproducts · read| Parameter | Description |
|---|---|
limit | 1–100, default 50 |
cursor | next_cursor from the previous page |
q | search in name and SKU, up to 100 characters |
sku | exact SKU |
group | group id from /v1/dict/product-groups |
updated_since | only changed since this time (RFC 3339): 2026-10-18T09:00:00Z. Pages are ordered by change time; for sync, store the last product's updated_at and pass it next time |
Product object
| Field | Description |
|---|---|
id, sku, name, brand | identifier, SKU, name, brand |
description | description and specifications — plain text up to 2000 characters, lines separated by \n; none — an empty string |
alt_names | other names, comma-separated — how customers call the product (the AI assistant finds it by them); none — an empty string |
group | {id, name, min_qty, step_qty} or null; the group's min_qty / step_qty are null if the group has none |
unit | base unit (id from /v1/dict/units) |
service | true — a service, no stock (stock: null) |
packs | packs: {unit, qty} — base units per pack |
min_qty, step_qty | the product's minimum order and order step in the base unit; null — none of its own, the group's apply (group.min_qty / group.step_qty). The effective value is the product's, otherwise the group's |
prices | prices: {price_list, price, currency, per}; per — what the price is for (unit or pack). A price list missing here means the product is not sold in it |
stock | on_hand — physically in warehouses, reserved — for orders, available — free; warehouses — the same per warehouse |
variants | variants {id, name, sku, stock}; for a product with variants stock is the sum of variants |
updated_at | when the product last changed |
{
"object": "product",
"id": "p1",
"sku": "KV-ETH-YRG",
"name": "Ефіопія Іргачеф",
"brand": "Своя обсмажка",
"description": "Арабіка 100%, мита обробка\nОбсмаження: світле\nВага: 1 кг, зерно",
"alt_names": "Іргачефф, ефіопська кава",
"group": {
"id": "coffee",
"name": "Кава",
"min_qty": 1,
"step_qty": null
},
"unit": "кг",
"service": false,
"packs": [
{
"unit": "кор",
"qty": 10
}
],
"min_qty": 2,
"step_qty": 0.5,
"prices": [
{
"price_list": "opt",
"price": "241.00",
"currency": "USD",
"per": "кор"
},
{
"price_list": "retail",
"price": "1180.00",
"currency": "UAH",
"per": "кг"
}
],
"stock": {
"on_hand": 45,
"reserved": 3,
"available": 42,
"warehouses": [
{
"warehouse": "kyiv",
"on_hand": 34,
"reserved": 3,
"available": 31
},
{
"warehouse": "odesa",
"on_hand": 11,
"reserved": 0,
"available": 11
}
]
},
"variants": [],
"updated_at": "2026-10-18T09:12:54.947Z"
}/v1/products/{id}products · readOne product by id. Missing (or another company's) — 404 not_found.
Create a product
/v1/productsproducts · read & writeOne new product per request (thousands at once — file import or a feed in the account). The SKU is required and unique among the company's products and variants (case-insensitive): if it already exists — 409 already_exists, the existing id is in errors; update it with a batch. Retry after a dropped connection with the same Idempotency-Key (see "Idempotent retries"). Photos are not added through the API.
| Field | Description |
|---|---|
sku | required, 1–64 characters |
name | required, 1–255 |
prices | required: {"retail": "1350.00"} or {"opt": {"price": "270.00", "per": "кор"}} — as in a batch; the default price list price is required; simply leave out price lists you do not sell in |
unit | id from /v1/dict/units; omitted — «шт» (or the first unit if there is no «шт») |
group | id from /v1/dict/product-groups or null — no group |
brand | up to 120 |
description | plain text up to 2000 after cleanup (HTML tags are removed, list items become lines «• »); longer — too_long, never silently trimmed |
alt_names | other names, comma-separated, up to 1000 |
service | true — a service: no stock or variants |
packs | up to 10 packs {unit, qty}: a unit from the dictionary, not the base one, no repeats; qty — base units per pack (more than 1; whole from 2 for non-fractional units) |
stock | {"kyiv": 20} — initial stock per warehouse (as in a batch); with variants — in the variants |
min_qty, step_qty | as in a batch: 0…1,000,000, null or 0 — as in the group; the effective minimum is a multiple of the effective step |
variants | up to 200 variants {name, sku?, stock?}: name 1–190, no repeats; SKU optional and unique; the product's stock is the sum of variants |
Request
{
"sku": "KV-KEN-AA",
"name": "Кенія АА",
"unit": "кг",
"group": "coffee",
"brand": "Своя обсмажка",
"description": "Арабіка, мита обробка\nОбсмаження: середнє",
"alt_names": "кенійська кава, Kenya AA",
"packs": [
{
"unit": "кор",
"qty": 10
}
],
"prices": {
"retail": "1350.00",
"opt": {
"price": "270.00",
"per": "кор"
}
},
"stock": {
"kyiv": 20,
"odesa": 5
},
"min_qty": 1,
"step_qty": 0.5
}Response
{
"object": "product",
"id": "pa1",
"sku": "KV-KEN-AA",
"name": "Кенія АА",
"brand": "Своя обсмажка",
"description": "Арабіка, мита обробка\nОбсмаження: середнє",
"alt_names": "кенійська кава, Kenya AA",
"group": {
"id": "coffee",
"name": "Кава",
"min_qty": null,
"step_qty": null
},
"unit": "кг",
"service": false,
"packs": [
{
"unit": "кор",
"qty": 10
}
],
"min_qty": 1,
"step_qty": 0.5,
"prices": [
{
"price_list": "opt",
"price": "270.00",
"currency": "USD",
"per": "кор"
},
{
"price_list": "retail",
"price": "1350.00",
"currency": "UAH",
"per": "кг"
}
],
"stock": {
"on_hand": 25,
"reserved": 0,
"available": 25,
"warehouses": [
{
"warehouse": "kyiv",
"on_hand": 20,
"reserved": 0,
"available": 20
},
{
"warehouse": "odesa",
"on_hand": 5,
"reserved": 0,
"available": 5
}
]
},
"variants": [],
"updated_at": "2026-11-15T10:20:31.512Z"
}The response is 201 with the same object as GET /v1/products/{id}. The id is a string — do not parse it. The initial stock is recorded as a stock movement "API · new product", the creation goes to the Activity log as "system: API"; managers see the product right away. An unknown field — unknown_field, field errors — 422 with a list.
The SKU already exists
{
"type": "https://ladnai.com/docs/api#error-already_exists",
"title": "Conflict",
"status": 409,
"code": "already_exists",
"detail": "A product or variant with this sku already exists — update it with PATCH /v1/products/batch.",
"request_id": "4c1e8a0b92d34f6e8b7a5c3d1e0f9a27",
"errors": [
{
"pointer": "/sku",
"code": "duplicate",
"detail": "Existing product pa1."
}
]
}Batch prices and stock
/v1/products/batchproducts · read & writePrices, stock, minimum order and order step for up to 500 products in one request (counts as one against the limit). Values are absolute: "price is now 1190", "40 on hand", not "+5". So repeating the same request after a dropped connection is safe: the second time the items come back as unchanged.
| Field | Description |
|---|---|
items[] | items, 1–500 |
items[].id or items[].sku | the product — exactly one of the two; a variant's SKU also works in sku; an empty SKU is an item error invalid_value |
items[].variant | variant id or SKU — for a variant's stock |
items[].prices | {"retail": "1190.00"} — price in a price list; {"opt": {"price": "245.00", "per": "кор"}} — price per pack; null — no longer sold in this price list (the default price list cannot be left without a price). Prices belong to the product and are shared by variants |
items[].stock | {"kyiv": 40} — how much is physically in the warehouse. Not less than reserved for orders. For a product with variants — per variant |
items[].min_qty, items[].step_qty | the product's (not a variant's) minimum order and order step in the base unit: 0…1,000,000, up to 3 decimals, whole numbers for non-fractional units; null or 0 — as in the group. The effective minimum must be a multiple of the effective step (counting the group) |
atomic | true — all items or none (error — 422 with a list). Default false: failed items are skipped, the rest are saved together |
Request
{
"items": [
{
"sku": "KV-ETH-YRG",
"prices": {
"retail": "1190.00",
"opt": {
"price": "245.00",
"per": "кор"
}
},
"stock": {
"kyiv": 40
},
"min_qty": 2
},
{
"sku": "MUG-RED",
"stock": {
"kyiv": 5
}
},
{
"sku": "NOPE-1",
"stock": {
"kyiv": 1
}
},
{
"id": "p10",
"prices": {
"retail": "0"
}
}
]
}Response
{
"object": "batch_result",
"updated": 2,
"unchanged": 0,
"failed": 2,
"results": [
{
"index": 0,
"status": "updated",
"id": "p1"
},
{
"index": 1,
"status": "updated",
"id": "p14",
"variant": "v1"
},
{
"index": 2,
"status": "failed",
"id": null,
"errors": [
{
"pointer": "/items/2/sku",
"code": "not_found",
"detail": "No such product."
}
]
},
{
"index": 3,
"status": "failed",
"id": "p10",
"errors": [
{
"pointer": "/items/3/prices/retail",
"code": "invalid_format",
"detail": "Price as a string like \"1180.00\": greater than 0, at most 2 decimals."
}
]
}
]
}The response has totals and each item's result in the same order: updated, unchanged or failed with errors. Stock changes are recorded as a stock movement "API · batch update", changes go to the Activity log as "system: API"; reservations and managers' screens update immediately.
Clients
Company clients: name, phone, email, city, channel and messenger accounts, tags, who handles them. Debts, payment terms, complaints and conversations are not exposed. Merged duplicates are not listed; fetching a duplicate by id returns merged_into — the id of the card it was merged into.
/v1/clientsclients · read| Parameter | Description |
|---|---|
limit, cursor | pages as for products; newest first |
q | part of name, email or city, up to 100 characters |
phone | phone number, 7–15 digits in any notation (0671234567, +38 067 123-45-67); a full number matches exactly, also among Viber / WhatsApp accounts. Only on its own, up to 100 clients |
email | exact email |
tag | tag id from /v1/dict/tags |
updated_since | changed since this time (RFC 3339) — for sync |
{
"object": "client",
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380 67 000 00 01",
"phone_e164": "+380670000001",
"email": "olena@example.com",
"city": "Київ",
"channel": "site",
"accounts": [
{
"channel": "site",
"handle": "+380670000001"
}
],
"tags": [
{
"id": "vip",
"label": "VIP"
}
],
"manager": {
"id": 2,
"name": "Марія"
},
"comment": null,
"price_list": null,
"blocked": false,
"orders_count": 3,
"updated_at": "2026-10-18T09:12:54.947Z"
}/v1/clients/{id}clients · readCreate and update
/v1/clientsclients · read & write/v1/clients/{id}clients · read & writeCreate — a name and a phone or email; optionally city, comment, tags (tags — ids), manager (manager_id from /v1/dict/managers). The new client appears in the account with channel "Site" and no conversation: you can message them once they write in a messenger. If a client with the same full phone or email exists — 409 already_exists with their id (update it with PATCH); no duplicate is created.
Update — the same fields, only those you send; tags replaces all tags, manager_id: null removes the manager.
{
"name": "Олена Кравець",
"phone": "+380 67 000 00 01",
"email": "olena@example.com",
"city": "Київ",
"tags": [
"vip"
]
}Orders
Orders with item lines, totals, payments, delivery and status. The number is number without "#". Amounts are strings in the order currency; due is what is left to pay, reserved / shipped in a line — reserved and shipped (in the product's base units). Team comments on orders are not exposed — they are for the team only.
/v1/ordersorders · read| Parameter | Description |
|---|---|
limit, cursor | pages; newest numbers first |
status | status name from /v1/dict/statuses |
client_id | orders of a client |
external_id | order number on your website |
q | part of the number or waybill |
updated_since | changed since this time (RFC 3339) — to sync statuses and payments |
/v1/orders/{number}orders · read{
"object": "order",
"number": "45401",
"date": "2026-10-18",
"status": {
"name": "Нове",
"step": 0,
"system": "new"
},
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380670000001"
},
"currency": "UAH",
"total": "2709.00",
"paid": "2709.00",
"due": "0.00",
"subtotal": null,
"price_list": "retail",
"rate": null,
"items": [
{
"id": "l1",
"product_id": "p1",
"variant_id": null,
"warehouse": "kyiv",
"name": "Ефіопія Іргачеф",
"sku": "KV-ETH-YRG",
"quantity": 2,
"unit": "кг",
"pack_qty": 1,
"price": "1180.00",
"amount": "2360.00",
"reserved": 2,
"shipped": 0
},
{
"id": "l2",
"product_id": "p14",
"variant_id": "v1",
"warehouse": "kyiv",
"name": "Чашка · Червоний",
"sku": "MUG-RED",
"quantity": 1,
"unit": "шт",
"pack_qty": 1,
"price": "349.00",
"amount": "349.00",
"reserved": 1,
"shipped": 0
}
],
"delivery": "Нова Пошта, Київ, відділення №12",
"ttn": null,
"payment": {
"term": "pre",
"method": {
"id": "card",
"name": "Картка"
},
"text": "Передоплата · Картка",
"due_date": null
},
"payments": [
{
"id": "p176081234500077",
"amount": "2709.00",
"method": "card",
"at": "2026-10-18T09:12:54.947Z",
"reconciled": false
}
],
"cancel_reason": null,
"source": "site",
"external_id": "WC-1042",
"updated_at": "2026-10-18T09:12:54.947Z"
}Create an order
/v1/ordersorders · read & write| Field | Description |
|---|---|
client | {"id"} of an existing client or {"name", "phone", "email", "city"}: found by full phone or email, otherwise created (channel "Site") |
items[] | 1–200 items: product_id or sku (a variant's SKU works too), variant for products with variants, quantity, unit — unit or pack (default — as in the price list), price — per line unit (omitted — from the client's price list incl. special prices), warehouse (default — the orders warehouse) |
price_list | price list (default — assigned to the client, by tag, or the default one); it sets the order currency and rate |
payment | term — pre prepayment, rcv on receipt, def deferred (+ days), dep deposit (+ deposit); only those enabled in the price list. method — from /v1/dict/payment-methods. Default — as for this client in the account |
paid | payment already made on the website: {"amount", "method", "note"} — recorded on the order as not reconciled |
delivery | delivery as text, up to 255 characters; Nova Poshta — "Нова Пошта, city, відділення №…" |
comment | comment for the team (the client does not see it) |
external_id | the order number on your website, up to 64 characters — unique in the company |
Request
{
"external_id": "WC-1042",
"client": {
"name": "Олена Кравець",
"phone": "+380 67 000 00 01",
"city": "Київ"
},
"items": [
{
"sku": "KV-ETH-YRG",
"quantity": 2
},
{
"sku": "MUG-RED",
"quantity": 1,
"price": "349.00"
}
],
"delivery": "Нова Пошта, Київ, відділення №12",
"payment": {
"term": "pre",
"method": "card"
},
"paid": {
"amount": "2709.00",
"method": "card",
"note": "LiqPay 4417"
},
"comment": "Подзвонити після 18:00"
}Same as in the account: the server assigns the number, the status is the first "new" one, stock is reserved per Settings → Catalog (if pre-orders are disabled you cannot order more than is free: insufficient_stock on the item). Deferred payment adds a client debt and a reminder to the manager a day before the due date. If the client has a conversation, an event "Order created … from the website" appears there and the conversation moves to the "Deal" stage. Prices, total and currency are checked by the server; the response is the full order (201).
Status and waybill
/v1/orders/{number}orders · read & write| Field | Description |
|---|---|
status | status name from /v1/dict/statuses; cancelling (system: cancel) needs cancel_reason, the reservation is released |
ttn | waybill number, 4–40 letters, digits or dashes; "" — remove |
delivery | delivery as text |
comment | a new comment for the team |
Status and waybill changes add an event to the client conversation (nothing is sent to the client).
{
"status": "Відправлено",
"ttn": "20450000000001"
}Messages to clients
/v1/messagesmessages · sendText to a client in a messenger on behalf of a company line: into a conversation you already had (the latest one or on line_id). The API never writes first — a client without a conversation gives 422 no_dialog, so the company number does not get banned for spam. In the account the message shows "API" as the author. A blocked client — 409. A separate limit: 20 per minute and 500 per day per company. If the conversation's line is paused (more numbers than the plan allows) — 402 line_paused; read-only mode and subscription limits — other 402 codes.
The response is 202: the message is queued on the line, status is sending; later sent, delivered, read or failed with fail_reason — check GET /v1/messages/{id}. Text is 1–4000 characters, no files.
{
"client_id": "176081234500012",
"text": "Ваше замовлення №45401 прийнято. Дякуємо!"
}{
"object": "message",
"id": "176081234500101",
"client_id": "176081234500012",
"dialog_id": "176081234500013",
"line": {
"id": "l-tg1",
"name": "Кава й чай",
"channel": "telegram"
},
"text": "Ваше замовлення №45401 прийнято. Дякуємо!",
"status": "sending",
"fail_reason": null,
"created_at": "2026-10-18T09:13:02.114Z"
}/v1/messages/{id}messages · sendCall log
/v1/callscall log · readCalls on company lines, newest first: direction, state (completed, missed, rejected, busy, failed…), who answered, duration in seconds, client. Filters: from / to (RFC 3339), client_id, line_id, direction (inbound / outbound), state.
The call recording is a file (m4a / ogg) at recording.url, only if the company allows downloading recordings in Settings → Calls (otherwise 403); if recording storage does not respond — 503 storage_unavailable with Retry-After; every download goes to the company Activity log. Recordings are personal data: store them just as carefully.
{
"object": "call",
"id": "176081234500300",
"direction": "inbound",
"state": "completed",
"line": {
"id": "l-tg1",
"name": "Кава й чай",
"channel": "telegram"
},
"kind": "telegram",
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380670000001"
},
"started_at": "2026-10-18T08:01:10.000Z",
"answered_at": "2026-10-18T08:01:16.000Z",
"ended_at": "2026-10-18T08:05:40.000Z",
"duration": 264,
"answered_by": {
"id": 2,
"name": "Марія"
},
"initiated_by": null,
"recording": {
"size": 1048576,
"format": "m4a",
"url": "/v1/calls/176081234500300/recording"
}
}/v1/calls/{id}call log · read/v1/calls/{id}/recordingcall log · readWebhooks
https://example.com/hooks/ladnaifrom Ladnai to youWhen something happens in the company — a client writes, a call ends, an order status or product stock changes, a client confirms an order — Ladnai immediately sends a JSON POST
to your website or system. No need to poll the API every minute for news.
Setup: Settings → Integrations → Webhooks → Connect: the URL and the events. One URL per company. After the first save we show the signing secret
whsec_… — once, keep it on your server. Managed by the owner or a person with the Settings right; every change goes to the Activity log. Send a test request sends a test event.
URL: https:// and a domain only (not an IP address), port 443 or 8443, no username or password and no #, with a valid certificate. The domain must point to a public server — we never send to private or reserved networks. Redirects (3xx) are not followed — give the final URL. The sandbox sends no events.
| Header | Description |
|---|---|
Content-Type | application/json; the body is UTF-8, up to 256 KB |
X-Ladnai-Event | the event: message.new, call.new, order.status, order.confirmed, stock.changed, test |
X-Ladnai-Event-Id | the event id — the same as id in the body, identical in every retry |
X-Ladnai-Attempt | attempt number: 1, 2… |
X-Ladnai-Signature | t=…,v1=… — time and signature, see Verifying signatures |
User-Agent | Ladnai-Webhooks/1.0 (+https://ladnai.com/docs/api#webhooks) |
The body is the same for every event: id, event, created (UTC, RFC 3339) and data — the event data.
POST /hooks/ladnai HTTP/1.1
Content-Type: application/json
X-Ladnai-Event: test
X-Ladnai-Event-Id: evt_3b9d1f0a7c2e4b6d8a1f5e70
X-Ladnai-Attempt: 1
X-Ladnai-Signature: t=1760780467,v1=5f2c0d8e…e91a
{
"id": "evt_3b9d1f0a7c2e4b6d8a1f5e70",
"event": "test",
"created": "2026-10-18T09:41:07.312Z",
"data": {
"message": "Тестовий запит з Ладнай — адреса й підпис працюють",
"sent_by": {
"id": 1,
"name": "Олена Кравець"
}
}
}Response: any 2xx code within 10 seconds (3 s to connect); we do not read the response body. Respond at once and do the heavy work afterwards — in a queue or in the background: otherwise a slow website gets the same event again.
Events
You choose which events to send in the account. An event describes one change; read the full current state through the API (for example, GET /v1/orders/{number}).
| Event | When | data |
|---|---|---|
message.new | A client wrote in any channel — within 10–15 s. No imported history and no blocked clients | message (kind: text, photo, voice, file, sticker, video; a file — only its name, type and duration), client |
call.new | A call ended — within 20 s; a recorded one — once the recording is ready (up to 5 min). Inbound, outbound, missed | call — as in GET /v1/calls/{id}; the recording is at recording.url with an API key |
order.status | An order status changed or a new order appeared (previous_status: null) — by anyone: a manager, the API, an import | order, changed_by (user / api / system), changed_at |
order.confirmed | The client confirmed the order by the ladn.me link — as is or after changing quantities, the address or the recipient (if the company allows it). One event per order | order (number, external_id, the status name after confirmation, client, total and currency — already with the changes), changes — what the client changed (lines in Ukrainian; empty — confirmed as is), comment, recipient (city and branch are null for pickup), confirmed_at |
stock.changed | Physical stock or a reservation of a product or variant changed in any warehouse: a sale, shipment, receipt, reservation, import, API. One event per product or variant per action | product, variant, totals across warehouses (on_hand, reserved, available), warehouses — only the changed ones, with previous |
test | Send a test request in the account | message, sent_by |
{
"id": "evt_6f1c2a9e0b7d4c3a8e5f1d20",
"event": "message.new",
"created": "2026-10-18T09:41:09.004Z",
"data": {
"message": {
"id": "176078045500137",
"client_id": "176081234500012",
"dialog_id": "176081234500013",
"line": {
"id": "l-tg1",
"name": "Кава й чай",
"channel": "telegram"
},
"kind": "text",
"text": "Добрий день! Ефіопія Іргачеф 1 кг є в наявності?",
"file": null,
"created_at": "2026-10-18T09:40:55.137Z"
},
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380 67 000 00 01"
}
}
}{
"id": "evt_91d0e4b7a2c35f8e1b6d0a44",
"event": "call.new",
"created": "2026-10-18T10:05:31.420Z",
"data": {
"call": {
"object": "call",
"id": "176081234500300",
"direction": "inbound",
"state": "completed",
"line": {
"id": "l-tg1",
"name": "Кава й чай",
"channel": "telegram"
},
"kind": "telegram",
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380670000001"
},
"started_at": "2026-10-18T08:01:10.000Z",
"answered_at": "2026-10-18T08:01:16.000Z",
"ended_at": "2026-10-18T08:05:40.000Z",
"duration": 264,
"answered_by": {
"id": 2,
"name": "Марія"
},
"initiated_by": null,
"recording": {
"size": 1048576,
"format": "m4a",
"url": "/v1/calls/176081234500300/recording"
}
}
}
}{
"id": "evt_c4a87e21f90b3d65a7e2c1b9",
"event": "order.status",
"created": "2026-10-18T11:20:02.871Z",
"data": {
"order": {
"number": "45401",
"external_id": "WC-1042",
"status": {
"name": "Відправлено",
"step": 3,
"system": null
},
"previous_status": {
"name": "Підтверджено",
"step": 2,
"system": null
},
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380 67 000 00 01"
},
"total": "2360.00",
"currency": "UAH",
"ttn": "20450000000001",
"source": "site"
},
"changed_by": {
"type": "user",
"id": 2,
"name": "Ірина Мельник"
},
"changed_at": "2026-10-18T11:20:02.865Z"
}
}{
"id": "evt_8d2f6b1e9c0a4e7d3b5f2a61",
"event": "order.confirmed",
"created": "2026-10-27T10:12:44.208Z",
"data": {
"order": {
"number": "45401",
"external_id": "WC-1042",
"status": "Підтверджено",
"client": {
"id": "176081234500012",
"name": "Олена Кравець",
"phone": "+380 67 000 00 01"
},
"total": "2360.00",
"currency": "UAH"
},
"changes": [
"адреса: Київ, Відділення №12"
],
"comment": "Зателефонуйте перед відправкою, будь ласка",
"recipient": {
"name": "Олена Кравець",
"phone": "+380 67 000 00 01",
"city": "Київ",
"branch": "Відділення №12"
},
"confirmed_at": "2026-10-27T10:12:44.193Z"
}
}{
"id": "evt_5e2b7d1c8a9f04e3b6a1d7c2",
"event": "stock.changed",
"created": "2026-10-18T11:20:02.871Z",
"data": {
"product": {
"id": "p1",
"sku": "KV-ETH-YRG",
"name": "Ефіопія Іргачеф",
"unit": "кг"
},
"variant": null,
"on_hand": 43.0,
"reserved": 1.0,
"available": 42.0,
"warehouses": [
{
"warehouse": {
"id": "kyiv",
"name": "Київ"
},
"on_hand": 32.0,
"reserved": 1.0,
"available": 31.0,
"previous": {
"on_hand": 34.0,
"reserved": 3.0,
"available": 31.0
}
}
],
"changed_at": "2026-10-18T11:20:02.866Z"
}
}Verifying signatures
Verify every request — otherwise anyone who learns the URL could send you an "order". The signature is in the header:
X-Ladnai-Signature: t=1760780467,v1=5f2c0d8e…e91a
X-Ladnai-Signature: t=1760780467,v1=5f2c0d8e…e91a,v1=b71e04c2…3d08- Take
tand everyv1from the header. - Compute HMAC-SHA256 with the secret over the string
t + "." + body— the body exactly as received, byte for byte: do not parse and re-serialize the JSON. - Compare it with each
v1in constant time (hash_equals,timingSafeEqual). If any matches, the signature is valid. - Reject the request if
tdiffers from your clock by more than 5 minutes — so an intercepted request replayed later does not pass. - Keep the
idof processed events for at least 7 days; skip a repeat and respond 2xx.
After New secret with Keep old for 24 h the header carries two v1 — one with the new and one with the old secret: replace the secret on your side within a day. Keep the secret like a password — in a server environment variable, not in code or git.
<?php
// PHP 8. The secret comes from a server environment variable, not from code
$secret = getenv('LADNAI_WEBHOOK_SECRET');
// the body exactly as received, byte for byte
$body = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_LADNAI_SIGNATURE'] ?? '';
$t = null;
$v1 = [];
foreach (explode(',', $header) as $part) {
[$k, $v] = array_pad(explode('=', trim($part), 2), 2, '');
if ($k === 't') $t = $v;
if ($k === 'v1') $v1[] = $v;
}
$want = hash_hmac('sha256', $t . '.' . $body, $secret);
// during secret rotation there are two v1 — either one matches
$valid = false;
foreach ($v1 as $sig) {
if (hash_equals($want, $sig)) $valid = true;
}
if ($t === null || abs(time() - (int)$t) > 300 || !$valid) {
http_response_code(400);
exit;
}
$event = json_decode($body, true);
// already processed — just 200; seen(), enqueue(), remember() are your functions (database, queue)
if (!seen($event['id'])) {
// heavy work goes to a queue after the response; keep ids for at least 7 days
enqueue($event);
remember($event['id']);
}
http_response_code(200);// Node.js 18+ and Express. The secret comes from a server environment variable
import crypto from "node:crypto";
import express from "express";
const SECRET = process.env.LADNAI_WEBHOOK_SECRET;
const app = express();
// the body as raw bytes: the signature is computed over it, not over JSON.parse
app.post("/hooks/ladnai", express.raw({ type: "application/json", limit: "1mb" }), (req, res) => {
let t = null;
const v1 = [];
for (const part of (req.get("X-Ladnai-Signature") || "").split(",")) {
const [k, v] = part.trim().split("=");
if (k === "t") t = v;
if (k === "v1") v1.push(v);
}
const want = crypto.createHmac("sha256", SECRET).update(t + ".").update(req.body).digest();
// during secret rotation there are two v1; compare in constant time
const valid = v1.some((s) => {
const got = Buffer.from(s, "hex");
return got.length === want.length && crypto.timingSafeEqual(got, want);
});
if (!t || Math.abs(Date.now() / 1000 - Number(t)) > 300 || !valid) return res.sendStatus(400);
const event = JSON.parse(req.body.toString("utf8"));
// respond at once; process afterwards and skip an event with an id you have already seen
res.sendStatus(200);
handle(event).catch(console.error);
});
app.listen(3000);Retries and delivery
- Not delivered on the first try — no 2xx within 10 s, a connection or certificate error, a 3xx: we retry 1, 5, 15, 30 and 60 min after the first attempt — 6 attempts within an hour. Then it is "Not delivered" in the account.
- 410 Gone — the URL was removed: the company's webhooks are turned off and the owner is notified. Turn them back on in the account.
- The owner, if Notify the owner is on, gets a notification and an email when an event fails after all attempts or the URL has not responded for over an hour; at most once an hour.
- Duplicates are possible: your website processed an event but answered after 10 s, or the response got lost — the event comes again with the same
id. Send again in the account also uses the sameid. - Order is not guaranteed: events are sent in parallel, a retry may arrive after a newer event. Rely on
created/changed_atand read the current state through the API. - Delivery in the account shows every event for 7 days: attempts with code, time and reason, the request body, Send again for one or all failed events. Older events are deleted.
- While webhooks or an event are off, events are not stored: after turning them on you get only new ones, without history.
- Verify the sender by the signature, not by IP address: our server addresses may change.
Security
What we do
- HTTPS only (TLS 1.2+); plain HTTP is rejected, not redirected
- The key only in the header; a key in the URL is rejected
- Only a key fingerprint is stored (HMAC-SHA-256), compared in constant time
- Key access is per section, deny by default; addresses by allowlist
- The company comes only from the key; foreign records are 404 just like missing ones
- Strict input: unknown fields and parameters, size, depth, encoding are errors
- Rate limits, a pause for key guessing, a notification to the owner
- 30-day request log — without bodies, headers or parameter values; every change goes to the Activity log
- Responses are not cached, no cookies or CORS, security headers
- The API runs separately from the account (own process and limits) — API load does not slow down managers
- The API never writes to clients first and has its own message limit — the company number does not get banned for spam
- Call recordings only if the company allows downloads; every download goes to the Activity log
- Webhooks are signed with HMAC-SHA-256 and a timestamp; only to https domains with public addresses, no redirects; we keep the signing secret only encrypted
What you should do
- Keep the key in an environment variable or a server secret store — not in code, git or chats
- Never put the key into website pages or mobile apps — everyone would see it
- Test in the sandbox (
ld_test_); use the live key only on the production server - Give the key only the sections it needs and restrict it to your server's addresses
- Do not disable TLS certificate verification in your client
- Do not write the key to your logs; ours show only a hint
ld_live_…abcd - Rotate the key (New key with the old one kept for 24 hours) when a person with access leaves, and immediately if it may have leaked
- Check the request log: unknown addresses and 401s are a signal
- Verify the signature and time of every webhook and skip
ids you have already processed
Found a vulnerability? Write to support from the account — please do not publish it before it is fixed. We never ask for keys in emails or messages.
Examples
Five steps: check the key, read all products page by page, update prices and stock in a batch, send a website order, create a new product. The client waits for Retry-After on 429 by itself. Start with a sandbox key.
# the key comes from Settings → Integrations → API; never put it in code or in the URL
export LADNAI_API_KEY="ld_test_…"
# 1. check the key
curl https://panel.ladnai.com/api/v1/me \
-H "Authorization: Bearer $LADNAI_API_KEY"
# 2. products page by page: pass next_cursor from the response
curl "https://panel.ladnai.com/api/v1/products?limit=100" \
-H "Authorization: Bearer $LADNAI_API_KEY"
curl "https://panel.ladnai.com/api/v1/products?limit=100&cursor=NEXT_CURSOR" \
-H "Authorization: Bearer $LADNAI_API_KEY"
# 3. prices and stock — in batches of up to 500 products
curl -X PATCH https://panel.ladnai.com/api/v1/products/batch \
-H "Authorization: Bearer $LADNAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"items":[{"sku":"KV-ETH-YRG","prices":{"retail":"1190.00"},"stock":{"kyiv":40}}]}'
# 4. a website order: with Idempotency-Key a retry after a dropped connection creates no second order
curl -X POST https://panel.ladnai.com/api/v1/orders \
-H "Authorization: Bearer $LADNAI_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: wc-order-1042" \
-d '{"external_id":"WC-1042","client":{"name":"Олена Кравець","phone":"+380670000001"},"items":[{"sku":"KV-ETH-YRG","quantity":2}],"delivery":"Нова Пошта, Київ, відділення №12"}'
# 5. a new product (your SKU; if it already exists — 409 already_exists with the existing id)
curl -X POST https://panel.ladnai.com/api/v1/products \
-H "Authorization: Bearer $LADNAI_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: new-sku-KV-KEN-AA" \
-d '{"sku":"KV-KEN-AA","name":"Кенія АА","unit":"кг","prices":{"retail":"1350.00"},"stock":{"kyiv":20},"min_qty":1,"step_qty":0.5}'<?php
// PHP 8 with the curl extension. The key comes from an environment variable, not from code
const LADNAI = 'https://panel.ladnai.com/api/v1';
function ladnai(string $method, string $path, ?array $body = null, ?string $idem = null): array
{
for ($try = 1; ; $try++) {
$ch = curl_init(LADNAI . $path);
$opt = [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('LADNAI_API_KEY'), 'Accept: application/json'],
];
if ($body !== null) {
$opt[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json';
$opt[CURLOPT_POSTFIELDS] = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
}
if ($idem !== null) $opt[CURLOPT_HTTPHEADER][] = 'Idempotency-Key: ' . $idem;
curl_setopt_array($ch, $opt);
$raw = curl_exec($ch);
if ($raw === false) throw new RuntimeException(curl_error($ch));
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$head = substr($raw, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
$data = json_decode(substr($raw, strlen($head)), true);
// 429 — wait for Retry-After and retry (up to 5 times)
if ($status === 429 && $try < 5) {
sleep(preg_match('/^retry-after:\s*(\d+)/mi', $head, $m) ? (int)$m[1] : 1);
continue;
}
if ($status >= 400) throw new RuntimeException("{$data['code']}: {$data['detail']} (request_id {$data['request_id']})");
return $data;
}
}
$me = ladnai('GET', '/me');
echo $me['company']['name'], ' · ', $me['mode'], PHP_EOL;
// all products page by page
$cursor = null;
do {
$page = ladnai('GET', '/products?limit=100' . ($cursor ? '&cursor=' . urlencode($cursor) : ''));
foreach ($page['data'] as $p) echo $p['sku'], ' ', $p['stock']['available'] ?? '—', PHP_EOL;
$cursor = $page['next_cursor'];
} while ($page['has_more']);
// prices and stock — batches of up to 500; the same values again give "unchanged", so retries are safe
$r = ladnai('PATCH', '/products/batch', ['items' => [
['sku' => 'KV-ETH-YRG', 'prices' => ['retail' => '1190.00'], 'stock' => ['kyiv' => 40]],
['sku' => 'MUG-RED', 'stock' => ['kyiv' => 5]],
]]);
echo "updated {$r['updated']}, unchanged {$r['unchanged']}, failed {$r['failed']}", PHP_EOL;
// a website order: the retry key comes from the website order number, so a retry creates no second order
$o = ladnai('POST', '/orders', [
'external_id' => 'WC-1042',
'client' => ['name' => 'Олена Кравець', 'phone' => '+380670000001'],
'items' => [['sku' => 'KV-ETH-YRG', 'quantity' => 2]],
'delivery' => 'Нова Пошта, Київ, відділення №12',
], 'wc-order-1042');
echo "order #{$o['number']} · {$o['total']} {$o['currency']}", PHP_EOL;
// a new product: if the SKU already exists — 409 already_exists (the existing id is in errors), then update it with a batch
$n = ladnai('POST', '/products', [
'sku' => 'KV-KEN-AA',
'name' => 'Кенія АА',
'unit' => 'кг',
'prices' => ['retail' => '1350.00'],
'stock' => ['kyiv' => 20],
'min_qty' => 1,
'step_qty' => 0.5,
], 'new-sku-KV-KEN-AA');
echo "product {$n['id']} · {$n['sku']}", PHP_EOL;// Node.js 18+, file sync.mjs. The key comes from an environment variable. Never use the key in a browser (on website pages)
const BASE = "https://panel.ladnai.com/api/v1";
async function ladnai(method, path, body, idem) {
for (let attempt = 1; ; attempt++) {
const res = await fetch(BASE + path, {
method,
headers: {
Authorization: `Bearer ${process.env.LADNAI_API_KEY}`,
Accept: "application/json",
...(body ? { "Content-Type": "application/json" } : {}),
...(idem ? { "Idempotency-Key": idem } : {}),
},
body: body ? JSON.stringify(body) : undefined,
});
// 429 — wait for Retry-After and retry (up to 5 times)
if (res.status === 429 && attempt < 5) {
await new Promise((r) => setTimeout(r, Number(res.headers.get("Retry-After") || 1) * 1000));
continue;
}
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.detail} (request_id ${data.request_id})`);
return data;
}
}
const me = await ladnai("GET", "/me");
console.log(me.company.name, me.mode);
// all products page by page
let cursor = null;
do {
const page = await ladnai("GET", "/products?limit=100" + (cursor ? "&cursor=" + encodeURIComponent(cursor) : ""));
for (const p of page.data) console.log(p.sku, p.stock?.available ?? "—");
cursor = page.has_more ? page.next_cursor : null;
} while (cursor);
// prices and stock — batches of up to 500 products
const r = await ladnai("PATCH", "/products/batch", {
items: [
{ sku: "KV-ETH-YRG", prices: { retail: "1190.00" }, stock: { kyiv: 40 } },
{ sku: "MUG-RED", stock: { kyiv: 5 } },
],
});
console.log(r.updated, r.unchanged, r.failed);
// a website order: the retry key comes from the website order number, so a retry creates no second order
const o = await ladnai("POST", "/orders", {
external_id: "WC-1042",
client: { name: "Олена Кравець", phone: "+380670000001" },
items: [{ sku: "KV-ETH-YRG", quantity: 2 }],
delivery: "Нова Пошта, Київ, відділення №12",
}, "wc-order-1042");
console.log(o.number, o.total, o.currency);
// a new product: if the SKU already exists — 409 already_exists (the existing id is in errors), then update it with a batch
const n = await ladnai("POST", "/products", {
sku: "KV-KEN-AA",
name: "Кенія АА",
unit: "кг",
prices: { retail: "1350.00" },
stock: { kyiv: 20 },
min_qty: 1,
step_qty: 0.5,
}, "new-sku-KV-KEN-AA");
console.log(n.id, n.sku);Changelog
- 2026-11-15
- Products: creation —
POST /v1/products(one product, a unique SKU,409 already_exists); minimum order and order step —min_qty,step_qtyin the product, its group and the batch. Documented the codesread_only,blocked,trial_limit,plan_limit,line_paused(402) andstorage_unavailable(503). Compound emoji in text (the U+200D joiner) stay whole. OpenAPI 1.5.0. - 2026-11-06
- Products: the
descriptionfield (description and specifications, plain text) andalt_names(other names — how customers call the product). OpenAPI 1.4.0. - 2026-10-27
- Webhook
order.confirmed— the client confirmed an order by the link (as is or with changes): the order, what was changed, the comment, the recipient. Select it in Settings → Integrations → Webhooks. OpenAPI 1.3.0. - 2026-10-18
- WooCommerce module: the store module key
ld_shop_…(works only inside the module, see Keys) and the error codesmodule_key,module_only,module_off. - 2026-10-18
- Webhooks: new message, call, order status, stock; HMAC-SHA-256 signature with a timestamp, retries within an hour, Delivery log in the account; events in OpenAPI (
webhooks). - 2026-10-18
- Clients (search by phone, create without duplicates), orders (from a website with
external_id, status, waybill), messages to clients in an existing conversation, the call log and recordings;Idempotency-KeyforPOST; tags dictionary. - 2026-10-18
- First version:
/v1/me, dictionaries, products — list, one, batch update of prices and stock; sandbox; request log in the account.