API Documentation

Everything you need to convert files programmatically with the FileSwitch API.

Every example below uses Authorization: Bearer fc_YOUR_API_KEY and follows the selected language everywhere on this page.

Getting Started

A single REST API to convert HTML, images, JSON, and XML files.

The FileSwitch API converts files between supported formats. Upload a file as multipart/form-data, and the API returns a Conversion object with a temporary download URL. Every request goes to a versioned base URL:

Base URLbash
https://api.fileswitch.co/api/v1

Two kinds of credentials can authenticate requests: API keys for programmatic access to the conversion API and JWT access tokens for account endpoints (login, billing, history, API key management). API keys are available on paid plans and inherit the same rate limits, concurrency, and credit rules as your account.

Quick start

  1. Create a free account and upgrade to a paid plan.
  2. Create an API key in the Integrations tab.
  3. Make your first conversion:
First conversioncURL
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-pdf \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@report.html"

Authentication

API keys for programmatic access, JWT access tokens for account endpoints.

API keys

The recommended way to authenticate server-side conversions. Keys start with fc_ and are sent as a Bearer token:

Authorization headerhttp
Authorization: Bearer fc_ab12cd34ef56...
  • Creating API keys requires a paid plan (Starter, Pro, or Scale).
  • The full key is shown only once at creation; it is stored as a one-way hash.
  • Revoking a key immediately invalidates it.
  • Keys are scoped to your account and cannot be used to access other accounts' data.
  • Requests authenticated with an API key are subject to your plan's rate limits, concurrent job limit, and credit costs — identical to using the web app.

JWT access tokens

Registering or logging in returns an accessToken and a refreshToken. Send the access token as a Bearer token on every authenticated request:

Authorization headerhttp
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
  • Get a token pair via POST /auth/login with your email and password (or register via POST /auth/register).
  • Access tokens expire after 15 minutes.
  • When the access token expires (HTTP 401), exchange the refresh token via POST /auth/refresh for a new pair.
  • Refresh tokens are single-use, expire after 7 days, and are revoked on logout.

Which endpoints need what

  • Public: /converter/formats, guest quota, and auth routes.
  • Either JWT or API key: conversion endpoints (guests may omit auth entirely), and file downloads.
  • JWT required: conversion history, stats, and API key management.

Content Types & Conventions

How requests are encoded and how responses are shaped.

JSON bodies use application/json. File uploads use multipart/form-data with a single file field plus optional option fields. File downloads are returned as raw binary with a Content-Type matching the output format.

Success envelope

Successful responsejson
{
  "success": true,
  "message": "Conversion completed",
  "data": { ... }
}

Paginated endpoints add a meta object with page, limit, total, and totalPages.

Error envelope

Error responsejson
{
  "success": false,
  "message": "File size exceeds the 10MB limit",
  "error": "FILE_TOO_LARGE",
  "details": { ... }
}

Every error returns a machine-readable error code. See the Response Codes reference for the full list. When a request is rate-limited, the response includes a Retry-After header (in seconds).

Conversions

Upload a file, get a converted file back with a download URL.

Each conversion has its own endpoint (POST /converter/:slug) so it can accept conversion-specific options alongside the file — for example header and footer text on an HTML-to-PDF job. Upload a single file plus any option fields; every option is optional and defaults when omitted.

Example request (HTML to PDF)cURL
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-pdf \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.html" \
  -F "pageSize=A4" \
  -F "printBackground=true" \
  -F "marginTop=20px" \
  -F "marginRight=20px" \
  -F "marginBottom=20px" \
  -F "marginLeft=20px"

Endpoints

MethodEndpointAuthDescription
POST/converter/:slugOptionalConvert a file using a dedicated endpoint per conversion (e.g. /converter/html-to-pdf). Accepts conversion-specific options.
POST/converter/convertOptionalLegacy generic convert endpoint (multipart upload with inputFormat/outputFormat fields).
GET/converter/formatsPublicList all supported conversions and their metadata (includes the endpoint slug).
GET/converter/conversionsJWTList the authenticated user's conversion history (paginated).
GET/converter/conversions/:idJWTFetch a single conversion by id (owner only).
GET/converter/statsJWTAggregate usage statistics for the authenticated user.
GET/converter/guest/quotaPublicCheck the guest conversion quota for the current IP.
GET/converter/download/:keyOptionalDownload a converted file by its storage key.

Guests vs. authenticated requests

/converter/:slugaccepts optional authentication. Unauthenticated (guest) requests are limited by IP: 1 request per 10-second window and 2 conversions per day, each file up to 5 MB. Requests made with an API key or JWT deduct credits from the account balance and follow the plan's rate limits, concurrency, and file size limits.

Conversion endpoints & schemas

One endpoint per conversion. Click through to the endpoint details for the input option schema and a request example. Every endpoint returns the same Conversion response schema.

POST/converter/html-to-pdf

HTML to PDF

html, htm pdf

Max 25 MB2 credits9 options
POST/converter/html-to-image

HTML to Image

html, htm png

Max 25 MB2 credits3 options
POST/converter/html-to-markdown

HTML to Markdown

html, htm md

Max 25 MB1 credit3 options
POST/converter/webp-to-png

WebP to PNG

webp png

Max 25 MB1 credit1 option
POST/converter/png-to-webp

PNG to WebP

png webp

Max 25 MB1 credit1 option
POST/converter/webp-to-jpg

WebP to JPG

webp jpg, jpeg

Max 25 MB1 credit1 option
POST/converter/json-to-csv

JSON to CSV

json csv

Max 25 MB1 credit1 option
POST/converter/json-to-xml

JSON to XML

json xml

Max 25 MB1 credit2 options
POST/converter/xml-to-json

XML to JSON

xml json

Max 25 MB1 credit1 option
POST/converter/html-to-pdfHTML to PDFView response schema →

Input

html, htm

Output

pdf (application/pdf)

Max file

25 MB

Credit cost

2

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
pageSizestringA4A4, A3, A5, Letter, Legal, TabloidOutput page size.
landscapebooleanfalsetrue | falseRender the page in landscape orientation.
printBackgroundbooleantruetrue | falsePrint the CSS background graphics.
marginTopstring20pxAny CSS lengthTop margin as a CSS length (e.g. 20px, 12mm).
marginRightstring20pxAny CSS lengthRight margin as a CSS length.
marginBottomstring20pxAny CSS lengthBottom margin as a CSS length.
marginLeftstring20pxAny CSS lengthLeft margin as a CSS length.
headerTextstringAny string (≤ 500 chars)Repeated on every page header (up to 500 chars).
footerTextstringAny string (≤ 500 chars)Repeated on every page footer (up to 500 chars).
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-pdf \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.html" \
  -F "pageSize=A4" \
  -F "printBackground=true" \
  -F "marginTop=20px" \
  -F "marginRight=20px" \
  -F "marginBottom=20px" \
  -F "marginLeft=20px"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/html-to-imageHTML to ImageView response schema →

Input

html, htm

Output

png (image/png)

Max file

25 MB

Credit cost

2

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
widthnumber1280320 – 4096Viewport width in pixels.
heightnumber800240 – 4096Viewport height in pixels.
fullPagebooleantruetrue | falseCapture the full scrollable page height.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-image \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.html" \
  -F "width=1280" \
  -F "height=800" \
  -F "fullPage=true"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/html-to-markdownHTML to MarkdownView response schema →

Input

html, htm

Output

md (text/markdown)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
headingStylestringatxatx | setextMarkdown heading syntax (## vs underline).
codeBlockStylestringfencedfenced | indentedCode block syntax.
bulletListMarkerstring-- | + | *Character used for unordered lists.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-markdown \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.html" \
  -F "headingStyle=atx" \
  -F "codeBlockStyle=fenced" \
  -F "bulletListMarker=-"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/webp-to-pngWebP to PNGView response schema →

Input

webp

Output

png (image/png)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
compressionLevelnumber60 – 9PNG zlib compression level.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/webp-to-png \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.webp" \
  -F "compressionLevel=6"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/png-to-webpPNG to WebPView response schema →

Input

png

Output

webp (image/webp)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
qualitynumber901 – 100Lossy compression quality.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/png-to-webp \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.png" \
  -F "quality=90"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/webp-to-jpgWebP to JPGView response schema →

Input

webp

Output

jpg, jpeg (image/jpeg)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
qualitynumber901 – 100JPEG compression quality.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/webp-to-jpg \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.webp" \
  -F "quality=90"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/json-to-csvJSON to CSVView response schema →

Input

json

Output

csv (text/csv)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
delimiterstring,Any single characterField separator.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/json-to-csv \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.json" \
  -F "delimiter=,"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/json-to-xmlJSON to XMLView response schema →

Input

json

Output

xml (application/xml)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
rootElementstringrootXML element nameName of the XML root element.
prettyPrintbooleantruetrue | falseIndent the output XML.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/json-to-xml \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.json" \
  -F "rootElement=root" \
  -F "prettyPrint=true"

Returns the standard Conversion response envelope.

View response schema →
POST/converter/xml-to-jsonXML to JSONView response schema →

Input

xml

Output

json (application/json)

Max file

25 MB

Credit cost

1

Input options (multipart form fields, all optional)

FieldTypeDefaultAllowed valuesDescription
prettyPrintbooleantruetrue | falsePretty-print the output JSON.
Example requestcURL
curl -X POST https://api.fileswitch.co/api/v1/converter/xml-to-json \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@input.xml" \
  -F "prettyPrint=true"

Returns the standard Conversion response envelope.

View response schema →

Response Schema

The standard Conversion object returned by every conversion endpoint.

On success, every conversion endpoint returns the same envelope: success, message, and data — a Conversion object. The outputFormat, outputFileName, and outputMime vary per conversion:

Response bodyjson
{
  "success": true,
  "message": "Conversion completed",
  "data": {
    "id": "b10a5f2e-8c1e-4b3a-9c1d-2e3f4a5b6c7d",
    "userId": "4b006abd-e7a3-48e5-a29c-d14d28465b57",
    "inputFormat": "html",
    "outputFormat": "pdf",
    "inputFileName": "document.html",
    "outputFileName": "document.pdf",
    "inputFileSize": 45210,
    "outputFileSize": 88431,
    "status": "completed",
    "error": null,
    "creditCost": 2,
    "filesCleanedAt": null,
    "createdAt": "2026-07-31T13:00:00.000Z",
    "completedAt": "2026-07-31T13:00:02.000Z",
    "downloadUrl": "/api/v1/converter/download/conversions%2Fb10a5f2e-8c1e-4b3a-9c1d-2e3f4a5b6c7d%2Foutput.pdf"
  }
}
FieldTypeDescription
idstringUnique conversion identifier (UUID).
userIdstring | nullOwning account id; null for guest conversions.
inputFormatstringDetected input format of the uploaded file.
outputFormatstringFormat produced by this conversion.
inputFileNamestringOriginal filename of the uploaded file.
outputFileNamestring | nullFilename of the converted output.
inputFileSizenumberUpload size in bytes.
outputFileSizenumber | nullConverted output size in bytes.
statusstringLifecycle state: pending, processing, completed, or failed.
errorstring | nullError message when the conversion failed.
creditCostnumber | nullCredits charged for this conversion.
filesCleanedAtstring | nullWhen the stored output was auto-deleted.
createdAtstringISO 8601 timestamp when the conversion was created.
completedAtstring | nullISO 8601 timestamp when the conversion finished.
downloadUrlstring | nullRelative URL to download the output; present while the output is stored.

Downloading the output

The downloadUrl is relative to the API host. Prepend https://api.fileswitch.co to download the file with the same API key (or the owning account's JWT). Files are retained temporarily and auto-deleted, so download outputs promptly:

Download the outputbash
curl https://api.fileswitch.co/api/v1/converter/download/conversions%2Fb10a5f2e-8c1e-4b3a-9c1d-2e3f4a5b6c7d%2Foutput.pdf \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  --output document.pdf

Rate Limits & Credits

How usage is governed per plan and per guest.

Plans

PlanMonthly creditsMax fileRate limit (req/s)Concurrent jobsAPI keys
Free20010 MB210
Starter100025 MB522
Pro4500100 MB1555
Scale15000500 MB301510

The effective upload limit is the lower of your plan's max file size and the converter's own limit (currently 25 MB for every supported conversion). Guests are capped at 5 MB.

Rate limiting

  • A global rate limit applies to all requests: 100 requests per 15-minute window per IP.
  • The conversion endpoint uses a stricter, per-account limiter: your plan's rateLimitRPS sustained over a rolling window.
  • Guests get 1 conversion request per 10-second window plus a daily quota.
  • Excess traffic returns HTTP 429 with Retry-After.

Guest quota

Without signing in you can convert up to 2 files per day (per IP), each up to 5 MB. The GET /converter/guest/quota endpoint reports how many conversions remain.

Credit costs

Conversions consume credits from your account. The base cost depends on the conversion type — heavy browser-based jobs cost more:

ConversionBase cost
html → pdf, html → png2 credits
html → md, webp → png, png → webp, webp → jpg, json → csv, json → xml, xml → json1 credit

File size adds a multiplier: files ≤ 25 MB cost 1×, files 25–100 MB cost 2×, and files over 100 MB cost 3×. Total cost = base cost × multiplier. Insufficient credits returns HTTP 402. Failed conversions are automatically refunded.

Response Codes

HTTP status codes and machine-readable error identifiers.

HTTP status codes

CodeNameDescription
200OKRequest succeeded. The response body contains the data envelope.
201CreatedA resource was created (account, API key, or conversion record).
400Bad RequestMalformed request, invalid body fields, missing file, or validation failure.
401UnauthorizedMissing, invalid, or expired credentials.
402Payment RequiredThe account does not have enough credits for the conversion.
403ForbiddenAuthenticated but not allowed (e.g. API keys require a paid plan, guest quota exceeded).
404Not FoundRoute, resource, or file does not exist or is not owned by you.
413Payload Too LargeThe uploaded file exceeds the allowed size for your plan or the converter.
422Unprocessable EntityThe requested input-to-output conversion is not supported, or the uploaded file's format does not match this conversion endpoint.
429Too Many RequestsRate limit exceeded. The Retry-After header indicates when to retry.
500Internal Server ErrorAn unexpected server error occurred. Retry later or contact support.

Error codes

CodeStatusDescription
VALIDATION_ERROR400Request body failed schema validation. Check the details field for the offending fields.
UNSUPPORTED_FILE_TYPE400The uploaded file's extension is not a recognized input format.
NO_FILE400The multipart upload contained no file.
UNEXPECTED_FILE400More than one file was uploaded to a single-file field.
UPLOAD_ERROR400The multipart upload failed for an unknown reason.
INVALID_FILE_KEY400The download key is not a valid storage key.
UNAUTHORIZED401No token provided, or the token could not be verified.
API_KEYS_REQUIRE_PAID_PLAN403API keys are a paid feature; the account is on a plan without API access.
GUEST_QUOTA_EXCEEDED403Guest daily conversion quota reached. Sign in to continue.
ACCESS_DENIED403The resource belongs to another account.
PAYMENT_REQUIRED402Insufficient credits for the conversion. Top up or upgrade.
FILE_TOO_LARGE413File exceeds the plan or converter size limit.
GUEST_FILE_TOO_LARGE413File exceeds the guest 5MB limit; sign in to upload larger files.
UNSUPPORTED_FORMAT422The input-to-output conversion is not supported, or the file's format does not match the conversion endpoint.
UNKNOWN_CONVERSION404The conversion endpoint slug does not exist (e.g. POST /converter/nope).
API_KEY_LIMIT_REACHED403The plan's API key allowance is exhausted; revoke a key or upgrade.
NOT_FOUND404Resource does not exist or is not visible to the caller.
TOO_MANY_REQUESTS429Rate limit exceeded.
INTERNAL_ERROR500Unexpected server error.

OpenAPI Schema

Pull the complete API contract into your toolchain.

The API publishes its full contract as an OpenAPI 3.0.3 document at GET /api/v1/openapi.json. It declares every endpoint — including all nine per-conversion routes — plus authentication, request bodies, and response schemas. Each conversion's input schema is published as a named component (e.g. HtmlToPdfInput), so clients can validate form fields and generate typed SDKs at build time.

Fetch the specbash
curl https://api.fileswitch.co/api/v1/openapi.json > openapi.json

Using the schema

  • Open the spec in Swagger Editor for an interactive, browsable reference.
  • Import the URL into Postman (File → Import → Link) to generate a collection with every endpoint preconfigured.
  • Import into Insomnia (Create → Import → URL) the same way.
  • Generate typed clients with openapi-generator or openapi-typescript from the same URL.

A conversion endpoint is declared with a multipart/form-data request body: a required filefield plus the option properties from the conversion's input schema:

Excerpt of /api/v1/openapi.jsonjson
"/converter/html-to-pdf": {
  "post": {
    "operationId": "convertHtmlToPdf",
    "requestBody": {
      "content": {
        "multipart/form-data": {
          "schema": {
            "type": "object",
            "required": ["file"],
            "properties": {
              "file": { "type": "string", "format": "binary" },
              "pageSize": { "type": "string", "enum": ["A4", "A3", "A5", "Letter", "Legal", "Tabloid"], "default": "A4" },
              "headerText": { "type": "string", "default": "" },
              "footerText": { "type": "string", "default": "" }
            }
          }
        }
      }
    }
  }
}

API Keys

Create, list, and revoke API keys programmatically.

Create a key

curlbash
curl -X POST https://api.fileswitch.co/api/v1/integrations/api-keys \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "ci-server", "expiresInDays": 90}'

Response (201) — the full key is shown exactly once:

Responsejson
{
  "success": true,
  "data": {
    "id": "c47afec6-083c-4228-a108-2271ce598dff",
    "name": "ci-server",
    "keyPrefix": "fc_ab12cd34",
    "lastFour": "5678",
    "lastUsedAt": null,
    "expiresAt": "2026-10-29T13:00:00.000Z",
    "revokedAt": null,
    "createdAt": "2026-07-31T13:00:00.000Z",
    "fullKey": "fc_ab12cd34..."
  }
}
  • name is required (1–100 characters). expiresInDays is optional (1–365); omit it for a non-expiring key.
  • Returns HTTP 403 with code API_KEYS_REQUIRE_PAID_PLAN on a free plan.
  • Returns HTTP 403 with code API_KEY_LIMIT_REACHED when the plan allowance is exhausted.

Endpoints

MethodEndpointAuthDescription
GET/integrations/api-keysJWTList API keys for the authenticated user.
POST/integrations/api-keysJWTCreate an API key (paid plans only).
POST/integrations/api-keys/:id/revokeJWTPermanently revoke an API key.

Keys are scoped to the authenticated user; attempting to revoke another user's key returns 404.

SDKs & Code Examples

Convert a file and download the result in the language of your choice.

The examples below show a full convert-and-download flow in the language selected by the switcher at the top of this page.

Convert & download (HTML to PDF)cURL
# 1. Convert with options
curl -X POST https://api.fileswitch.co/api/v1/converter/html-to-pdf \
  -H "Authorization: Bearer fc_YOUR_API_KEY" \
  -F "file=@report.html" \
  -F "pageSize=A4" \
  -F "headerText=Quarterly Report" \
  -F "footerText=Confidential" > response.json

# 2. Download the converted file using the returned downloadUrl
URL=$(node -e "console.log(JSON.parse(require('fs').readFileSync('response.json')).data.downloadUrl)")
curl https://api.fileswitch.co$URL -H "Authorization: Bearer fc_YOUR_API_KEY" \
  --output report.pdf

Handling errors & rate limits

Resilient conversionpython
import time, requests

headers = {"Authorization": "Bearer fc_YOUR_API_KEY"}

for attempt in range(3):
    res = requests.post(
        "https://api.fileswitch.co/api/v1/converter/json-to-csv",
        headers=headers,
        files={"file": open("data.json", "rb")},
        data={"delimiter": ";"},
    )
    if res.status_code == 429:
        retry_after = int(res.headers.get("Retry-After", 5))
        time.sleep(retry_after)
        continue
    res.raise_for_status()
    break

# 402 -> insufficient credits, 413 -> file too large, 422 -> unsupported input for this endpoint

Best Practices & Security

Keep your integration fast, safe, and reliable.

  • Store API keys securely. Keep them in environment variables or a secret manager, never in client-side code or repositories. The full key is only shown once.
  • Download outputs promptly. Converted files are retained temporarily and cleaned up automatically.
  • Respect rate limits. Honor HTTP 429 and the Retry-After header with exponential backoff.
  • Watch your credit balance. Poll GET /credits/balance and handle HTTP 402 gracefully by prompting for a top-up or upgrade.
  • Rotate keys. Revoke a key and create a new one if it is ever exposed or when a service is decommissioned.
  • Set key expiries. Use expiresInDays for temporary or CI credentials so they cannot outlive their purpose.
  • Pagination. History and transactions default to page size 20 (max 50). Use the meta response to page through results.

Security & compliance

  • All traffic is encrypted in transit (HTTPS).
  • Uploaded and converted files are auto-deleted after a short retention period.
  • API keys are stored as one-way hashes — the plaintext is never recoverable.
  • Conversions are scoped to your account and cannot be read by other accounts.

Need help? Contact support or check the plans to pick the right tier for your usage.