Part of the Determesh series.

What

The Determesh API does not return answers. A company’s backend submits a user’s message and gets 202 Accepted with a thread ID. The reply arrives later, as a signed webhook to the company’s endpoint. If the webhook cannot be delivered, the reply is still there to pull through the thread API.

Why

The work does not fit in a request

A simple question takes a few seconds: the orchestrator searches, asks a resource, the reply is written and scored. A request like “send this month’s statements to my team” can take minutes, and sends progress along the way: “found 40 people, sending now”, “38 sent, 2 failed”. Some work waits on a person, such as an approval that may come tomorrow.

None of that fits in an HTTP request. A synchronous API would need a timeout, and every timeout would be a reply the user never gets.

One request can have many replies

An acknowledgement, three progress updates and a final report are five messages for one submit. A notice that an email bounced may arrive half an hour after the reply that said it was sent. The natural shape for that is a stream of events to the customer, not a response body.

Every channel is already like this

Telegram and email are asynchronous by nature. The user writes, and the reply comes when it comes. Making the API work the same way means one engine behind every channel, not a fast path for the API and a slow path for the rest.

How

Submitting

POST /v1/messages
X-Determesh-Key: dmk_...
X-Determesh-Timestamp: 1767225600
X-Determesh-Nonce: 7f3c...
X-Determesh-Signature: 9a1b...

{ "userId": "customer-123", "text": "What is my order status?" }
202 { "threadId": "...", "chatId": "..." }

No threadId in the request starts a new thread. Sending one continues it. The request is signed with HMAC, and the details of that signature have their own post.

The userId is the company’s own ID for its user. The API is called by the company’s backend with its key, so that ID is trusted as already authenticated. The company’s backend is the only thing that can send it.

Delivering

Every message the user should receive on an API thread, replies and progress updates alike, is queued for delivery in the same database transaction that stores it. If the transaction rolls back, there is nothing to deliver. If it commits, the delivery exists.

The payload is a small, documented envelope: the event, the thread, the company’s user ID, the message, and a per-thread sequence number that counts 1, 2, 3. It is signed the same way as incoming requests, with a secret that belongs to the webhook, so the company can verify it came from us. A delivery ID in a header lets the customer ignore a repeat.

Success is a 2xx within a few seconds. Redirects are not followed.

When the endpoint is down

Retries use exponential backoff, for days, with a cap on the gap between tries. The interesting part is what happens across many deliveries to the same endpoint.

Shared state. When a delivery finds the endpoint down, every other payload for that endpoint waits too, instead of each one hammering a dead server on its own schedule.

Order. Payloads are delivered oldest first. A reply must not arrive before the acknowledgement it follows.

One probe. Whenever any waiting payload’s backoff comes due, the oldest pending payload is the one actually sent. If it gets through, the endpoint is marked up, and everything waiting is released straight away, in order.

That combination keeps both rules at once: each payload keeps its own retry schedule, and order is by creation time. It also means a customer whose endpoint was down for an hour gets every message, in order, within moments of coming back.

A dropped delivery is never a lost reply

After days of retries, a delivery is dropped. The reply is not. It is in the thread, and the thread API returns every message the user should see, oldest first, paged by that same sequence number:

GET /v1/threads/{threadId}/messages?afterSeq=12

A customer who missed deliveries can always catch up. The webhook is the fast path. The thread is the record.

Per key, not per company

A company can hold several API keys, one per app or integration, and each key has its own webhook, its own secret and its own list of events. A reply goes to the key its thread came in on. Each key is its own endpoint for the backoff rules above, so one integration with a broken endpoint does not hold back another.

Besides replies, a key can subscribe to events such as an email sent, failed or bounced, and a document upload finishing.

What the API never returns

Internal work. The thread API shows the user’s messages and the replies, never the orchestrator’s decisions, the resource calls or the evaluator’s scores. Those exist, and the company’s admin can read them in the panel. They are not part of what the company’s own users receive, because they were never written for them.

That closes the philosophy part of the series. From the next post on, it is how Determesh is built, starting with the engine that runs every thread.


Previous: Need to Know: Denied by Default

Next: Threads as Postgres Rows, With No Queue Server