REST API Reference

Complete reference for the ResolveDB REST API.

Base URL

All API requests should be made to:

https://api.resolvedb.io/api/v1

Authentication

The ResolveDB API uses Bearer token authentication. Include your API key in the Authorization header of every request.

Bearer Token

Authorization: Bearer YOUR_API_KEY

Getting API Keys

Generate API keys from the API Keys section of your dashboard. Each key has configurable permissions and can be revoked at any time.

Important: API key tokens are only displayed once upon creation. Store them securely. If you lose a key, you must generate a new one.

Example Request

curl https://api.resolvedb.io/api/v1/me \
  -H "Authorization: Bearer rdb_live_abc123..."

Records

Records are the core data objects in ResolveDB. Each record is addressable via DNS and contains Base64-encoded data.

List Records

GET /records

List all records for the authenticated user. Supports filtering by namespace and resource.

Query Parameters:

ParameterTypeDescription
namespacestringFilter by namespace
resourcestringFilter by resource name
pageintegerPage number (default: 1)
per_pageintegerResults per page (default: 25, max: 100)

Example Request:

curl "https://api.resolvedb.io/api/v1/records?namespace=myapp&per_page=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "records": [
    {
      "id": "rec_abc123",
      "key": "config.myapp.v1",
      "data": "eyJkYXRhYmFzZSI6InBvc3RncmVzIn0=",
      "namespace": "myapp",
      "resource": "config",
      "version": "v1",
      "ttl": 3600,
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 10,
    "total": 1,
    "total_pages": 1
  }
}

Get Record

GET /records/:id

Retrieve a single record by ID.

Path Parameters:

ParameterTypeDescription
idstringRecord ID (e.g., rec_abc123)

Example Request:

curl https://api.resolvedb.io/api/v1/records/rec_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "record": {
    "id": "rec_abc123",
    "key": "config.myapp.v1",
    "data": "eyJkYXRhYmFzZSI6InBvc3RncmVzIn0=",
    "namespace": "myapp",
    "resource": "config",
    "version": "v1",
    "ttl": 3600,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Create Record

POST /records

Create a new record. The data field must be Base64 encoded.

Request Body:

FieldTypeRequiredDescription
record.keystringYesDNS key (format: resource.namespace.version)
record.datastringYesBase64 encoded data
record.ttlintegerNoCache TTL in seconds (default: 3600)

Example Request:

curl -X POST https://api.resolvedb.io/api/v1/records \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "record": {
      "key": "config.myapp.v1",
      "data": "eyJkYXRhYmFzZSI6InBvc3RncmVzIn0=",
      "ttl": 3600
    }
  }'

Response:

{
  "record": {
    "id": "rec_abc123",
    "key": "config.myapp.v1",
    "data": "eyJkYXRhYmFzZSI6InBvc3RncmVzIn0=",
    "namespace": "myapp",
    "resource": "config",
    "version": "v1",
    "ttl": 3600,
    "dns_query": "get.config.myapp.v1.resolvedb.net",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Update Record

PATCH /records/:id

Update an existing record. Only include fields you want to change.

Path Parameters:

ParameterTypeDescription
idstringRecord ID

Request Body:

FieldTypeDescription
record.datastringNew Base64 encoded data
record.ttlintegerNew cache TTL in seconds

Example Request:

curl -X PATCH https://api.resolvedb.io/api/v1/records/rec_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "record": {
      "data": "eyJkYXRhYmFzZSI6Im15c3FsIn0=",
      "ttl": 7200
    }
  }'

Response:

{
  "record": {
    "id": "rec_abc123",
    "key": "config.myapp.v1",
    "data": "eyJkYXRhYmFzZSI6Im15c3FsIn0=",
    "namespace": "myapp",
    "resource": "config",
    "version": "v1",
    "ttl": 7200,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T12:45:00Z"
  }
}

Delete Record

DELETE /records/:id

Delete a record. This action is permanent.

Path Parameters:

ParameterTypeDescription
idstringRecord ID

Example Request:

curl -X DELETE https://api.resolvedb.io/api/v1/records/rec_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

Returns HTTP 204 No Content on success.


API Keys

Manage API keys for programmatic access to the ResolveDB API.

List API Keys

GET /api_keys

List all API keys for the authenticated user. Note: The actual token values are not returned for security reasons.

Example Request:

curl https://api.resolvedb.io/api/v1/api_keys \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "api_keys": [
    {
      "id": "key_xyz789",
      "name": "Production API Key",
      "prefix": "rdb_live_abc",
      "scopes": ["read", "write"],
      "last_used_at": "2024-01-15T09:00:00Z",
      "expires_at": null,
      "created_at": "2024-01-01T00:00:00Z"
    },
    {
      "id": "key_def456",
      "name": "CI/CD Pipeline",
      "prefix": "rdb_live_def",
      "scopes": ["read"],
      "last_used_at": "2024-01-14T18:30:00Z",
      "expires_at": "2024-12-31T23:59:59Z",
      "created_at": "2024-01-10T12:00:00Z"
    }
  ]
}

Create API Key

POST /api_keys

Create a new API key. The full token is only returned once in this response - store it securely.

Request Body:

FieldTypeRequiredDescription
api_key.namestringYesDescriptive name for the key
api_key.scopesarrayNoPermissions: read, write (default: both)
api_key.expires_atstringNoISO 8601 expiration date

Example Request:

curl -X POST https://api.resolvedb.io/api/v1/api_keys \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "name": "Production API Key",
      "scopes": ["read", "write"],
      "expires_at": "2025-12-31T23:59:59Z"
    }
  }'

Response:

Important: The token field is only returned once. Store it immediately in a secure location.

{
  "api_key": {
    "id": "key_xyz789",
    "name": "Production API Key",
    "token": "rdb_live_abc123def456ghi789...",
    "prefix": "rdb_live_abc",
    "scopes": ["read", "write"],
    "expires_at": "2025-12-31T23:59:59Z",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Revoke API Key

DELETE /api_keys/:id

Revoke an API key. This action is immediate and permanent. Any requests using this key will be rejected.

Path Parameters:

ParameterTypeDescription
idstringAPI key ID

Example Request:

curl -X DELETE https://api.resolvedb.io/api/v1/api_keys/key_xyz789 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

Returns HTTP 204 No Content on success.


Account

Endpoints for managing your account and retrieving profile information.

Get Current User

GET /me

Get the current authenticated user's profile information.

Example Request:

curl https://api.resolvedb.io/api/v1/me \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "user": {
    "id": "usr_abc123",
    "email": "developer@example.com",
    "name": "Jane Developer",
    "plan": "pro",
    "records_count": 42,
    "records_limit": 10000,
    "created_at": "2024-01-01T00:00:00Z"
  }
}

Error Handling

The API uses conventional HTTP response codes to indicate success or failure of requests. Errors include a JSON body with details.

Error Response Format

{
  "error": {
    "code": "validation_error",
    "message": "The request body contains invalid data",
    "details": [
      {
        "field": "record.key",
        "message": "is required"
      }
    ]
  }
}

HTTP Status Codes

CodeNameDescription
200OKRequest succeeded
201CreatedResource created successfully
204No ContentRequest succeeded, no body returned
400Bad RequestInvalid request body or parameters
401UnauthorizedMissing or invalid API key
403ForbiddenAPI key lacks required scope
404Not FoundResource does not exist
422Unprocessable EntityValidation error
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error (contact support)

Error Codes

CodeDescription
authentication_errorInvalid or missing API key
authorization_errorAPI key lacks required permissions
validation_errorRequest body failed validation
not_foundRequested resource does not exist
rate_limit_exceededToo many requests
quota_exceededAccount record limit reached
server_errorInternal server error

DNS Error Code Mapping

When querying records via DNS, errors are returned as UQRP status codes. See UQRP Protocol - Error Codes for the complete mapping (E001-E017).

API ErrorDNS StatusDNS Error Code
authentication_errorauthE006, E007, E008
authorization_errorforbiddenE009
validation_errorinvalidE001, E002, E003
not_foundnotfoundE004, E005
rate_limit_exceededratelimitE010
server_errorerrorE012

Rate Limits

API requests are rate limited to ensure fair usage and system stability. Limits vary by plan and endpoint type.

Rate Limit Headers

Every response includes headers indicating your current rate limit status:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets

Limits by Plan

PlanRequests/minRecords
Free60100
Pro60010,000
EnterpriseCustomUnlimited

Handling Rate Limits

When rate limited, the API returns HTTP 429. Implement exponential backoff:

// Example: Exponential backoff in JavaScript
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const response = await fetch(url, options);

    if (response.status === 429) {
      const resetTime = response.headers.get('X-RateLimit-Reset');
      const waitMs = (resetTime * 1000) - Date.now();
      await new Promise(r => setTimeout(r, Math.max(waitMs, 1000 * (i + 1))));
      continue;
    }

    return response;
  }
  throw new Error('Rate limit exceeded after retries');
}

Next Steps