REST and other languages
Call the ReQlo HTTP API from any language: cURL, Go, Java, .NET, Ruby and PHP, failing closed.
Call the implemented API over HTTPS from any language. Use this page if your language has no official SDK, or if you want full control.
Authorize from your stack
The same request works from TypeScript, Python or cURL using direct HTTP. Choose a tab and copy the example.
Authorize an agent action
Proposed APIcurl --fail-with-body -X POST "$REQLO_BASE_URL/v1/authorize" \
--max-time 3 \
-H "Authorization: Bearer $REQLO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent": { "id": "agt_assistant_42" },
"subject": { "id": "usr_94", "kind": "user" },
"action": "documents.read",
"resource": {
"type": "document", "id": "doc_831",
"attributes": { "owner_id": "usr_94" }
},
"context": { "document_classification": "internal" }
}'Direct HTTP, no SDK required. Set REQLO_BASE_URL to the server origin and keep REQLO_API_KEY on your server. Execute the action only after an explicit allow.
Rules every HTTP client must follow
- Only
"decision": "allow"permits execution. Check thedecisionfield, not just the HTTP status. - Any non-2xx response, timeout or network error means don't execute.
- Set a timeout (we recommend 1–3 seconds).
- Retry only 429 and 5xx, with exponential backoff and jitter, honoring
Retry-After. - Don't automatically replay a state-changing request after an ambiguous timeout; check its outcome first.
API key creation and rolling require an
Idempotency-Key; reuse it when retrying. - Keep the key server-side and out of logs.
- Ignore unknown response fields and treat unknown reason codes as deny.
Other languages
There are no official SDKs for these languages yet. These examples call the HTTP API with each language's standard HTTP client and follow the fail-closed rules above.
package reqlo
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"os"
"time"
)
type Ref struct {
ID string `json:"id"`
Kind string `json:"kind,omitempty"`
}
type Resource struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes map[string]any `json:"attributes,omitempty"`
}
type AuthorizeRequest struct {
Agent Ref `json:"agent"`
Subject *Ref `json:"subject,omitempty"`
Action string `json:"action"`
Resource Resource `json:"resource"`
Context map[string]any `json:"context,omitempty"`
}
type Decision struct {
ID string `json:"id"`
Decision string `json:"decision"`
ReasonCode string `json:"reason_code"`
}
var ErrDenied = errors.New("reqlo: action not allowed")
var client = &http.Client{Timeout: 3 * time.Second}
// Enforce returns nil only when ReQlo explicitly allows the action.
func Enforce(ctx context.Context, req AuthorizeRequest) (*Decision, error) {
body, err := json.Marshal(req)
if err != nil {
return nil, err
}
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.reqlo.io/v1/authorize", bytes.NewReader(body))
if err != nil {
return nil, err
}
httpReq.Header.Set("Authorization", "Bearer "+os.Getenv("REQLO_API_KEY"))
httpReq.Header.Set("Content-Type", "application/json")
resp, err := client.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("reqlo: request failed: %w", err) // fail closed
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("reqlo: HTTP %d, request %s", resp.StatusCode, resp.Header.Get("Reqlo-Request-Id"))
}
var d Decision
if err := json.NewDecoder(resp.Body).Decode(&d); err != nil {
return nil, err
}
if d.Decision != "allow" {
return &d, ErrDenied
}
return &d, nil
}if _, err := reqlo.Enforce(ctx, req); err != nil {
return refuse(err) // denied or failed: do not execute
}
return readDocument(doc)The full contract is the API reference.
Something wrong or unclear? Report an issue with this page.