> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refile.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Ship your refile integration fast

We're dedicated to providing the simplest integration experience possible. If you encounter any challenges or have suggestions for improvement, please reach email [dx@refile.co](mailto:dx@refile.co).

## Your first PDF

1. [Sign up](https://refile.co/dashboard) for refile to get your API key and use the playground
2. Make your first call to the refile API

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
    --url https://www.refile.co/api/v1/pdf/markdown \
    --header "Authorization: Bearer <token>" \
    --data '{
    "markdown": "# My first PDF!\nThis is my first PDF."
  }' --output ./output.pdf
  ```

  ```javascript JavaScript theme={null}
  const markdown = `
  # My first document on refile

  Welcome to my first document!
  `;

  const options = {
  	method: "POST",
  	headers: {
  		Authorization: "Bearer <token>", // Replace <token> with your API key
  	},
  	body: JSON.stringify({
  		markdown: markdown,
  		output: "url", // Use "binary" for binary output
  	}),
  };

  fetch("https://www.refile.co/api/v1/pdf/markdown", options)
  	.then((response) => response.json())
  	.then((response) => console.log(response))
  	.catch((err) => console.error(err));
  ```

  ```python Python theme={null}
  import requests

  url = "https://www.refile.co/api/v1/pdf/markdown"

  payload = {
      "markdown": "# My first document on refile\n\nWelcome to my first document!",
      "output": "url"  # Use "binary" for binary output
  }

  headers = {
      "Authorization": "Bearer <token>"  # Replace <token> with your API key
  }

  response = requests.request("POST", url, json=payload, headers=headers)

  print(response.text)
  ```

  ```php PHP theme={null}
  <?php

  $curl = curl_init();

  $markdown = "# My first document on refile\n\nWelcome to my first document!";

  $payload = json_encode([
      "markdown" => $markdown,
      "output" => "url"  // Use "binary" for binary output
  ]);

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://www.refile.co/api/v1/pdf/markdown",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => [
      "Authorization: Bearer <token>",  // Replace <token> with your API key
      "Content-Type: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io/ioutil"
  	"net/http"
  )

  func main() {
  	url := "https://www.refile.co/api/v1/pdf/markdown"

  	markdown := "# My first document on refile\n\nWelcome to my first document!"

  	payload := map[string]interface{}{
  		"markdown": markdown,
  		"output":   "url", // Use "binary" for binary output
  	}

  	jsonPayload, _ := json.Marshal(payload)

  	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))

  	req.Header.Add("Content-Type", "application/json")
  	req.Header.Add("Authorization", "Bearer <token>") // Replace <token> with your API key

  	client := &http.Client{}
  	res, _ := client.Do(req)

  	defer res.Body.Close()
  	body, _ := ioutil.ReadAll(res.Body)

  	fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import com.mashape.unirest.http.HttpResponse;
  import com.mashape.unirest.http.Unirest;
  import com.mashape.unirest.http.exceptions.UnirestException;

  public class RefileExample {
      public static void main(String[] args) throws UnirestException {
          String url = "https://www.refile.co/api/v1/pdf/markdown";

          String markdown = "# My first document on refile\n\nWelcome to my first document!";

          String requestBody = "{"
              + "\"markdown\": \"" + markdown + "\","
              + "\"output\": \"url\"" // Use "binary" for binary output
              + "}";

          HttpResponse<String> response = Unirest.post(url)
              .header("Content-Type", "application/json")
              .header("Authorization", "Bearer <token>") // Replace <token> with your API key
              .body(requestBody)
              .asString();

          System.out.println(response.getBody());
      }
  }
  ```

  ```rust Rust theme={null}
  use serde_json::json;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let url = "https://www.refile.co/api/v1/pdf/markdown";

      let markdown = "# My first document on refile\n\nWelcome to my first document!";

      let payload = json!({
          "markdown": markdown,
          "output": "url"  // Use "binary" for binary output
      });

      let client = reqwest::Client::new();
      let response = client.post(url)
          .header("Content-Type", "application/json")
          .header("Authorization", "Bearer <token>")  // Replace <token> with your API key
          .json(&payload)
          .send()
          .await?;

      let response_text = response.text().await?;
      println!("{}", response_text);

      Ok(())
  }
  ```
</CodeGroup>

## Customizing your payload

You can enhance your PDF generation by customizing various properties in your API payload. These options allow you to control the appearance, formatting, and delivery of your documents.

### Markdown

Markdown content is specified via the `markdown` property. We fully support [GitHub Flavored Markdown (GFM)](https://github.github.com/gfm/), and inline HTML with custom CSS via `<style>` tags.

### Themes

Enhance your document's appearance by setting the `theme` property to one of our professionally designed options from the [themes gallery](/essentials/themes). Each theme provides a unique visual style that can match your brand or content purpose. The default theme is `modern`.

### Page numbers

Use the `pageNumeration` property to control page number placement in your PDF. Available options include `"none"` (default, no page numbers), `"center"` (centered at bottom), `"left"` (bottom left), and `"right"` (bottom right).

### Output format

The `output` property determines how the generated PDF is returned:

* `"binary"` (default): Returns the PDF as binary data in the response, which you can save directly to a file.
* `"url"`: Returns a URL to download the generated PDF. The URL is valid for at least 7 days.

Choose `"url"` for most web applications where you want to provide a download link, and `"binary"` when you need to process or store the PDF data directly in your application. When you choose URL, we will host your PDF on [Vercel Blob Storage](https://vercel.com/docs/vercel-blob).

### Page size

Control the dimensions of your PDF by setting the `pageSize` property. We support many standard paper sizes, including A0-A9, Letter, Legal and B1-B6.

For the full list of supported paper sizes, refer to the [API reference](/api-reference/generate-pdf-from-markdown#body-page-size).

### Example payload

```json JSON theme={null}
{
	"markdown": "# Example Document\n\nThis is a sample document created with refile.",
	"theme": "basic",
	"pageNumeration": "left",
	"output": "url",
	"pageSize": "Legal"
}
```

***

# Further reading

<CardGroup cols={2}>
  <Card title="API Playground" icon="play" href="https://refile.co/dashboard">
    Play around with the API options in a simple interface
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference">
    An overview of our API
  </Card>

  <Card title="LangChainJS" icon="link" href="/developers/langchainjs/">
    Use refile with LangChainJS
  </Card>

  <Card title="Vercel AI SDK" icon="triangle" href="/developers/aisdk/">
    Use refile with Vercel AI SDK
  </Card>
</CardGroup>
