API Reference
The copyto.design API allows you to integrate HTML to Figma conversion into your applications and workflows.
Overview
Our REST API provides programmatic access to all conversion features available in the web playground, plus additional capabilities for production use.
Base URL
All API requests should be made to:
https://api.copyto.design/v1API Version
The current API version is v1. We maintain backward compatibility and will announce any breaking changes well in advance.
Get Started
Generate Your API Key
To start using the API, you’ll need an API key. Create and manage your keys in the dashboard.
Key Features
RESTful Design
Standard HTTP methods and response codes make integration straightforward:
- POST - Create conversion jobs
JSON API
All requests and responses use JSON format:
Content-Type: application/jsonRate Limiting
API requests are rate-limited based on your plan:
- Free: 100 requests/day
- Pro: 10,000 requests/day
- Enterprise: Custom limits
Rate limit information is included in response headers:
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9995
X-RateLimit-Reset: 1640995200Quick Start Example
Here’s a simple example to convert HTML to Figma:
const response = await fetch('https://api.copyto.design/v1/convert', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
html: '<div style="padding: 20px;"><h1>Hello Figma</h1></div>',
format: 'figma'
})
});
const data = await response.json();
console.log(data.figmaUrl); // URL to paste in FigmaResponse Format
Success Response
{
"success": true,
"data": {
"id": "conv_abc123",
"figmaUrl": "https://...",
"downloadUrl": "https://...",
"metadata": {
"nodes": 5,
"processingTime": 234
}
}
}Error Response
{
"success": false,
"error": {
"code": "INVALID_HTML",
"message": "The provided HTML is not valid",
"details": {}
}
}Error Codes
Common error codes you may encounter:
| Code | Description |
|---|---|
INVALID_HTML | The HTML provided is malformed |
INVALID_URL | The URL provided is not accessible |
RATE_LIMIT_EXCEEDED | Too many requests |
UNAUTHORIZED | Invalid or missing API key |
CONVERSION_FAILED | Conversion process failed |
FILE_TOO_LARGE | Input exceeds size limits |
SDKs and Libraries
We provide official SDKs for popular languages:
JavaScript/TypeScript
npm install @copyto-design/sdkimport { CopyToDesign } from '@copyto-design/sdk';
const client = new CopyToDesign('YOUR_API_KEY');
const result = await client.convert({ html: '<div>...</div>' });cURL
curl -X POST https://api.copyto.design/v1/convert \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"html": "<div>Hello</div>", "format": "figma"}'Security
- Never expose API keys in client-side code
- Use environment variables for credentials
- Rotate API keys regularly
- Monitor API usage for anomalies
Support
For API support:
- Email: [email protected]
- Documentation: docs
Next Steps
- Learn about Authentication
- Explore API Endpoints
- Try the Playground