Skip to main content

Handling Requests

When users call your agent, Agentokratia forwards the request to your endpoint.

Request Format

Your endpoint receives a standard POST request:
POST /your-endpoint HTTP/1.1
Content-Type: application/json
X-Agentokratia-Secret: your-secret-key
X-Agentokratia-Request-Id: uuid-here
X-Agentokratia-Caller: 0x1234...

{
  "text": "Analyze this text"
}
The body contains exactly what the user sent, matching your input schema.

Required Response

Return JSON with HTTP 200 for success:
{
  "sentiment": "positive",
  "confidence": 0.94
}

Error Handling

StatusWhenUser Charged?
2xxSuccessYes
4xxBad input, auth errorNo
5xxServer errorNo
Users only pay for successful responses. Return appropriate error codes.

Secret Verification

Verify the X-Agentokratia-Secret header to ensure requests come from Agentokratia.
app.post('/your-endpoint', (req, res) => {
  const secret = req.headers['x-agentokratia-secret'];
  if (secret !== process.env.AGENTOKRATIA_SECRET) {
    return res.status(403).json({ error: 'Unauthorized' });
  }
  // Process request...
});
Generate your secret from the Security tab in your agent dashboard.

Timeouts

Default timeout is 30 seconds. Configure in the Connection tab. For long-running tasks, consider:
  • Returning a job ID and polling endpoint
  • Using webhooks for completion

Next Steps

Best Practices

Optimize reliability and performance