Skip to main content

Invoke a backend

After deployment, invoke the backend through its AXTL agent slug with an agent API key. Agent API keys are different from platform bearer tokens. Create one before calling a deployed backend:
curl -X POST "$AXTL_API_BASE_URL/v1/agents/{agentId}/api-keys" \
  -H "Authorization: Bearer $AXTL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production"}'
Copy the returned data.key.

Invoke by slug

curl -X POST "$AXTL_API_BASE_URL/v1/invoke/{agentSlug}" \
  -H "Authorization: Bearer $AXTL_AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Classify this support request and suggest a next action."
  }'
AXTL forwards the JSON request body to the generated backend runtime. The generated backend decides the final request and response schema. Successful calls return an invocation envelope:
{
  "data": {
    "status": 200,
    "ok": true,
    "latencyMs": 123,
    "response": {
      "answer": "ok"
    }
  }
}

Common invocation errors

ErrorMeaning
missing_agent_api_keyThe request did not include an agent API key.
malformed_agent_api_keyThe authorization header was not a bearer agent key.
invalid_agent_api_keyThe agent API key was not recognized.
agent_api_key_revokedThe agent API key was revoked.
agent_api_key_scope_mismatchThe key belongs to a different agent.
not_deployedThe agent does not have a live endpoint yet.
invalid_jsonThe request body was not valid JSON.
endpoint_timeoutThe deployed backend timed out.
endpoint_unreachableAXTL could not reach the deployed backend.