Connect a key

What you need#

  • The gateway address and a product key from the owner. relic has no public address of its own: the owner tells you where it is reachable.
  • At least one scope granted to your key. Without it every list is empty.

Authenticate#

Send the key on every request as Authorization: Bearer <key> or as X-Api-Key: <key>. The key identifies your product, so scopes and the ledger follow it. A missing or wrong key gets 401 unauthorized.

Use it as an MCP server#

The MCP endpoint is POST /mcp (Streamable HTTP, stateless, JSON replies). Register it in an MCP client with your key as the bearer token. The tool list depends on the key: tools of a scope your key does not have are not listed.

First calls over MCP#

  1. list_chats shows every conversation open to your key. find_chat finds one by name, @username or id.
  2. Pass the ref you got as conversation to the other tools. A Telegram ref looks like telegram:<account>:<id>.
  3. get_messages returns the newest messages first. Use around, after, filter, sender or topic to narrow them.

First calls over REST#

curl -s -H "Authorization: Bearer $RELIC_KEY" \
  "$RELIC_URL/v1/conversations?limit=2"
{
  "total": 2,
  "count": 2,
  "truncated": false,
  "conversations": [
    { "ref": "telegram:main:-1001234567890", "name": "Example group", "type": "group", "platform": "telegram" },
    { "ref": "telegram:main:1234567", "name": "Example person", "type": "private", "platform": "telegram" }
  ]
}

Then read one conversation with GET /v1/conversations/<ref>/messages?limit=20. The ref must be URL-encoded.

Check what your key can do#

  • GET /v1/scope returns the scope rows of your key, grouped by access level.
  • GET /v1/usage returns usedToday and the daily cap.
  • GET /v1/adapters returns the login state of each adapter.

More in REST API and Errors and limits.