Documents API
For finding, creating and editing documents.
Documents list
Section titled “Documents list”/documents/List documentsReturns a paginated list of the documents you can see. Use page, page_size (maximum 200), q and sort to page, search and order the results. The X-Resource-Range header gives the range and total.
Response 200
Headers
Content-Type: application/jsonBody
[{ "id": 1, "title": "Soil Quality Report", "user": { "id": 1, "url": "https://{domain}/services/api/v1.x/users/1/", "first_name": "Jane", "last_name": "Doe", "country": "US" }, "url": "https://{domain}/services/api/v1.x/documents/1/", "url_html": "https://{domain}/document/1-soil-quality-report/", "url_download": "https://{domain}/document/1-soil-quality-report/download/", "first_published_at": null, "published_at": null, "extension": "pdf", "file_size": 4, "file_size_formatted": "4.0 B"}]/documents/Create documentNote that documents can only be created from sources with the data type document. Required fields are title, data.datasource (the URL of a datasource with the data type document) and either group or user (an ID; some sites only allow groups to own data). The document is published immediately, so there is no draft version after the create.
Request
Headers
Content-Type: application/jsonBody
{ "title": "Example Document", "group": 1, "data": { "datasource": "https://{domain}/services/api/v1.x/sources/5/datasources/1/" }}Response 201
Headers
Content-Type: application/jsonLocation: https://{domain}/services/api/v1.x/documents/2/Body: the document detail, as in Retrieve a document, plus a version object for the new version (id, url, created_at, created_by).
/documents/drafts/List document draftsLists the draft version of each document. If the most recent version of a document has already been published, it won’t appear here.
/documents/latest/List latest document versionsLists the latest version of each document that you can see: the draft version for documents you can administer, and the published version for all others.
Document detail
Section titled “Document detail”/documents/{id}/Retrieve a documentResponse 200
Headers
Content-Type: application/jsonBody
{ "id": 1, "title": "Soil Quality Report", "user": { "id": 1, "url": "https://{domain}/services/api/v1.x/users/1/", "first_name": "Jane", "last_name": "Doe", "country": "US" }, "url": "https://{domain}/services/api/v1.x/documents/1/", "url_html": "https://{domain}/document/1-soil-quality-report/", "url_download": "https://{domain}/document/1-soil-quality-report/download/", "first_published_at": null, "published_at": null, "extension": "pdf", "file_size": 4, "file_size_formatted": "4.0 B", "description": "The soil quality report provides detailed information about soil conditions.", "description_html": "<p>The soil quality report provides detailed information about soil conditions.</p>", "published_version": "https://{domain}/services/api/v1.x/documents/1/versions/1/", "latest_version": "https://{domain}/services/api/v1.x/documents/1/versions/1/", "this_version": "https://{domain}/services/api/v1.x/documents/1/versions/1/", "data": { "datasource": "https://{domain}/services/api/v1.x/sources/5/datasources/1/" }, "categories": [], "tags": [], "license": null, "metadata": null, "permissions": "https://{domain}/services/api/v1.x/documents/1/permissions/", "publish_to_catalog_services": false}/documents/{id}/Delete a documentDeletes the document and all its versions.
Response 204
Document versions
Section titled “Document versions”/documents/{id}/versions/List document versionsResponse 200
Body
[{ "id": 2, "url": "https://{domain}/services/api/v1.x/documents/2/versions/2/", "created_at": "2015-04-12T21:43:59.200Z", "created_by": { "id": 1, "url": "https://{domain}/services/api/v1.x/users/1/", "first_name": "Jane", "last_name": "Doe", "country": "US" }}]/documents/{id}/versions/Create document versionCreates a draft version of the document, copying the latest version. Returns 201 with a Location header for the new version and the document detail in the body. If the document already has a draft, returns 409 with {"already-exists": "This document already has a draft version"}.
Document version detail
Section titled “Document version detail”/documents/{id}/versions/{version}/Retrieve document version/documents/{id}/versions/{version}/Update document versionEdits a draft version (for example title or description). Returns 200 with the document detail, or 405 with {"not-draft": "This version isn't a draft, so you can't edit it"} if the version has been published.
/documents/{id}/versions/{version}/Delete document versionDeletes this draft version (revert to published).
Response 204
No body.
Response 405
Headers
Content-Type: application/jsonBody
{"not-draft": "This version isn't a draft, so you can't delete it"}Document version publishing
Section titled “Document version publishing”/documents/{id}/versions/{version}/publish/Publish document versionNo POST data. Returns 201 with a publish object and a Location header pointing at it.
/documents/{id}/versions/publish/Create and publish document versionCreates a new version of the document and publishes it immediately. If the document already has a draft version, a 409 response is returned with {"already-exists": "This document already has a draft version"}.