HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

Upload documents into Layar

Uploading a document

To upload a document, we'll be using the Source Document API to add a document to the Layar data fabric.

The first step is to upload the document to the Layar API

curl 'https://YOUR_SERVER_HERE/layar/sourceDocument' \
-X POST \
-H 'Authorization: Bearer YOUR_TOKEN_HERE' \
-F 'name=filename.pdf' \
-F '[email protected]/to/local/file/filename.pdf'

The response of the document upload will contain an ID that you can use to reference the document in the future. In the example below, the ID is AYXGsE6FbZ95yV31x8iZ

{
    "cortexDocumentType": "DOCUMENT",
    "createdByUser": 25001,
    "id": "AYXGsE6FbZ95yV31x8iZ",
    "metadata": {},
    "mimeType": "application/pdf",
    "name": "filename.pdf"
}

Processing of documents after upload is an asynchronous process. You can monitor the status of the uploaded document by calling the Source Document Status API using the ID returned above (e.g. in this instance it's AYXGsE6FbZ95yV31x8iZ)

curl -X GET 'https://YOUR_SERVER_HERE/layar/sourceDocument/AYXGsE6FbZ95yV31x8iZ/status'
-H 'Accept: application/json' 
-H 'Authorization: Bearer YOUR_TOKEN_HERE'

As the document is processed, the API will return with a status of Processing

{
  "percent":75,
  "message":"Processing..."
}

Once the document is uploaded and ready for querying and use in the data fabric, the status will change to 100% and the message will read Complete

{
  "percent":100,
  "message":"Complete!"
}