> 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.

# Retrieve Full Document Content in Chunks

POST /v1/artifacts/chunked-content
Content-Type: application/json

Retrieve full document content split into chat-optimized chunks.

This endpoint provides access to complete document content split into
manageable chunks suitable for chat interfaces. Unlike semantic chunk
retrieval, this returns complete documents divided sequentially.

Key Features:
* Chat-Optimized Chunking: Documents split into conversational pieces
* Node Type Filtering: Include or exclude images, tables, and other node types
* Token-Aware Splitting: Respects token limits for chat context management
* Sequential Chunks: Maintains document order and narrative flow
* Filtered Retrieval: Select specific documents using metadata filters
* Token Limiting: Optional max_tokens parameter to control response size

Content Filtering:
* Use include to retrieve only specific node types
* Use exclude to omit unwanted content types
* Supports TextNode, ImageNode, TableNode, and other node types
* Filtering is applied before chunking

Chunking Process:
1. Retrieve filtered documents based on context criteria
2. Apply node type filters (include/exclude)
3. Split documents into chat-appropriate segments respecting max_tokens
4. Return structured chunks with metadata and citations

Notes:
* Chunks maintain document structure and logical flow
* Token limiting prevents context window overflow
* Node type filtering reduces payload size and improves relevance
* Use `/artifacts/search` endpoint for semantic search instead

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

## Request

### Body (application/json)

This endpoint expects a ContentBody.

- `context_filter` (ContextFilter, required) — Filter to select documents to retrieve. Supports filtering by collection, artifacts, and metadata.
- `format` (enum, optional) — Format for returned content. 'object' returns structured data, 'markdown' returns content formatted as markdown text.
  - Allowed values: `object`, `markdown`
- `filter` (ContentFilter, optional, nullable) — Content filtering options to include or exclude specific node types. Use this to control the types of content returned in the response.
- `max_tokens` (integer, optional, nullable) — Maximum number of tokens to return in the content. If not set, returns full content of the documents.

## Response

### 200

Successful chunked content retrieval

- `data` (list of ChunkedContentDocumentResponse, required) — List of documents with their content split into chunks for chat usage

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 422 Unprocessable Entity Error

Validation Error - Invalid request parameters

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

## Types

### ContextFilter

Filter by collection, artifacts and metadata in the ingested context. The main filter is the collection the context is part of. All artifacts ids are ensured to be part of the context. If any of the ids is not usable in the context (i.e. doesn't exist), the related task will fail. The metadata filter will look for all context matching the metadata, if any, and add it to the context. The filter is a dictionary of key-value pairs. The key is the metadata key, and the value is the metadata value. If both artifacts and metadata filters are provided, the result will be the intersection of the two filters.

- `collection` (string, optional, default: pgpt_collection) — The name of the collection to filter on.
- `artifacts` (list of string, optional, nullable) — Artifacts ids to filter on.
- `metadata_filter` (list of map from string to any, optional, nullable) — Metadata filter to apply on the context.

### ContentFilter

Filter the content by node types to include in the response.

- `include` (list of enum, optional, nullable) — List of node types to include in the content response. If not specified, all node types will be included. Example node types include TextNode, ImageNode, TableNode, etc.
  - Allowed values: `ImageNode`, `ListItemNode`, `ListNode`, `SectionNode`, `TableNode`, `TableRowNode`, `TextNode`
- `exclude` (list of enum, optional, nullable) — List of node types to exclude from the content response. If not specified, no node types will be excluded. Example node types include TextNode, ImageNode, TableNode, etc.
  - Allowed values: `ImageNode`, `ListItemNode`, `ListNode`, `SectionNode`, `TableNode`, `TableRowNode`, `TextNode`
- `node_ids` (list of string, optional, nullable) — List of specific node IDs to retrieve from the document tree. When specified, only these nodes (and optionally their children) will be returned. Useful for retrieving specific sections or parts of a document. Example: ['382b0aab-3c63-44a1-ae2e-1ee234009d6e', '6d2a3086-10bc-4d76-885b-2208c211b648']
- `include_children` (boolean, optional, default: true) — When node_ids is specified, determines whether to include the full subtree below each selected node. If True (default), returns complete subtrees. If False, returns only the specified nodes without their descendants.
- `include_ancestors` (boolean, optional, default: false) — When node_ids is specified, determines whether to include ancestor nodes in the path from each selected node to the document root. If True, provides structural context. If False (default), returns only selected subtrees.

### ChunkedContentDocumentResponse

Response model for chunked document content.

- `artifact_id` (string, required) — Identifier of the document
- `content` (list of ChunkedContentDocumentResponseContentItems, required) — Chunked content of the document, split into manageable pieces

### OpenApiValidationErrorResponseDetail

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

### ChunkedContentDocumentResponseContentItems

### TextBlock

Plain-text content block.

- `type` ("text", required) — type field.
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (TextBlockCacheControl, optional, nullable) — cache control field.
- `text` (string, optional, default: ) — Text payload for this block.
- `citations` (list of ZylonCitation, optional, nullable, default: []) — citations field.

### ImageBlock

Anthropic-compatible image content block.

- `type` ("image", required) — type field.
- `source` (ImageBlockSource, required) — Anthropic image source payload
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (ImageBlockCacheControl, optional, nullable) — cache control field.

### AudioBlock

Anthropic-compatible audio content block.

- `type` ("audio", required) — type field.
- `source` (AudioBlockSource, required) — Audio source payload
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (AudioBlockCacheControl, optional, nullable) — cache control field.

### BinaryBlock

Arbitrary binary payload (PDF, ZIP, …) encoded as base64.

- `type` ("binary", required) — type field.
- `source` (BinaryBlockSource, required) — Binary source payload
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `filename` (string, optional, nullable) — filename field.

### LocalResourceBlock

Reference to a local file produced by code execution.

- `type` ("local_resource", required) — type field.
- `file_path` (string, required) — Absolute path to the file inside the execution environment
- `name` (string, required) — Human-readable file name (stem, without extension)
- `mime_type` (string, required) — MIME type of the file
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `file_id` (string, optional, nullable) — Base64url-encoded storage file ID used to download the file via the files API

### ResourceLinkBlock

Reference to an external resource by URI (not embedded).

- `type` ("resource_link", required) — type field.
- `uri` (string, required) — URI of the external resource
- `name` (string, required) — Human-readable resource name
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `description` (string, optional, nullable) — description field.
- `mime_type` (string, optional, nullable) — mime type field.

### ResourceBlock

Embedded resource with metadata.

- `type` ("resource", required) — type field.
- `resource` (Resource, required) — Embedded resource metadata
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.

### SourceBlock

Document chunks surfaced as RAG context attribution.

- `type` ("source", required) — type field.
- `sources` (list of SourceBlockSourcesItems, required) — Document chunks used as context for this response
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.

### ThinkingBlock

Extended thinking block containing the model's reasoning process.

- `type` ("thinking", required) — type field.
- `signature` (string, required) — Anthropic reasoning signature required for extended thinking compatibility
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (ThinkingBlockCacheControl, optional, nullable) — cache control field.
- `thinking` (string, optional, default: ) — Thinking payload
- `citations` (list of ZylonCitation, optional, nullable, default: []) — citations field.

### RedactedThinkingBlock

Redacted thinking block returned when thinking content is encrypted.

- `type` ("redacted_thinking", required) — type field.
- `data` (string, required) — Encrypted thinking payload
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (RedactedThinkingBlockCacheControl, optional, nullable) — cache control field.

### ToolUseBlock

Represents a model-initiated tool call.

- `type` ("tool_use", required) — type field.
- `id` (string, required) — Unique identifier for this tool use
- `name` (string, required) — Name of the tool being called
- `input` (map from string to any, required) — Input payload for the tool call
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (ToolUseBlockCacheControl, optional, nullable) — cache control field.
- `caller` (ToolUseBlockCaller, optional, nullable) — caller field.

### ServerToolUseBlock

Represents a server-side (built-in) tool call initiated by the model.

- `type` ("server_tool_use", required) — type field.
- `id` (string, required) — Unique identifier for this server tool use
- `name` (enum, required) — Name of the server tool being called
  - Allowed values: `web_search`, `web_fetch`, `code_execution`, `bash_code_execution`, `text_editor_code_execution`, `tool_search_tool_regex`, `tool_search_tool_bm25`
- `input` (map from string to any, required) — Input payload for the server tool call
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (ServerToolUseBlockCacheControl, optional, nullable) — cache control field.
- `caller` (ServerToolUseBlockCaller, optional, nullable) — caller field.

### ContainerUploadBlock

References a file that was uploaded to an Anthropic container.

- `type` ("container_upload", required) — type field.
- `file_id` (string, required) — Container file identifier
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (ContainerUploadBlockCacheControl, optional, nullable) — cache control field.

### DocumentBlock

Anthropic document block (used for document-grounded generation).

- `type` ("document", required) — type field.
- `source` (DocumentBlockSource, required) — Document source payload
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (DocumentBlockCacheControl, optional, nullable) — cache control field.
- `title` (string, optional, nullable) — title field.
- `context` (string, optional, nullable) — context field.
- `citations` (list of ZylonCitation, optional, nullable) — citations field.

### SearchResultBlock

Anthropic search result block.

- `type` ("search_result", required) — type field.
- `source` (string, required) — Search result source payload
- `title` (string, required) — Search result title
- `content` (list of TextBlock, required) — Search result content
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (SearchResultBlockCacheControl, optional, nullable) — cache control field.
- `citations` (list of ZylonCitation, optional, nullable) — citations field.

### MidConvSystemBlock

System instructions injected at a specific point mid-conversation.

- `type` ("mid_conv_system", required) — type field.
- `content` (list of TextBlock, required) — System instruction text blocks.
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `cache_control` (MidConvSystemBlockCacheControl, optional, nullable) — cache control field.

### TLDRBlock

Condensed summary block.

- `type` ("tldr", required) — type field.
- `start_timestamp` (datetime, optional, nullable) — start timestamp field.
- `stop_timestamp` (datetime, optional, nullable) — stop timestamp field.
- `_meta` (map from string to any, optional) — meta field.
- `content` (list of TldrBlockContentItems, optional) — content field.
- `tldr_side` (enum, optional, default: left) — tldr side field.
  - Allowed values: `left`, `right`

### TextBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### ZylonCitation

ZylonCitation represents a citation in the Zylon format.

- `id` (string, optional, nullable) — Unique identifier for the citation
- `index` (integer, optional, nullable) — Index of the citation in the document
- `artifact_id` (string, optional, nullable) — Identifier of the artifact associated with the citation
- `source_id` (string, optional, nullable) — Identifier of the source document from which the citation is derived

### ImageBlockSource

Anthropic image source payload

- `type`: `base64` (Base64ImageSource)
  - `data` (string, required) — Base64-encoded image bytes
  - `media_type` (enum, required) — media type field.
    - Allowed values: `image/jpeg`, `image/png`, `image/gif`, `image/webp`
- `type`: `url` (URLSource)
  - `url` (string, required) — Publicly reachable URL

### ImageBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### AudioBlockSource

Audio source payload

- `type`: `base64` (Base64AudioSource)
  - `data` (string, required) — Base64-encoded audio bytes
  - `media_type` (string, required) — Audio MIME type, e.g. 'audio/mpeg'
- `type`: `url` (URLSource)
  - `url` (string, required) — Publicly reachable URL

### AudioBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### BinaryBlockSource

Binary source payload

- `type`: `base64` (Base64BinarySource)
  - `data` (string, required) — Base64-encoded binary data
  - `media_type` (string, required) — MIME type, e.g. 'application/pdf'
- `type`: `url` (url)

### Resource

Resource schema.

- `uri` (string, required) — uri field.
- `name` (string, required) — name field.
- `description` (string, optional, nullable) — description field.
- `mime_type` (string, optional, nullable) — mime type field.

### SourceBlockSourcesItems

### ThinkingBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### RedactedThinkingBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### ToolUseBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### ToolUseBlockCaller

caller field.

- `type`: `code_execution_20250825` (ServerToolCaller)
  - `tool_id` (string, required) — Server tool identifier.
- `type`: `code_execution_20260120` (ServerToolCaller20260120)
  - `tool_id` (string, required) — Server tool identifier.
- `type`: `direct` (DirectCaller)

### ServerToolUseBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### ServerToolUseBlockCaller

caller field.

- `type`: `code_execution_20250825` (ServerToolCaller)
  - `tool_id` (string, required) — Server tool identifier.
- `type`: `code_execution_20260120` (ServerToolCaller20260120)
  - `tool_id` (string, required) — Server tool identifier.
- `type`: `direct` (DirectCaller)

### ContainerUploadBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### DocumentBlockSource

Document source payload

- `type`: `base64` (Base64Source)
  - `data` (string, required) — data field.
  - `media_type` (string, required) — media type field.
- `type`: `content` (content)
- `type`: `text` (PlainTextSource)
  - `data` (string, required) — data field.
  - `media_type` ("text/plain", required) — media type field.
- `type`: `url` (URLDocumentSource)
  - `url` (string, required) — url field.

### DocumentBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### SearchResultBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### MidConvSystemBlockCacheControl

cache control field.

- `type`: `ephemeral` (CacheControlEphemeral)
  - `ttl` (enum, optional, default: 5m) — ttl field.
    - Allowed values: `5m`, `1h`

### TldrBlockContentItems

### Chunk

Represents a chunk of text content from an ingested document.

- `object` ("context.chunk", required) — Object type identifier, always 'context.chunk' for chunk responses
- `score` (double, required) — Relevance score indicating how well this chunk matches the query (0.0 to 1.0, higher is better)
- `document` (IngestedDoc, required) — Reference to the parent document containing metadata and ingestion information
- `text` (string, required) — The actual text content of the chunk extracted from the document
- `id` (string, optional, nullable) — Unique identifier for the chunk within the document
- `content_type` (string, optional, default: text/plain) — MIME type indicating the format of the chunk content
- `previous_texts` (list of string, optional, nullable) — List of text chunks that appear before this chunk in the document, providing preceding context
- `next_texts` (list of string, optional, nullable) — List of text chunks that appear after this chunk in the document, providing following context
- `metadata` (map from string to any, optional, nullable) — Additional metadata about the chunk including positioning information and document properties

### Website

Represents a website URL source.

- `id` (string, required) — Unique identifier for the website source
- `object` ("context.website", required) — Object type identifier, always 'context.website' for website sources
- `url` (string, required) — The URL of the website
- `favicon_url` (string, optional, nullable) — The URL of the website's favicon
- `title` (string, optional, nullable) — The title of the website or webpage
- `description` (string, optional, nullable) — A brief description or summary of the website content
- `metadata` (map from string to any, optional, nullable) — Additional metadata about the website source
- `content_type` (string, optional, nullable) — MIME type indicating the format of the website content
- `content` (string, optional, nullable) — The actual text content extracted from the website

### IngestedDoc

Represents a document that has been ingested into the system.

- `artifact` (string, required) — Unique identifier for the ingested document artifact.
- `object` ("ingest.document", optional, default: ingest.document) — Type of the object, indicating this is an ingested document.
- `doc_metadata` (map from string to any, optional, nullable) — Metadata associated with the ingested document, such as title, author, and other

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "data": [
    {
      "artifact_id": "annual_report_2023",
      "content": [
        {
          "text": "ANNUAL REPORT 2023\n\nExecutive Summary\n\nFiscal year 2023 marked a transformative period for our organization with record-breaking performance across all key metrics.",
          "type": "text"
        },
        {
          "text": "Revenue Analysis\n\nTotal revenue reached $12.4M, representing a 34% increase year-over-year. Growth was driven primarily by enterprise customer acquisition and subscription renewals.",
          "type": "text"
        }
      ]
    },
    {
      "artifact_id": "quarterly_summary_q4",
      "content": [
        {
          "text": "Q4 QUARTERLY SUMMARY\n\nQuarter Overview\n\nThe fourth quarter concluded our strongest year on record, with significant achievements in customer satisfaction and operational efficiency.",
          "type": "text"
        }
      ]
    }
  ]
}
```

**SDK Code**

```python Complete documents split into chat chunks
import requests

url = "https://api.example.com/v1/artifacts/chunked-content"

payload = {}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Complete documents split into chat chunks
const url = 'https://api.example.com/v1/artifacts/chunked-content';
const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}'};

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

```go Complete documents split into chat chunks
package main

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

func main() {

	url := "https://api.example.com/v1/artifacts/chunked-content"

	payload := strings.NewReader("{}")

	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 Complete documents split into chat chunks
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/chunked-content")

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 = "{}"

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

```java Complete documents split into chat chunks
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/chunked-content")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php Complete documents split into chat chunks
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/chunked-content', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Complete documents split into chat chunks
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/chunked-content");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Complete documents split into chat chunks
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/chunked-content")! 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()
```