---
title: Get Document
slug: fourkites-api-reference/get-document
description: This document provides an overview of an API that enables customers to effortlessly access and retrieve specific documents based on load numbers or stops. The API returns a secure Base64 image string of the requested document, granting a validity period o
icon: {"apiMethod":"GET"}
createdAt: 2023-04-14T05:21:41.000Z
---

This API is for the customers to get the documents for their load number/stop. It should provide Base64 image string for document. The validity of image should be applicable for 1 year. If any customer is licensed for Document storage, additional years validity should be provided by API to that customer.

:::ApiMethodV2
```json
{
  "name": "Production",
  "method": "GET",
  "url": "https://api.fourkites.com/document-data",
  "description": "",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "99rucZZAt55KtGbP0cSMa",
        "language": "curl",
        "code": "curl --request GET 'https://api.fourkites.com/document-data' \\\n--header 'Content-Type: application/json' \\\n--header 'apikey: REPLACE_KEY_VALUE'\n",
        "customLabel": ""
      },
      {
        "id": "bVB8VuUp5NdcT9DUbElIn",
        "language": "java",
        "code": "OkHttpClient client = new OkHttpClient().newBuilder()\n  .build();\nMediaType mediaType = MediaType.parse(\"application/json\");\nRequestBody body = RequestBody.create(mediaType, \"\");\nRequest request = new Request.Builder()\n  .url(\"https://api.fourkites.com/document-data\")\n  .method(\"GET\", body)\n  .addHeader(\"Content-Type\", \"application/json\")\n  .addHeader(\"apikey\", \"REPLACE_KEY_VALUE\")\n  .build();\nResponse response = client.newCall(request).execute();\n",
        "customLabel": ""
      },
      {
        "id": "RzayVHa-lTOWhAwiM-V-w",
        "language": "javascript",
        "code": "var settings = {\n  \"url\": \"https://api.fourkites.com/document-data\",\n  \"method\": \"GET\",\n  \"timeout\": 0,\n  \"headers\": {\n    \"Content-Type\": \"application/json\",\n    \"apikey\": \"REPLACE_KEY_VALUE\"\n  },\n};\n\n$.ajax(settings).done(function (response) {\n  console.log(response);\n});\n",
        "customLabel": ""
      },
      {
        "id": "FXTLEGHbRCE35oR6egZnN",
        "language": "swift",
        "code": "import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n\nvar semaphore = DispatchSemaphore (value: 0)\n\nvar request = URLRequest(url: URL(string: \"https://api.fourkites.com/document-data\")!,timeoutInterval: Double.infinity)\nrequest.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\nrequest.addValue(\"REPLACE_KEY_VALUE\", forHTTPHeaderField: \"apikey\")\n\nrequest.httpMethod = \"GET\"\n\nlet task = URLSession.shared.dataTask(with: request) { data, response, error in \n  guard let data = data else {\n    print(String(describing: error))\n    semaphore.signal()\n    return\n  }\n  print(String(data: data, encoding: .utf8)!)\n  semaphore.signal()\n}\n\ntask.resume()\nsemaphore.wait()\n",
        "customLabel": ""
      },
      {
        "id": "fVeXL9ar25OAIFFLPCHcm",
        "language": "csharp",
        "code": "import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n\nvar semaphore = DispatchSemaphore (value: 0)\n\nvar request = URLRequest(url: URL(string: \"https://api.fourkites.com/document-data\")!,timeoutInterval: Double.infinity)\nrequest.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\nrequest.addValue(\"REPLACE_KEY_VALUE\", forHTTPHeaderField: \"apikey\")\n\nrequest.httpMethod = \"GET\"\n\nlet task = URLSession.shared.dataTask(with: request) { data, response, error in \n  guard let data = data else {\n    print(String(describing: error))\n    semaphore.signal()\n    return\n  }\n  print(String(data: data, encoding: .utf8)!)\n  semaphore.signal()\n}\n\ntask.resume()\nsemaphore.wait()\n",
        "customLabel": ""
      },
      {
        "id": "SadeGaXl6-VaIenJ92Cms",
        "language": "go",
        "code": "package main\n\nimport (\n  \"fmt\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n\n  url := \"https://api.fourkites.com/document-data\"\n  method := \"GET\"\n\n  client := &http.Client {\n  }\n  req, err := http.NewRequest(method, url, nil)\n\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  req.Header.Add(\"Content-Type\", \"application/json\")\n  req.Header.Add(\"apikey\", \"REPLACE_KEY_VALUE\")\n\n  res, err := client.Do(req)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  defer res.Body.Close()\n\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  fmt.Println(string(body))\n}\n",
        "customLabel": ""
      },
      {
        "id": "aFCulRsR1GW_R32h_kWxz",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fourkites.com/document-data\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"Content-Type\"] = \"application/json\"\nrequest[\"apikey\"] = \"REPLACE_KEY_VALUE\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      },
      {
        "id": "c59jSqcZ5RW-GSNshsaYF",
        "language": "python",
        "code": "import http.client\nimport json\n\nconn = http.client.HTTPSConnection(\"api.fourkites.com\")\npayload = ''\nheaders = {\n  'Content-Type': 'application/json',\n  'apikey': 'REPLACE_KEY_VALUE'\n}\nconn.request(\"GET\", \"/document-data\", payload, headers)\nres = conn.getresponse()\ndata = res.read()\nprint(data.decode(\"utf-8\"))\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "99rucZZAt55KtGbP0cSMa"
  },
  "results": {
    "languages": [
      {
        "id": "DQowC88lMQxqZXBP1Bdzs",
        "language": "200",
        "code": "[\n  {\n    \"base64_content\": \"contentxyz==\",\n    \"type\": \"pdf\",\n    \"name\": \"doc.pdf\"\n  },\n  {\n    \"base64_content\": \"contentabc==\",\n    \"type\": \"jpeb\",\n    \"name\": \"image.jpeg\"\n  }\n]\n",
        "customLabel": ""
      },
      {
        "id": "iR2uqrlXMbwY9a3Chrgdu",
        "language": "400",
        "code": "{\n    \"status\": \"BAD_REQUEST\",\n    \"timestamp\": 1688970099233,\n    \"message\": \"Validation Errors\",\n    \"sub_errors\": [\n        {\n            \"field\": \"stopIdentifier\",\n            \"message\": \"stop identifier must be one of stopReferenceId, stopSequence, locationId or stopId\",\n            \"reject_value\": \"stopSequence1\"\n        },\n        {\n            \"field\": \"documentType\",\n            \"message\": \"accepted values for document_type are BLD (Bill of Lading-Driver), PSD (Packing Slip-Driver), BL (Bill of Lading), PS (Packing Slip), CD (Customs Document), DR (Delivery Receipt/Proof of Delivery), IV (Invoice), WC (Weight & Inspection Certificates), WI (Weight & Inspection), WP (Weight & Research Picture), FB (Freight Bill), PO (Purchase order), OD (Overages, Shortages and Damages), FA (Fuel Advance) or LR (Lumper Receipt)\",\n            \"reject_value\": \"PSD1\"\n        },\n        {\n            \"field\": \"loadIdentifier\",\n            \"message\": \"load identifier must be one of loadNumber, proNumber, trackingNumber or loadReferenceNumber\",\n            \"reject_value\": \"loadNumber1\"\n        }\n    ]\n}\n",
        "customLabel": ""
      },
      {
        "id": "q7V5oQsSDuqC9ZM6Fla4O",
        "language": "404",
        "code": "{\n    \"error_message\": \"404 Could not find document using provided parameters.\"\n}\n",
        "customLabel": ""
      },
      {
        "id": "9u3uZKD4NFu17xjnMBOy8",
        "language": "413",
        "code": "{ \"error_message\": \"Too many documents (120) to return in one response; the maximum is 50. Instead of all_stops=true, request documents one stop at a time using stop_identifier and stop_value.\" }"
      }
    ],
    "selectedLanguageId": "DQowC88lMQxqZXBP1Bdzs"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "production",
  "legacyHash": "lIaeWVDGt24sPsuQ3rBos"
}
```
:::

:::ApiMethodV2
```json
{
  "name": "Staging",
  "method": "GET",
  "url": "https://api-staging.fourkites.com/document-data",
  "description": "",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "99rucZZAt55KtGbP0cSMa",
        "language": "curl",
        "code": "curl --request GET 'https://api-staging.fourkites.com/document-data' \\\n--header 'Content-Type: application/json' \\\n--header 'apikey: REPLACE_KEY_VALUE'\n",
        "customLabel": ""
      },
      {
        "id": "bVB8VuUp5NdcT9DUbElIn",
        "language": "java",
        "code": "OkHttpClient client = new OkHttpClient().newBuilder()\n  .build();\nMediaType mediaType = MediaType.parse(\"application/json\");\nRequestBody body = RequestBody.create(mediaType, \"\");\nRequest request = new Request.Builder()\n  .url(\"https://api-staging.fourkites.com/document-data\")\n  .method(\"GET\", body)\n  .addHeader(\"Content-Type\", \"application/json\")\n  .addHeader(\"apikey\", \"REPLACE_KEY_VALUE\")\n  .build();\nResponse response = client.newCall(request).execute();\n",
        "customLabel": ""
      },
      {
        "id": "RzayVHa-lTOWhAwiM-V-w",
        "language": "javascript",
        "code": "var settings = {\n  \"url\": \"https://api-staging.fourkites.com/document-data\",\n  \"method\": \"GET\",\n  \"timeout\": 0,\n  \"headers\": {\n    \"Content-Type\": \"application/json\",\n    \"apikey\": \"REPLACE_KEY_VALUE\"\n  },\n};\n\n$.ajax(settings).done(function (response) {\n  console.log(response);\n});\n",
        "customLabel": ""
      },
      {
        "id": "FXTLEGHbRCE35oR6egZnN",
        "language": "swift",
        "code": "import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n\nvar semaphore = DispatchSemaphore (value: 0)\n\nvar request = URLRequest(url: URL(string: \"https://api-staging.fourkites.com/document-data\")!,timeoutInterval: Double.infinity)\nrequest.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\nrequest.addValue(\"REPLACE_KEY_VALUE\", forHTTPHeaderField: \"apikey\")\n\nrequest.httpMethod = \"GET\"\n\nlet task = URLSession.shared.dataTask(with: request) { data, response, error in \n  guard let data = data else {\n    print(String(describing: error))\n    semaphore.signal()\n    return\n  }\n  print(String(data: data, encoding: .utf8)!)\n  semaphore.signal()\n}\n\ntask.resume()\nsemaphore.wait()\n",
        "customLabel": ""
      },
      {
        "id": "fVeXL9ar25OAIFFLPCHcm",
        "language": "csharp",
        "code": "import Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n\nvar semaphore = DispatchSemaphore (value: 0)\n\nvar request = URLRequest(url: URL(string: \"https://api-staging.fourkites.com/document-data\")!,timeoutInterval: Double.infinity)\nrequest.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\nrequest.addValue(\"REPLACE_KEY_VALUE\", forHTTPHeaderField: \"apikey\")\n\nrequest.httpMethod = \"GET\"\n\nlet task = URLSession.shared.dataTask(with: request) { data, response, error in \n  guard let data = data else {\n    print(String(describing: error))\n    semaphore.signal()\n    return\n  }\n  print(String(data: data, encoding: .utf8)!)\n  semaphore.signal()\n}\n\ntask.resume()\nsemaphore.wait()\n",
        "customLabel": ""
      },
      {
        "id": "SadeGaXl6-VaIenJ92Cms",
        "language": "go",
        "code": "package main\n\nimport (\n  \"fmt\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n\n  url := \"https://api-staging.fourkites.com/document-data\"\n  method := \"GET\"\n\n  client := &http.Client {\n  }\n  req, err := http.NewRequest(method, url, nil)\n\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  req.Header.Add(\"Content-Type\", \"application/json\")\n  req.Header.Add(\"apikey\", \"REPLACE_KEY_VALUE\")\n\n  res, err := client.Do(req)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  defer res.Body.Close()\n\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    fmt.Println(err)\n    return\n  }\n  fmt.Println(string(body))\n}\n",
        "customLabel": ""
      },
      {
        "id": "aFCulRsR1GW_R32h_kWxz",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api-staging.fourkites.com/document-data\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"Content-Type\"] = \"application/json\"\nrequest[\"apikey\"] = \"REPLACE_KEY_VALUE\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      },
      {
        "id": "c59jSqcZ5RW-GSNshsaYF",
        "language": "python",
        "code": "import http.client\nimport json\n\nconn = http.client.HTTPSConnection(\"api-staging.fourkites.com\")\npayload = ''\nheaders = {\n  'Content-Type': 'application/json',\n  'apikey': 'REPLACE_KEY_VALUE'\n}\nconn.request(\"GET\", \"/document-data\", payload, headers)\nres = conn.getresponse()\ndata = res.read()\nprint(data.decode(\"utf-8\"))\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "c59jSqcZ5RW-GSNshsaYF"
  },
  "results": {
    "languages": [
      {
        "id": "DQowC88lMQxqZXBP1Bdzs",
        "language": "200",
        "code": "[\n  {\n    \"base64_content\": \"contentxyz==\",\n    \"type\": \"pdf\",\n    \"name\": \"doc.pdf\"\n  },\n  {\n    \"base64_content\": \"contentabc==\",\n    \"type\": \"jpeb\",\n    \"name\": \"image.jpeg\"\n  }\n]\n",
        "customLabel": ""
      },
      {
        "id": "xwY0_Y60mPj4lsafIi_B7",
        "language": "400",
        "code": "{\n    \"status\": \"BAD_REQUEST\",\n    \"timestamp\": 1688970099233,\n    \"message\": \"Validation Errors\",\n    \"sub_errors\": [\n        {\n            \"field\": \"stopIdentifier\",\n            \"message\": \"stop identifier must be one of stopReferenceId, stopSequence, locationId or stopId\",\n            \"reject_value\": \"stopSequence1\"\n        },\n        {\n            \"field\": \"documentType\",\n            \"message\": \"accepted values for document_type are BLD (Bill of Lading-Driver), PSD (Packing Slip-Driver), BL (Bill of Lading), PS (Packing Slip), CD (Customs Document), DR (Delivery Receipt/Proof of Delivery), IV (Invoice), WC (Weight & Inspection Certificates), WI (Weight & Inspection), WP (Weight & Research Picture), FB (Freight Bill), PO (Purchase order), OD (Overages, Shortages and Damages), FA (Fuel Advance) or LR (Lumper Receipt)\",\n            \"reject_value\": \"PSD1\"\n        },\n        {\n            \"field\": \"loadIdentifier\",\n            \"message\": \"load identifier must be one of loadNumber, proNumber, trackingNumber or loadReferenceNumber\",\n            \"reject_value\": \"loadNumber1\"\n        }\n    ]\n}\n",
        "customLabel": ""
      },
      {
        "id": "kR5E9lEPtpCHUfa4CHOoG",
        "language": "404",
        "code": "{\n    \"error_message\": \"404 Could not find document using provided parameters.\"\n}\n",
        "customLabel": ""
      },
      {
        "id": "yWKUrI0EemYRppRHOL90f",
        "language": "413",
        "code": "{ \"error_message\": \"Too many documents (120) to return in one response; the maximum is 50. Instead of all_stops=true, request documents one stop at a time using stop_identifier and stop_value.\" }"
      }
    ],
    "selectedLanguageId": "DQowC88lMQxqZXBP1Bdzs"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "staging",
  "legacyHash": "TWGmfUB57r0tBBR9QNdMw"
}
```
:::

### Request Attributes

| Name             | Param Type | Format  | Required | Example                                                                                                                                                                                                                                                                                                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------- | ---------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| load\_identifier | Query      | String  | Yes      | loadNumber, proNumber, trackingNumber or loadReferenceNumber                                                                                                                                                                                                                                                                                                                                          | Returns results associated with the given load identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| load\_value      | Query      | String  | Yes      | NA                                                                                                                                                                                                                                                                                                                                                                                                    | Returns results associated with the given load value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| stop\_identifier | Query      | String  | No       | stopReferenceId, stopSequence, locationId or stopId (Defaults to last delivery stop if not provided)                                                                                                                                                                                                                                                                                                  | Returns results associated with the given stop identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| stop\_value      | Query      | String  | No       | Defaults to last delivery stop if not provided                                                                                                                                                                                                                                                                                                                                                        | Returns results associated with the given stop value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| all\_stops       | Query      | Boolean | No       | true or false (defaults to false)                                                                                                                                                                                                                                                                                                                                                                     | When <br />**true**<br />, returns documents of the given document\_type from all stops on the load (any stop\_identifier/stop\_value are ignored). When <br />**false**<br /> or omitted, only the last delivery stop is searched. Use it to fetch a document attached to a non-delivery stop (e.g. a POD on the pickup stop). If matches exceeds the server limit (50), the request is rejected with <br />413<br /> (see Sample <br />413<br />) - request one stop at a time using stop\_identifier/stop\_value instead. |
| document\_type   | Query      | String  | Yes      | BLD (Bill of Lading-Driver), PSD (Packing Slip-Driver), BL (Bill of Lading), PS (Packing Slip), CD (Customs Document), DR (Delivery Receipt/Proof of Delivery), IV (Invoice), WC (Weight & Inspection Certificates), WI (Weight & Inspection), WP (Weight & Research Picture), FB (Freight Bill), PO (Purchase order), OD (Overages, Shortages and Damages), FA (Fuel Advance) or LR (Lumper Receipt) | Returns results associated with the given document type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

### Response Attributes

Shipment

| Name            | Format                                                                                                                     | Default | Example      |
| --------------- | -------------------------------------------------------------------------------------------------------------------------- | ------- | ------------ |
| base64\_content | String - The base 64 encoded file content                                                                                  | NA      | AbFF7RgAAAA= |
| type            | String - The file extension. The following are the standardized file types: JPG, PNG, PDF, JPEG,TIFF, DOC, DOCX, XLS, XLSX | NA      | jpeg, pdf    |
| name            | String - The file name                                                                                                     | NA      | doc.pdf      |

