Skip to main content

Overview

The Raily API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

Base URL

All API requests are made to:
https://api.raily.ai/v1

Authentication

The Raily API uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard. Include your API key in the Authorization header:
Authorization: Bearer raily_sk_xxxxxxxxxxxxx
Your API key carries significant privileges. Keep it secure and never share it in publicly accessible areas such as GitHub, client-side code, or browser requests.

API Key Types

TypePrefixUse Case
Secret Keyraily_sk_Server-side requests
Public Keyraily_pk_Client-side (read-only)

Request Format

All requests should include:
Content-Type: application/json
Authorization: Bearer raily_sk_xxxxxxxxxxxxx

Example Request

curl https://api.raily.ai/v1/content \
  -H "Authorization: Bearer raily_sk_xxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "externalId": "article-123",
    "title": "My Article",
    "type": "article",
    "source": "https://example.com/article"
  }'

Response Format

All responses are JSON with a consistent structure:

Success Response

{
  "id": "cnt_abc123xyz",
  "object": "content",
  "created": "2024-01-15T10:30:00Z",
  "externalId": "article-123",
  "title": "My Article",
  "type": "article",
  "source": "https://example.com/article"
}

List Response

{
  "object": "list",
  "data": [
    { "id": "cnt_abc123", ... },
    { "id": "cnt_def456", ... }
  ],
  "hasMore": true,
  "totalCount": 150
}

Error Response

{
  "error": {
    "code": "invalid_request",
    "message": "The 'title' field is required",
    "param": "title",
    "type": "validation_error"
  }
}

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn’t exist
409Conflict - Resource already exists
422Unprocessable Entity - Validation error
429Too Many Requests - Rate limit exceeded
500Server Error

Rate Limits

API requests are rate limited based on your plan:
PlanRequests/minuteRequests/day
Starter6010,000
Professional300100,000
EnterpriseCustomCustom
Rate limit information is included in response headers:
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 295
X-RateLimit-Reset: 1705320000
When rate limited, you’ll receive a 429 response:
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Retry after 60 seconds.",
    "retryAfter": 60
  }
}

Pagination

List endpoints support pagination with limit and cursor parameters:
GET /v1/content?limit=20&cursor=cnt_abc123
ParameterDescriptionDefault
limitNumber of items (1-100)20
cursorPagination cursor-

Response

{
  "object": "list",
  "data": [...],
  "hasMore": true,
  "nextCursor": "cnt_xyz789"
}

Pagination Example

async function getAllContent() {
  const allContent = [];
  let cursor = null;

  do {
    const response = await raily.content.list({
      limit: 100,
      cursor
    });

    allContent.push(...response.data);
    cursor = response.hasMore ? response.nextCursor : null;
  } while (cursor);

  return allContent;
}

Filtering

Many list endpoints support filtering:
GET /v1/content?type=article&created[gte]=2024-01-01

Filter Operators

OperatorDescriptionExample
eqEqual (default)type=article
neNot equaltype[ne]=draft
gtGreater thancreated[gt]=2024-01-01
gteGreater or equalrequests[gte]=100
ltLess thancreated[lt]=2024-12-31
lteLess or equalrequests[lte]=1000
inIn arraytype[in]=article,report

Expanding Objects

Some endpoints support expanding related objects:
GET /v1/content/cnt_abc123?expand=policy
{
  "id": "cnt_abc123",
  "title": "My Article",
  "policyId": "pol_xyz789",
  "policy": {
    "id": "pol_xyz789",
    "name": "Premium Policy",
    "rules": [...]
  }
}

Idempotency

For POST requests, you can include an Idempotency-Key header to safely retry requests:
curl https://api.raily.ai/v1/content \
  -H "Authorization: Bearer raily_sk_xxx" \
  -H "Idempotency-Key: unique-request-id-123" \
  -d '{...}'
Idempotency keys expire after 24 hours.

Versioning

The API version is included in the URL path (/v1/). We maintain backwards compatibility within a version. Breaking changes result in a new version. You’ll receive advance notice before deprecating old versions.

SDKs

Official SDKs handle authentication, retries, and error handling:

Quick Reference

Content Endpoints

MethodEndpointDescription
GET/v1/contentList all content
POST/v1/contentCreate content
GET/v1/content/:idGet content
PATCH/v1/content/:idUpdate content
DELETE/v1/content/:idDelete content

Policy Endpoints

MethodEndpointDescription
GET/v1/policiesList policies
POST/v1/policiesCreate policy
PATCH/v1/policies/:idUpdate policy
DELETE/v1/policies/:idDelete policy

Access Endpoints

MethodEndpointDescription
POST/v1/access/checkCheck access

Analytics Endpoints

MethodEndpointDescription
GET/v1/analytics/usageUsage analytics
GET/v1/analytics/revenueRevenue analytics

Next Steps