> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.privategpt.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server.

# Convert File to Markdown or Tree

POST /v1/artifacts/convert
Content-Type: application/json

Parse a file using the document readers and return its content as markdown text or a structured content tree, without ingesting it into the knowledge base.

Reference: https://docs.privategpt.dev/api-reference/artifacts/convert-content-v-1-artifacts-convert-post

## Request

### Body (application/json)

This endpoint expects a ConvertBody.

- `input` (ConvertBodyInput, required) — File content as base64, remote URI, or plain text
- `metadata` (map from string to any, optional, nullable) — Optional metadata, must include 'file_name' to resolve file extension
- `reader` (string, optional, nullable) — Reader to use for parsing. If omitted the default reader for the file type is used.
- `format` (enum, optional) — Output format: 'markdown' returns text, 'object' returns a content tree.
  - Allowed values: `object`, `markdown`

## Response

### 200

Successful conversion

- `content` (ConvertResponseContent, required) — Parsed file content in the requested format
- `reader` (string, required) — Reader that was used to parse the file

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 422 Unprocessable Entity Error

Validation Error

- `detail` (OpenApiValidationErrorResponseDetail, required) — Error detail — a string message or a list of validation error objects.

## Types

### ConvertBodyInput

File content as base64, remote URI, or plain text

- `type`: `file` (FileArtifact)
  - `value` (string, required) — Base64 encoded file content
- `type`: `text` (TextArtifact)
  - `value` (string, required) — Plain text content
- `type`: `uri` (UriArtifact)
  - `value` (string, required) — URI to download from

### ConvertResponseContent

Parsed file content in the requested format

### OpenApiValidationErrorResponseDetail

Error detail — a string message or a list of validation error objects.

### ContentTree

Structured representation of document content as a tree.

- `id` (string, required) — Unique identifier of the node
- `type` (string, required) — Type of the node (e.g., section, paragraph)
- `content` (string, required) — Text content of the node
- `children` (list of ContentTree, optional) — Child nodes representing nested content structure

## Examples

### Converted content as markdown text

**Response**

```json
{
  "content": "# Annual Report 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period...",
  "reader": "markitdown"
}
```

**SDK Code**

```python Converted content as markdown text
import requests

url = "https://api.example.com/v1/artifacts/convert"

response = requests.post(url)

print(response.json())
```

```javascript Converted content as markdown text
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {method: 'POST'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Converted content as markdown text
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Converted content as markdown text
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
```

```java Converted content as markdown text
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .asString();
```

```php Converted content as markdown text
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert');

echo $response->getBody();
```

```csharp Converted content as markdown text
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift Converted content as markdown text
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Converted content as structured tree

**Response**

```json
{
  "content": {
    "children": [
      {
        "children": [
          {
            "children": [],
            "content": "Executive Summary\n\nFiscal year 2023 marked a transformative period...",
            "id": "text-1",
            "type": "TextNode"
          }
        ],
        "content": "Annual Report 2023",
        "id": "section-1",
        "type": "SectionNode"
      }
    ],
    "content": "",
    "id": "root",
    "type": "document"
  },
  "reader": "docling"
}
```

**SDK Code**

```python Converted content as structured tree
import requests

url = "https://api.example.com/v1/artifacts/convert"

response = requests.post(url)

print(response.json())
```

```javascript Converted content as structured tree
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {method: 'POST'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Converted content as structured tree
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Converted content as structured tree
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
```

```java Converted content as structured tree
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .asString();
```

```php Converted content as structured tree
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert');

echo $response->getBody();
```

```csharp Converted content as structured tree
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift Converted content as structured tree
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Plain text content

**Request**

```json
{
  "input": {
    "type": "text",
    "value": "# Hello\n\nThis is a simple markdown document."
  },
  "metadata": {
    "file_name": "hello.md"
  },
  "format": "markdown"
}
```

**Response**

```json
{
  "content": "# Annual Report 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period...",
  "reader": "markitdown"
}
```

**SDK Code**

```python Plain text content
import requests

url = "https://api.example.com/v1/artifacts/convert"

payload = {
    "input": {
        "type": "text",
        "value": "# Hello

This is a simple markdown document."
    },
    "metadata": { "file_name": "hello.md" },
    "format": "markdown"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Plain text content
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":{"type":"text","value":"# Hello\n\nThis is a simple markdown document."},"metadata":{"file_name":"hello.md"},"format":"markdown"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Plain text content
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	payload := strings.NewReader("{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Hello\\n\\nThis is a simple markdown document.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"hello.md\"\n  },\n  \"format\": \"markdown\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Plain text content
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Hello\\n\\nThis is a simple markdown document.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"hello.md\"\n  },\n  \"format\": \"markdown\"\n}"

response = http.request(request)
puts response.read_body
```

```java Plain text content
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Hello\\n\\nThis is a simple markdown document.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"hello.md\"\n  },\n  \"format\": \"markdown\"\n}")
  .asString();
```

```php Plain text content
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert', [
  'body' => '{
  "input": {
    "type": "text",
    "value": "# Hello\\n\\nThis is a simple markdown document."
  },
  "metadata": {
    "file_name": "hello.md"
  },
  "format": "markdown"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Plain text content
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Hello\\n\\nThis is a simple markdown document.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"hello.md\"\n  },\n  \"format\": \"markdown\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Plain text content
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "input": [
    "type": "text",
    "value": "# Hello

This is a simple markdown document."
  ],
  "metadata": ["file_name": "hello.md"],
  "format": "markdown"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### File content (base64)

**Request**

```json
{
  "input": {
    "type": "file",
    "value": "JVBERi0xLjQKJaqrrK0KMS..."
  },
  "metadata": {
    "file_name": "report.pdf"
  },
  "reader": "markitdown",
  "format": "markdown"
}
```

**Response**

```json
{
  "content": "# Annual Report 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period...",
  "reader": "markitdown"
}
```

**SDK Code**

```python File content (base64)
import requests

url = "https://api.example.com/v1/artifacts/convert"

payload = {
    "input": {
        "type": "file",
        "value": "JVBERi0xLjQKJaqrrK0KMS..."
    },
    "metadata": { "file_name": "report.pdf" },
    "reader": "markitdown",
    "format": "markdown"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript File content (base64)
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":{"type":"file","value":"JVBERi0xLjQKJaqrrK0KMS..."},"metadata":{"file_name":"report.pdf"},"reader":"markitdown","format":"markdown"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go File content (base64)
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	payload := strings.NewReader("{\n  \"input\": {\n    \"type\": \"file\",\n    \"value\": \"JVBERi0xLjQKJaqrrK0KMS...\"\n  },\n  \"metadata\": {\n    \"file_name\": \"report.pdf\"\n  },\n  \"reader\": \"markitdown\",\n  \"format\": \"markdown\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby File content (base64)
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": {\n    \"type\": \"file\",\n    \"value\": \"JVBERi0xLjQKJaqrrK0KMS...\"\n  },\n  \"metadata\": {\n    \"file_name\": \"report.pdf\"\n  },\n  \"reader\": \"markitdown\",\n  \"format\": \"markdown\"\n}"

response = http.request(request)
puts response.read_body
```

```java File content (base64)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": {\n    \"type\": \"file\",\n    \"value\": \"JVBERi0xLjQKJaqrrK0KMS...\"\n  },\n  \"metadata\": {\n    \"file_name\": \"report.pdf\"\n  },\n  \"reader\": \"markitdown\",\n  \"format\": \"markdown\"\n}")
  .asString();
```

```php File content (base64)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert', [
  'body' => '{
  "input": {
    "type": "file",
    "value": "JVBERi0xLjQKJaqrrK0KMS..."
  },
  "metadata": {
    "file_name": "report.pdf"
  },
  "reader": "markitdown",
  "format": "markdown"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp File content (base64)
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": {\n    \"type\": \"file\",\n    \"value\": \"JVBERi0xLjQKJaqrrK0KMS...\"\n  },\n  \"metadata\": {\n    \"file_name\": \"report.pdf\"\n  },\n  \"reader\": \"markitdown\",\n  \"format\": \"markdown\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift File content (base64)
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "input": [
    "type": "file",
    "value": "JVBERi0xLjQKJaqrrK0KMS..."
  ],
  "metadata": ["file_name": "report.pdf"],
  "reader": "markitdown",
  "format": "markdown"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Remote URI

**Request**

```json
{
  "input": {
    "type": "uri",
    "value": "https://example.com/document.pdf"
  },
  "metadata": {
    "file_name": "document.pdf"
  },
  "format": "object"
}
```

**Response**

```json
{
  "content": "# Annual Report 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period...",
  "reader": "markitdown"
}
```

**SDK Code**

```python Remote URI
import requests

url = "https://api.example.com/v1/artifacts/convert"

payload = {
    "input": {
        "type": "uri",
        "value": "https://example.com/document.pdf"
    },
    "metadata": { "file_name": "document.pdf" },
    "format": "object"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Remote URI
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":{"type":"uri","value":"https://example.com/document.pdf"},"metadata":{"file_name":"document.pdf"},"format":"object"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Remote URI
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	payload := strings.NewReader("{\n  \"input\": {\n    \"type\": \"uri\",\n    \"value\": \"https://example.com/document.pdf\"\n  },\n  \"metadata\": {\n    \"file_name\": \"document.pdf\"\n  },\n  \"format\": \"object\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Remote URI
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": {\n    \"type\": \"uri\",\n    \"value\": \"https://example.com/document.pdf\"\n  },\n  \"metadata\": {\n    \"file_name\": \"document.pdf\"\n  },\n  \"format\": \"object\"\n}"

response = http.request(request)
puts response.read_body
```

```java Remote URI
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": {\n    \"type\": \"uri\",\n    \"value\": \"https://example.com/document.pdf\"\n  },\n  \"metadata\": {\n    \"file_name\": \"document.pdf\"\n  },\n  \"format\": \"object\"\n}")
  .asString();
```

```php Remote URI
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert', [
  'body' => '{
  "input": {
    "type": "uri",
    "value": "https://example.com/document.pdf"
  },
  "metadata": {
    "file_name": "document.pdf"
  },
  "format": "object"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Remote URI
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": {\n    \"type\": \"uri\",\n    \"value\": \"https://example.com/document.pdf\"\n  },\n  \"metadata\": {\n    \"file_name\": \"document.pdf\"\n  },\n  \"format\": \"object\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Remote URI
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "input": [
    "type": "uri",
    "value": "https://example.com/document.pdf"
  ],
  "metadata": ["file_name": "document.pdf"],
  "format": "object"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Return structured content tree

**Request**

```json
{
  "input": {
    "type": "text",
    "value": "# Section\n\nSome content here."
  },
  "metadata": {
    "file_name": "doc.md"
  },
  "format": "object"
}
```

**Response**

```json
{
  "content": "# Annual Report 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period...",
  "reader": "markitdown"
}
```

**SDK Code**

```python Return structured content tree
import requests

url = "https://api.example.com/v1/artifacts/convert"

payload = {
    "input": {
        "type": "text",
        "value": "# Section

Some content here."
    },
    "metadata": { "file_name": "doc.md" },
    "format": "object"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Return structured content tree
const url = 'https://api.example.com/v1/artifacts/convert';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":{"type":"text","value":"# Section\n\nSome content here."},"metadata":{"file_name":"doc.md"},"format":"object"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Return structured content tree
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/convert"

	payload := strings.NewReader("{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Section\\n\\nSome content here.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"doc.md\"\n  },\n  \"format\": \"object\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Return structured content tree
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/convert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Section\\n\\nSome content here.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"doc.md\"\n  },\n  \"format\": \"object\"\n}"

response = http.request(request)
puts response.read_body
```

```java Return structured content tree
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/convert")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Section\\n\\nSome content here.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"doc.md\"\n  },\n  \"format\": \"object\"\n}")
  .asString();
```

```php Return structured content tree
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/convert', [
  'body' => '{
  "input": {
    "type": "text",
    "value": "# Section\\n\\nSome content here."
  },
  "metadata": {
    "file_name": "doc.md"
  },
  "format": "object"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Return structured content tree
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"# Section\\n\\nSome content here.\"\n  },\n  \"metadata\": {\n    \"file_name\": \"doc.md\"\n  },\n  \"format\": \"object\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Return structured content tree
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "input": [
    "type": "text",
    "value": "# Section

Some content here."
  ],
  "metadata": ["file_name": "doc.md"],
  "format": "object"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/convert")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```