Documents

Documents #

The documents endpoint allows you to view and download any documents that fit the parameters passed. Types of documents generated from Alpaca can be Account Monthly Statements and Trade Confirmations.


The Document Object #

Sample Object #

{
  "id": "904837e3-3b76-47ec-b432-046db621571b",
  "type": "account_statement",
  "date": "2020-01-15"
}

Attributes #

Attribute Type Notes
document_id string.UUID The UUID of the document
document_type string ENUM: account_statement or trade_confirmation
document_date string.date format: “2020-01-01”

Uploading a Document #

POST /v1/accounts/{account_id}/documents/upload

Upload a document to be attached to an account.

Documents are binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB.

Request #

Sample Request #

[
  {
    "document_type": "cip_result",
    "content": "VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=",
    "mime_type": "application/pdf"
  },
  {
    "document_type": "identity_verification",
    "document_sub_type": "passport",
    "content": "QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=",
    "mime_type": "image/jpeg"
  }
]

Parameters #

Key Value Requirement
document_upload models.DocumentUpload
Required

Response #

204 - No Content

Error Codes #

400 - Bad Request

The body in the request is not valid

404 - Not Found

No account was for this account_id


Retrieving Documents for One Account #

GET /v1/accounts/{account_id}/documents

This endpoint allows you to query all the documents that belong to a certain account. You can filter by date, or type of document.

Request #

Sample Request #

{
  "start": "2020-01-01",
  "end": "2020-01-31",
  "type": "account_statement"
}

Parameters #

Attribute Type Requirement Notes
start_date string
Optional
format: 2020-01-01
end_date string
Optional
format: 2020-01-01
document_type string
Optional
ENUM: account_statement or trade_confirmation

Response #

Returns the document model.

Error Codes #

401 - Not Authorized: Invalid Credentials

Downloading a Document #

GET /v1/accounts/{account_id}/documents/{document_id}/download

This endpoint allows you to download a document identified by the document_id passed in the header. The returned document is in PDF format.

Request #

N/A

Response #

301 - Redirects to a presigned download link for the document PDF.

Errors #

404 - Document Not Found

Retrieving a Document by ID #

GET /v1/accounts/{account_id}/documents/{document_id}

This endpoint allows you to call for a specific document and returns the document model.

Request #

N/A

Response #

Returns the document model.

Errors #

404 - Document Not Found