{
    "id": "canva",
    "name": "Canva",
    "category": "Design",
    "description": "Create, autofill, export, and manage Canva designs, brand templates, and assets via the Canva Connect API.",
    "baseUrl": "https://api.canva.com/rest/v1",
    "authStrategy": "oauth2",
    "authKey": "Authorization",
    "authorizationUrl": "https://www.canva.com/api/oauth/authorize",
    "tokenUrl": "https://api.canva.com/rest/v1/oauth/token",
    "usePkce": true,
    "scopeSeparator": " ",
    "scopes": [
        "profile:read",
        "design:meta:read",
        "design:content:read",
        "design:content:write",
        "asset:read",
        "asset:write",
        "brandtemplate:meta:read",
        "brandtemplate:content:read",
        "folder:read"
    ],
    "fields": [
        { "name": "clientId", "label": "Client ID", "type": "text" },
        { "name": "clientSecret", "label": "Client Secret", "type": "password" }
    ],
    "hints": [
        "REST API. Auth is OAuth 2.0 with PKCE (S256) — required by Canva for ALL clients (public AND confidential). The proxy handles the PKCE handshake automatically.",
        "User profile: GET /users/me/profile — returns the authenticated user's display_name and user_id. Use this as a connection smoke test.",
        "List designs: GET /designs?query=&continuation=&ownership=any&sort_by=relevance",
        "  Cursor pagination via `continuation` (opaque string). Pass back the value from the previous response's `continuation` field to fetch the next page.",
        "Get a design: GET /designs/{designId} — returns title, urls (edit_url, view_url), thumbnail, page_count.",
        "Create a blank design: POST /designs  Body: { design_type: { type: \"preset\", name: \"presentation\" } }   Other preset names: doc, whiteboard, presentation, instagrampost, instagramstory, facebookcover, etc. Or use { type: \"custom\", width, height } for custom dimensions.",
        "Export a design (PNG, PDF, JPG, MP4, GIF, PPTX) — async two-step:",
        "  1) POST /exports  Body: { design_id, format: { type: \"png\" } }   Response: { job: { id, status: \"in_progress\" } }",
        "  2) Poll GET /exports/{jobId} until status === \"success\". Response then includes `urls` (signed download URLs, expire after a short window — fetch immediately).",
        "  Format options: png (no compression flag), jpg (quality 1-100), pdf (size, pages), mp4 (quality), gif, pptx.",
        "Asset upload — binary only, no URL pass-through. Two-step async:",
        "  1) POST /asset-uploads  Headers: Content-Type: application/octet-stream, Asset-Upload-Metadata: <base64url JSON {name_base64, tags?}>   Body: raw bytes.",
        "  2) Poll GET /asset-uploads/{jobId} until status === \"success\". Response then includes asset.id (use in autofill / design references).",
        "  Pexels URLs cannot be passed directly — fetch the image, then upload the bytes here. Max ~25MB per asset.",
        "List brand templates: GET /brand-templates?query=&continuation=  Returns templates the user has access to (Canva Enterprise required for full brand template access).",
        "Get template dataset (autofill schema): GET /brand-templates/{brandTemplateId}/dataset   Returns the named text fields and image placeholders the template accepts.",
        "Autofill a brand template — async two-step (very high-value for programmatic design generation):",
        "  1) POST /autofills  Body: { brand_template_id, data: { <field_name>: { type: \"text\" | \"image\" | \"chart\", text?: \"...\", asset_id?: \"...\" } } }   Response: { job: { id, status: \"in_progress\" } }",
        "  2) Poll GET /autofills/{jobId} until status === \"success\". Response includes design_id of the new design — then fetch via /designs/{designId} for edit_url/thumbnail or export it.",
        "  Image fields require an asset_id from a prior /asset-uploads — you cannot pass a URL.",
        "Comments: GET/POST /designs/{designId}/comments and /designs/{designId}/comments/{commentId}/replies (requires comment:read / comment:write scopes — not in default scope list above; add if needed).",
        "Folders: GET /folders/{folderId}, GET /folders/{folderId}/items?continuation=  — list designs/templates within a folder.",
        "Async job pattern (used by exports, asset uploads, autofills): poll the GET endpoint with a small backoff (start 500ms, cap ~5s). Status values: in_progress, success, failed. On failed the response includes an `error` object with `code` and `message`.",
        "Error shape: { code: \"<machine_code>\", message: \"...\" } with appropriate HTTP status (400/401/403/404/429/5xx). Common codes: invalid_request, unauthorized, forbidden, not_found, rate_limit_exceeded, internal_error.",
        "Rate limits: per-token request budgets. On 429, honor the Retry-After response header (seconds).",
        "Refresh tokens: Canva rotates refresh tokens — every refresh returns a new refresh_token and invalidates the old one. The proxy stores the latest automatically; do not cache refresh tokens client-side.",
        "IMPORTANT: Do NOT include access_token in body or query params — the proxy attaches the Authorization: Bearer header automatically."
    ],
    "onboarding": {
        "url": "https://www.canva.com/developers/",
        "steps": [
            "Sign in to Canva and go to canva.com/developers",
            "Create a new integration (Connect API) and choose 'Public' or 'Team' depending on who will use it",
            "Add the redirect URI shown in Synthos (typically http://localhost:<port>/api/connectors/callback) to the integration's allowed redirect URIs",
            "Enable the scopes the integration needs: profile:read, design:meta:read, design:content:read, design:content:write, asset:read, asset:write, brandtemplate:meta:read, brandtemplate:content:read, folder:read",
            "Copy the Client ID and Client Secret into the fields below"
        ]
    }
}
