The Documents API provides a simple interface to manage documents. You can retrieve a single document as well as a list of documents attached to the specific resource.

JSON format

NameRead OnlyTypeDescription
idtruenumberUnique identifier of the document.
resource_typetruestringType name of the resource the document is attached to. Possible values: "lead", "contact", "sales_account", "deal"
resource_idtruenumberUnique identifier of the resource the document is attached to.
creator_idtruenumberUnique identifier of the user who uploaded the document.
nametruestringFilename of the document.
content_typetruestringMIME type of the document. eg. application/pdf
sizetruenumberSize of the document in bytes.
download_urltruestringAn expiring URL to download document. It will expire after 90 minutes.
created_attruestringDate and time of creation in UTC (ISO8601 format).
updated_attruestringDate and time of the last update in UTC (ISO8601 format).

Retrieve documents

GET /v2/documents

Returns all docuements attached to the specific resource, according to the parameters provided.

Parameters

NameRequiredTypeInDescription
resource_typetruestringQueryComma-separated list of names of the type of resource to search for. Possible values:"lead", "contact", "sales_account", "deal"
resource_idtruenumberQueryComma-separated list of unique identifiers of the resource to search for.
pagefalsenumberQueryPage number to start from. Page numbering starts at 1, and omitting the page parameter will return the first page.
per_pagefalsenumberQueryNumber of records to return per page. The default limit is 25 and the maximum number that can be returned at one time is 100.
sort_byfalsestringQueryA field to sort by. Default ordering is ascending. If you want to change the sort ordering to descending, append :desc to the field e.g. sort_by=created_at:desc. Possible values: "id", "created_at", "updated_at"
idsfalsestringQueryComma-separated list of document IDs to be returned in a request.
namefalsestringQueryFilename of the document.

Allowed for

  • Agents

Using cURL

curl -v -X GET https://api.getbase.com/v2/documents?resource_type=deal,contact&resource_id=5,6 \-H "Accept: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN"

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "items": [    {      "data": {        "id": 1242633,        "resource_type": "deal",        "resource_id": 5,        "creator_id": 12345,        "name": "My Fancy File.pdf",        "content_type": "application/pdf",        "size": 22715,        "download_url": "https://s3.amazonaws.com/uploads.futuresimple.com/uploads/345/456433/86a26727-3a84-415d-915c-a683842e198d?AWSAccessKeyId=XXX&Expires=1525786253&Signature=ZZZ&response-content-disposition=attachment%3B%20filename%2A%3D%20UTF-8%27%27MyFancyFile.pdf&response-content-type=application%2Fpdf",        "created_at": "2014-08-27T16:32:56Z",        "updated_at": "2014-08-27T17:32:56Z"      },      "meta": {        "type": "document"      }    },    {      "data": {        "id": 1332633,        "resource_type": "deal",        "resource_id": 6,        "creator_id": 12345,        "name": "My Super Fancy File.pdf",        "content_type": "application/pdf",        "size": 22715,        "download_url": "https://s3.amazonaws.com/uploads.futuresimple.com/uploads/345/456433/86a26727-3a84-415d-915c-a683842e198d?AWSAccessKeyId=XXX&Expires=1525786253&Signature=ZZZ&response-content-disposition=attachment%3B%20filename%2A%3D%20UTF-8%27%27MySuperFancyFile.pdf&response-content-type=application%2Fpdf",        "created_at": "2014-08-27T16:32:56Z",        "updated_at": "2014-08-27T17:32:56Z"      },      "meta": {        "type": "document"      }    },    {      "data": {        "id": 22652633,        "resource_type": "contact",        "resource_id": 6,        "creator_id": 12345,        "name": "Another Fancy File for contact.pdf",        "content_type": "application/pdf",        "size": 22715,        "download_url": "https://s3.amazonaws.com/uploads.futuresimple.com/uploads/345/456433/86a26727-3a84-415d-915c-a683842e198d?AWSAccessKeyId=XXX&Expires=1525786253&Signature=ZZZ&response-content-disposition=attachment%3B%20filename%2A%3D%20UTF-8%27%27AnotherMyFancyFileforcontact.pdf&response-content-type=application%2Fpdf",        "created_at": "2014-08-27T16:32:56Z",        "updated_at": "2014-08-27T17:32:56Z"      },      "meta": {        "type": "document"      }    }  ],  "meta": {    "type": "collection",    "count": 3,    "links": {      "self": "https://api.getbase.com/v2/documents?resource_type=deal,contact&resource_id=5,6"    }  }}

Retrieve a single document

Returns a single document available to the user, according to the unique document ID provided. If the docuemnt ID does not exist, this request will return an error.

To download file content, use the link provided in request response:

curl -o "[data.name]" -O "[data.download_url]"

Parameters

NameRequiredTypeInDescription
idtruenumberQueryUnique identifier of the document.

Allowed for

  • Agents

Using cURL

curl -v -X GET https://api.getbase.com/v2/documents/1 \-H "Accept: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN"

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "data": {    "id": 1242633,    "resource_type": "deal",    "resource_id": 5,    "creator_id": 12345,    "name": "My Fancy File.pdf",    "content_type": "application/pdf",    "size": 22715,    "download_url": "https://s3.amazonaws.com/uploads.futuresimple.com/uploads/345/456433/86a26727-3a84-415d-915c-a683842e198d?AWSAccessKeyId=XXX&Expires=1525786253&Signature=ZZZ&response-content-disposition=attachment%3B%20filename%2A%3D%20UTF-8%27%27MyFancyFile.pdf&response-content-type=application%2Fpdf",    "created_at": "2014-08-27T16:32:56Z",    "updated_at": "2014-08-27T17:32:56Z"  },  "meta": {    "type": "document"  }}