Skip to main content

Documents

Documents API provides a way to store and retrieve documents related to your program, profile, or an account.

Uploading a Document

Before a document can be uploaded, we need to generate a document ID that is related to an entity (program, profile, or account).

Below is an example of uploading a profile document.

POST /profiles/:profile_id/documents

{
"type": "USER_PHOTO"
}

Response:

{
"id": "ae89eb47-4a57-47e6-8b75-4f78e502ac03",
"type": "USER_PHOTO",
"created_dt": "2022-07-27T21:08:19.991939Z",
"status": "PENDING"
}

Once we have the generated document ID we can upload the document. The body of the request should be a multipart/form-data with the file field containing the file you want to upload.

POST /documents/:document_id/upload

Content-Type: multipart/form-data; boundary="boundary"

--boundary
Content-Disposition: form-data; name="file"

[file bytes]

Response:

{
"id": "ae89eb47-4a57-47e6-8b75-4f78e502ac03",
"is_uploaded": true,
"type": "USER_PHOTO"
}

Retrieving a Document

To get an uploaded document, you'll use the same document ID that was used to upload the document. The document's content will be returned as a stream with two additional response headers.

  • X-MD5
    • MD5 checksum of the document
  • X-Document-Type
    • The document's type such as USER_PHOTO, PASSPORT, etc.

The Accept header must be application/octet-stream.

GET /documents/:document_id

Response:

Binary stream