API Endpoints
Complete reference for all copyto.design API endpoints.
Need an API Key?
All endpoints require authentication. Create your API key to start making requests.
Create API Key →
Convert HTML to Figma
Convert HTML code or a URL to Figma format.
Endpoint
POST /v1/convertRequest Body
{
"html": "<div>Your HTML here</div>",
"url": "https://example.com",
"format": "figma",
"options": {
"viewport": {
"width": 1440,
"height": 900
},
"waitForSelector": ".content",
"screenshot": false
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
html | string | conditional | HTML code to convert (required if url not provided) |
url | string | conditional | URL to fetch and convert (required if html not provided) |
format | string | optional | Output format: figma (default), fig |
options | object | optional | Additional conversion options |
Options
| Option | Type | Default | Description |
|---|---|---|---|
viewport.width | number | 1440 | Viewport width for URL conversion |
viewport.height | number | 900 | Viewport height for URL conversion |
waitForSelector | string | null | CSS selector to wait for before conversion |
screenshot | boolean | false | Include screenshot in response |
Response
{
"success": true,
"data": {
"id": "conv_abc123",
"figmaUrl": "https://www.figma.com/file/...",
"downloadUrl": "https://cdn.copyto.design/files/conv_abc123.fig",
"screenshot": "https://cdn.copyto.design/screenshots/conv_abc123.png",
"metadata": {
"nodes": 42,
"layers": 15,
"processingTime": 234,
"dimensions": {
"width": 1440,
"height": 900
}
}
}
}Example: Convert HTML
const response = await fetch('https://api.copyto.design/v1/convert', {
method: 'POST',
headers: {
Authorization: 'Bearer ct_sk_abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
html: `
<div style="padding: 40px; background: #f9fafb; border-radius: 8px;">
<h1 style="margin: 0 0 16px; font-size: 32px; color: #111827;">
Welcome to copyto.design
</h1>
<p style="margin: 0; color: #6b7280; font-size: 16px;">
Convert HTML to Figma instantly
</p>
</div>
`,
format: 'figma',
}),
});
const data = await response.json();
console.log('Figma URL:', data.data.figmaUrl);
console.log('Download:', data.data.downloadUrl);Example: Convert URL
const response = await fetch('https://api.copyto.design/v1/convert', {
method: 'POST',
headers: {
Authorization: 'Bearer ct_sk_abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://tailwindcss.com',
options: {
viewport: {
width: 1920,
height: 1080,
},
waitForSelector: '.hero',
},
}),
});
const data = await response.json();Example: Python
import requests
response = requests.post(
'https://api.copyto.design/v1/convert',
headers={
'Authorization': 'Bearer ct_sk_abc123...',
'Content-Type': 'application/json'
},
json={
'html': '<div><h1>Hello Figma</h1></div>',
'format': 'figma'
}
)
data = response.json()
print('Figma URL:', data['data']['figmaUrl'])Example: cURL
curl -X POST https://api.copyto.design/v1/convert \
-H "Authorization: Bearer ct_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"html": "<div><h1>Hello Figma</h1></div>",
"format": "figma"
}'Error Handling
All endpoints return consistent error responses:
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error message",
"details": {}
}
}Common Error Codes
| Code | Status | Description |
|---|---|---|
INVALID_HTML | 400 | HTML is malformed |
INVALID_URL | 400 | URL is not accessible |
FILE_TOO_LARGE | 400 | Input exceeds size limits |
UNAUTHORIZED | 401 | Invalid or missing API key |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
CONVERSION_FAILED | 500 | Conversion process failed |
NOT_FOUND | 404 | Resource not found |
Next Steps
- Review Authentication details
- Try the Playground for testing
- Check pricing for API limits