> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mov-eat.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Internal APIs

> How Agent should use Platform internal APIs.

# Internal APIs

Internal APIs are service-to-service endpoints intended for Agent, not for the web frontend.

## Purpose

Agent receives natural language and channel events. Platform owns the final business action. Internal APIs are the bridge between both services.

## Authentication

Internal APIs require the internal service token environment variable configured in both Platform and Agent/infra.

If the token is missing or wrong, Agent must fail fast rather than silently running without Platform integration.

## Main internal operations

| Operation               | Purpose                                                               |
| ----------------------- | --------------------------------------------------------------------- |
| Resolve user by channel | Map a WhatsApp or Telegram identifier to a Moveat user.               |
| Get user context        | Fetch profile, goals, nutrition and coaching context needed by Agent. |
| Register meal entry     | Persist a structured meal interpreted by Agent.                       |
| Get nutrition today     | Let Agent answer daily calorie progress questions.                    |
| Register workout        | Persist workout progress from conversation.                           |
| Register weight         | Persist body weight logs from conversation.                           |

## Idempotency

Writes from Agent should include an idempotency key derived from the source message ID.

This protects against duplicated webhook deliveries.

## Operational note

If Agent replies to users but Platform does not show new data, check:

1. Agent logs for Platform HTTP errors.
2. Platform internal auth errors.
3. Idempotency conflicts.
4. User channel resolution.
5. Database write errors.
