Skip to content

API Overview

Mandatum provides a comprehensive REST API for programmatic access to all platform features.

Base URL

https://mandatum-api.gavelinivar.com/api/v1

Authentication

Include your API key in the Authorization header:

bash
Authorization: Bearer YOUR_API_KEY

Example:

bash
curl -H "Authorization: Bearer mdt_live_abc123..." \
  https://mandatum-api.gavelinivar.com/api/v1/prompts

Learn more about authentication.

SDKs

Python

bash
pip install mandatum-sdk
python
from mandatum import Mandatum

client = Mandatum(api_key="your-api-key")

TypeScript/JavaScript

Coming Soon

A TypeScript/JavaScript SDK is in development. For now, use the REST API directly.

Request Format

All requests must use Content-Type: application/json:

bash
curl -X POST https://mandatum-api.gavelinivar.com/api/v1/prompts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "test", "template": "Hello {name}"}'

Response Format

All responses are JSON:

json
{
  "data": {
    "id": "prompt_abc123",
    "name": "test",
    "template": "Hello {name}"
  },
  "meta": {
    "request_id": "req_xyz789"
  }
}

Error Handling

Errors follow this format:

json
{
  "error": {
    "type": "validation_error",
    "message": "Invalid prompt template",
    "code": "INVALID_TEMPLATE",
    "details": {
      "field": "template",
      "issue": "Missing required variable: name"
    }
  },
  "meta": {
    "request_id": "req_xyz789"
  }
}

HTTP Status Codes

CodeMeaningDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient permissions
404Not FoundResource doesn't exist
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Error Types

TypeDescription
authentication_errorInvalid API key
authorization_errorInsufficient permissions
validation_errorInvalid request data
not_found_errorResource not found
rate_limit_errorToo many requests
server_errorInternal server error

Pagination

List endpoints support cursor-based pagination:

bash
curl -X GET "https://mandatum-api.gavelinivar.com/api/v1/prompts?limit=20&cursor=abc123" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response includes pagination metadata:

json
{
  "data": [...],
  "pagination": {
    "has_more": true,
    "next_cursor": "xyz789",
    "total": 156
  }
}

Rate Limits

Rate limits vary by plan:

PlanRequests/MinuteRequests/Day
Free601,000
Pro600100,000
EnterpriseCustomCustom

Rate limit headers are included in all responses:

X-RateLimit-Limit: 600
X-RateLimit-Remaining: 583
X-RateLimit-Reset: 1642876800

Idempotency

Use Idempotency-Key header to ensure requests are processed once:

bash
curl -X POST https://mandatum-api.gavelinivar.com/api/v1/prompts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: unique-key-123" \
  -H "Content-Type: application/json" \
  -d '{"name": "test", "template": "Hello"}'

Versioning

The API is versioned via the URL path (/v1). Breaking changes will result in a new version.

Current version: v1

Webhooks

Subscribe to events via webhooks:

python
webhook = client.webhooks.create(
    url="https://your-app.com/webhooks",
    events=["request.completed", "request.failed"]
)

Learn more about webhooks.

API Resources

Example Requests

Create a Prompt

bash
curl -X POST https://mandatum-api.gavelinivar.com/api/v1/prompts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "greeting",
    "template": "Hello {name}!",
    "model": "gpt-4"
  }'

Run a Prompt

bash
curl -X POST https://mandatum-api.gavelinivar.com/api/v1/prompts/greeting/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input_variables": {
      "name": "Alice"
    },
    "metadata": {
      "user_id": "user_123"
    }
  }'

List Logs

bash
curl -X GET "https://mandatum-api.gavelinivar.com/api/v1/logs?limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

Support

Rate Limit Best Practices

  • Cache responses when possible
  • Use exponential backoff on 429 errors
  • Batch requests when available
  • Monitor rate limit headers
  • Upgrade plan if consistently hitting limits