RP
RolePlay Docs
Developer Documentation

RolePlay API

Build AI character integrations with our simple, powerful API. Create, manage, and automate your character catalog.

Overview

The RolePlay Character API provides programmatic access to create, manage, and automate AI characters.

RESTful API

Simple HTTP endpoints with JSON responses for easy integration.

Secure by Default

API key authentication with account-scoped permissions.

Fast & Reliable

Optimized for batch operations and production workloads.

Base URL
https://api.roleplaychat.ai
Authentication
Bearer Token
Response Format
JSON

Key Features

  • Resource ownership tied to API key owner account
  • JSON responses optimized for queue/job processing
  • Explicit visibility and share behavior controls
  • Partial updates supported for efficient mutations

Quickstart

Get started with the RolePlay API in under 5 minutes.

1

Get your API key

Generate an API key from the API settings page. Store it securely in your environment.

2

Make your first request

Use the code examples below to create your first character.

# Create your first character
curl -X POST "https://api.roleplaychat.ai/apiCreateCharacter" \
  -H "Authorization: Bearer $ROLEPLAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Luna",
    "subtitle": "A helpful AI assistant",
    "description": "Warm, concise, and useful in every reply.",
    "definition": "You are Luna, a friendly assistant.",
    "greetings": ["Hello! How can I help you today?"]
  }'
import requests

api_key = "rp_your_api_key"
endpoint = "https://api.roleplaychat.ai/apiCreateCharacter"

response = requests.post(
    endpoint,
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "name": "Luna",
        "subtitle": "A helpful AI assistant",
        "description": "Warm, concise, and useful.",
        "definition": "You are Luna, a friendly assistant.",
        "greetings": ["Hello! How can I help you today?"]
    },
    timeout=30
)

print(response.json())
const response = await fetch('https://api.roleplaychat.ai/apiCreateCharacter', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Luna',
    subtitle: 'A helpful AI assistant',
    description: 'Warm, concise, and useful.',
    definition: 'You are Luna, a friendly assistant.',
    greetings: ['Hello! How can I help you today?']
  })
});

const data = await response.json();
console.log(data);
Important: Never expose your API key in client-side code. Always make API calls from your backend server.

Authentication

Secure your API requests with Bearer token authentication.

All API requests require authentication using a Bearer token in the Authorization header.

Authorization Header
Authorization: Bearer rp_your_api_key_here

Best Practices

  • Use separate keys for each environment (dev, staging, prod)
  • Rotate keys periodically and during incident response
  • Never embed keys in client-side code or public repos
  • Store keys in environment variables or secret managers
Security Notice: If you believe your API key has been compromised, revoke it immediately from the API settings page.

Pricing

Simple, transparent pricing for developers.

Creator

Free

Perfect for getting started and personal projects.

  • Full API access
  • Standard rate limits
  • Community support

Character Model

Understand the structure of character data.

Field
Type
Required
Description
name
string
Required
Display name of the character
definition
string
Required
Instructions that define character behavior
greetings
string[]
Required
Opening messages the character can send
subtitle
string
Optional
Short tagline for discovery
description
string
Optional
Detailed description
visibility
enum
Optional
private | unlisted | public
tags
string[]
Optional
Categorization tags for discovery
avatar
string
Optional
Base64-encoded image (PNG/JPEG, 1024x1024, max 2MB)

Visibility States

Control who can discover and access your characters.

Private

Only visible to you. Use for drafts and personal characters.

Unlisted

Accessible via direct link, but not shown in public feeds.

Public

Visible to everyone. Shown in discovery and search results.

Error Handling

Handle API errors gracefully in your integration.

Status
Meaning
Action
200
Success
Request completed successfully
400
Bad Request
Check request payload format
401
Unauthorized
Verify API key is valid
403
Forbidden
Check resource permissions
429
Rate Limited
Wait and retry with backoff
500
Server Error
Retry with exponential backoff

Retry Strategy

// Recommended retry delays with jitter
delays: [1s, 2s, 4s, 8s]
max_retries: 4
// Never retry: 400, 401, 403

Rate Limits

Understand and work within API rate limits.

Rate limits protect the API from abuse and ensure fair usage. Limits vary by plan and endpoint.

Tip: Use bounded worker pools and implement backpressure for bulk operations.

Best Practices

  • Use queueing for batch operations
  • Monitor 429 response rates
  • Implement exponential backoff
  • Persist failed requests for replay

API Endpoints

Complete reference for all available endpoints.

POST /apiCreateCharacter

Create a new character with the specified attributes.

Request Body

{
  "name": "Luna",
  "subtitle": "A helpful AI assistant",
  "definition": "You are Luna...",
  "greetings": ["Hello!"],
  "visibility": "private"
}
GET /apiListCharacters

List all characters owned by the authenticated account.

PATCH /apiUpdateCharacter

Update an existing character. Supports partial updates.

Request Body

{
  "characterId": "char_abc123",
  "visibility": "public"
}
DELETE /apiDeleteCharacter

Permanently delete a character by ID.

Request Body

{
  "characterId": "char_abc123"
}

Code Examples

Production-ready code samples in multiple languages.

Create a Character

curl -X POST "https://api.roleplaychat.ai/apiCreateCharacter" \
  -H "Authorization: Bearer $ROLEPLAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Nora",
    "subtitle": "Cyberpunk fixer",
    "definition": "Stay in-character and concise.",
    "greetings": ["Need a job done right?"],
    "visibility": "unlisted"
  }'
import requests

api_key = "rp_your_key_here"
endpoint = "https://api.roleplaychat.ai/apiCreateCharacter"

payload = {
    "name": "Nora",
    "subtitle": "Cyberpunk fixer",
    "definition": "Stay in-character and concise.",
    "greetings": ["Need a job done right?"],
    "visibility": "unlisted",
}

response = requests.post(
    endpoint,
    headers={"Authorization": f"Bearer {api_key}"},
    json=payload,
    timeout=30,
)
print(response.json())
const response = await fetch('https://api.roleplaychat.ai/apiCreateCharacter', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Nora',
    subtitle: 'Cyberpunk fixer',
    definition: 'Stay in-character and concise.',
    greetings: ['Need a job done right?'],
    visibility: 'unlisted'
  })
});

const data = await response.json();
console.log(data);

List Characters

curl -X GET "https://api.roleplaychat.ai/apiListCharacters" \
  -H "Authorization: Bearer $ROLEPLAY_API_KEY"
response = requests.get(
    "https://api.roleplaychat.ai/apiListCharacters",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
print(response.json())

Security

Best practices for securing your API integration.

Security First: Assume key compromise is eventually possible. Design with rapid revocation and minimal privilege propagation.

Key Management

  • Keep API keys server-side only
  • Rotate keys on a regular schedule
  • Revoke compromised keys immediately
  • Use separate keys for each environment

Monitoring

  • Apply secret scanning in CI and source control
  • Alert on unusual API traffic patterns
  • Log API calls with request metadata for audit

Changelog

Recent updates and changes to the API.

Latest v1.2

Share IDs & URLs

Added share IDs and share URLs to character outputs for easier distribution.

v1.1

Expanded Update Payload

Enhanced update payload support with improved validation behavior.

v1.0

Initial Release

Launch of create, list, update, and delete API endpoints.

Frequently Asked Questions

Common questions about the RolePlay API.

Why doesn't my private character link work for others?

Private visibility blocks non-owner reads by design. Change the character's visibility to unlisted or public to allow access.

Can I publish a character after creating it as private?

Yes! Use the update endpoint to change the visibility to public or unlisted at any time.

Should I call APIs directly from browser apps?

No. Always use your backend as a trusted proxy so API keys are never exposed to users. Client-side API calls expose your key and violate security best practices.

How should I migrate thousands of characters?

Use queue workers with batched retries and checkpointed progress. Avoid unbounded parallel writes. Start with a small batch to test, then gradually increase throughput.

What happens if I exceed rate limits?

You'll receive a 429 response. Implement exponential backoff and queue pending requests. For sustained high volume, contact us about enterprise limits.