3. Uploading Documents


This section describes how to send documents to the API. Uploading documents requires authentication so be sure to go back and read that section if you haven’t already.

Sending Binary Content

The API accepts Content-type: application/octet-stream for sending full documents. The documents must be sent directly in the POST body with no padding or structure around it.

The endpoint for sending a new document is POST /documents.

Example

POST https://api.innodata.com/v1.1/documents
Content-type: application/octet-stream
Authorization: Basic dXNlci1saXZlLTYzMmE1YTYzLWQ2ZDYtNDI0Ni05MWNhLWQ1NDY2MzI2OThkMzo=
X-Name: My file.pdf
X-Type: application/pdf
Body:
...BINARY CONTENTS...

Response:
{
  "success": true,
  "status_code": 201,
  "tracking": "05732019-889d-4b43-8049-cf0dfe3c0d34",
  "response":{
    "contents_uri": "https://api.innodata.com/v1.1/documents/f7afca0f-cd88-465a-bdac-421f7ada07fe/contents",
    "id": "f7afca0f-cd88-465a-bdac-421f7ada07fe",
    "name": "My file.pdf",
    "owner": {
      "email": "me@example.com",
      "id": "5a2e5257-404d-4aaf-86c4-b1c2a1ff886b",
      "name": "My Name Goes Here"
    },
    "size": 2358568,
    "type": "application/pdf"
  }
}

Sending documents with cURL

When using the cURL command line client, be sure to use the flag --data-binary when sending documents.

Don’t forget the Content-type header!

Example

$> curl \
-X POST \
-u "user-live-632a5a63-d6d6-4246-91ca-d546632698d3:" \
-H "Content-type: application/octet-stream" \
-H "X-name: My file.pdf" \
-H "X-type: application/pdf" \
--data-binary @"My file.pdf" \
https://api.innodata.com/v1.1/documents

Document Fields

Here are a few of the document properties:

  • id — a string field containing a unique identifier (UUID format) for the document.
  • name — a string field containing a human readable name identifying the document.
  • size — an integer field counting the size of the content in bytes.
  • type — a string field containing a mime type for the document.
  • contents_uri — a string field containing the URI where you can fetch or update the document. When creating a job from an uploaded document, send this field as the content's uri.