Documents
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
Name | Read Only | Type | Description |
---|---|---|---|
id | true | number | Unique identifier of the document. |
resource_type | true | string | Type name of the resource the document is attached to. Possible values: "lead", "contact", "sales_account", "deal" |
resource_id | true | number | Unique identifier of the resource the document is attached to. |
creator_id | true | number | Unique identifier of the user who uploaded the document. |
name | true | string | Filename of the document. |
content_type | true | string | MIME type of the document. eg. application/pdf |
size | true | number | Size of the document in bytes. |
download_url | true | string | An expiring URL to download document. It will expire after 90 minutes. |
created_at | true | string | Date and time of creation in UTC (ISO8601 format). |
updated_at | true | string | Date 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
Name | Required | Type | In | Description |
---|---|---|---|---|
resource_type | true | string | Query | Comma-separated list of names of the type of resource to search for. Possible values:"lead", "contact", "sales_account", "deal" |
resource_id | true | number | Query | Comma-separated list of unique identifiers of the resource to search for. |
page | false | number | Query | Page number to start from. Page numbering starts at 1, and omitting the page parameter will return the first page. |
per_page | false | number | Query | Number 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_by | false | string | Query | A 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" |
ids | false | string | Query | Comma-separated list of document IDs to be returned in a request. |
name | false | string | Query | Filename 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-8
Content-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
Name | Required | Type | In | Description |
---|---|---|---|---|
id | true | number | Query | Unique 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-8
Content-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"
}
}