# Quickstart

Your first PDF in three steps: export the key, send a markdown file, save the response.

Page: https://legivel.com/docs/quickstart

## Prerequisites

- A legivel account.
- An API key. See [Get your API key](https://legivel.com/docs/api-key).

There is no SDK. Every sample below is a plain HTTP request, so any language with an HTTP client works.

## Render your first PDF

1. ### Set your API key

   ```bash
   export LEGIVEL_API_KEY="lgv_your_key_here"
   ```
2. ### Write a markdown file

   hello.md

   [Open in editor](https://legivel.com/markdown-to-pdf?sample=docs-quickstart)

   ````markdown
   # Hello, legivel

   This paragraph uses paragraph-wide line breaking. Set a document language to enable automatic hyphenation.

   - One list item
   - Another list item

   ```mermaid
   flowchart LR
     md[markdown] --> pdf[PDF]
   ```
   ````

   Open it in the editor to see the PDF before you have a key.
3. ### Send it

   POST the file as the request body with `Content-Type: text/markdown`. The response body is the PDF.

   ```bash
   curl -X POST https://api.legivel.com/v1/render \
     -H "Authorization: Bearer $LEGIVEL_API_KEY" \
     -H "Content-Type: text/markdown" \
     --data-binary @hello.md \
     -o hello.pdf
   ```
4. ### Check the result

   Open `hello.pdf`. Then read your usage; `credits_used` has increased by 1.

   ```bash
   curl https://api.legivel.com/v1/usage \
     -H "Authorization: Bearer $LEGIVEL_API_KEY"
   ```

   ```json
   {
     "plan": "free",
     "period_start": "2026-09-09T00:00:00.000Z",
     "period_end": "2026-10-09T00:00:00.000Z",
     "credits_included": 100,
     "credits_granted": 0,
     "credits_used": 1,
     "limits": { "markdown_kb": 512, "resources_mb": 1.5, "pages_max": 20,
                 "timeout_s": 30, "concurrency": 1, "requests_per_min": 5, "previews_per_hour": 120 },
     "keys": [{ "id": "<id of the calling key>", "name": "CI", "credits": 1 }]
   }
   ```

   Sign in and this block shows your own account.

JSON works too

Send `Content-Type: application/json` with a body of `{"markdown": "..."}` instead of raw markdown. The response is the same.

## What happened

- The request used one of your period's documents. The Free plan includes 100 documents per period. A failed render returns the document to your period.
- The PDF carries no watermark. Only the web editor's free preview does.
- The response carries a `Server-Timing` header with the converter's own numbers in milliseconds: `setup`, `render`, `serialize` and `total`.

## Next steps

- [Render a PDF](https://legivel.com/docs/api/render): the JSON body and the `Idempotency-Key` header for safe retries.
- [Errors and quota](https://legivel.com/docs/errors): every error code and what to do about it.
- [Limits](https://legivel.com/docs/limits): what each plan allows and what a refusal costs.
- [MCP server](https://legivel.com/docs/mcp): the same render from an agent.
