Publishing API
The Publishing API allows for draft versions of versioned objects - i.e. documents, layers and tables - to be scheduled for publishing together.
Publish tasks
Section titled “Publish tasks”/publish/List publish tasksReturns a list of publish tasks, newest first. Your key needs the layers:read scope.
The list supports page and page_size and returns the X-Resource-Range and Link headers described in Introducing the Admin API. An unrecognised state returns an empty list, not an error.
Parameters
Section titled “Parameters”- state:
string(optional). Returns Publish Tasks in the specified state. Valid Publish states are:waiting-for-items(versions are still importing),waiting-for-time,waiting-for-approval,publishing,cancelled,cancelled-due-to-error,errored,completed. - reference:
string(optional). Returns Publish Tasks with the specified reference.
Response 200
Headers
Content-Type: application/jsonBody
[ { "id": 123, "url": "https://{domain}/services/api/v1.x/publish/123/", "state": "waiting-for-items", "created_at": "2015-08-19T00:00:01.000000Z", "created_by": { "id": 3, "url": "https://{domain}/services/api/v1.x/users/3/", "first_name": "Bob", "last_name": "Jones", "country": "NZ", "geotag": "global/oceania/new-zealand" }, "error_strategy": "abort", "publish_strategy": "together", "publish_at": null, "items": [ "https://{domain}/services/api/v1.x/layers/4/versions/44/", "https://{domain}/services/api/v1.x/tables/5/versions/55/", "https://{domain}/services/api/v1.x/layers/6/versions/66/" ], "reference": "1234abcd" }]/publish/Create a new publish taskCreate a publish job for a number of draft layers/tables/documents. The items will be published when all the drafts are ready:
items: List of API URLs of draft versions to publish. At least one is required.
publish_at: Optional ISO 8601 date and time to hold the publish until (state waiting-for-time).
publish_strategy: One of: "manual", "together". Default = "together"
- The
togetherstrategy will publish all items once they have all finished importing/updating. - The
manualstrategy will publish all items once they have all finished importing/updating and have been approved by posting to/publish/{id}/approve/. error_strategy: One of:"abort","ignore". Default ="abort"- The
abortstrategy will leave all items in their draft state if one of them encounters an error during importing/updating. - The
ignorestrategy will publish any successful items and leave any errored items in their draft state
reference: Optional user-defined reference.
Request
Headers
Content-Type: application/jsonBody
{ "items": [ "https://{domain}/services/api/v1.x/tables/5/versions/456/", "https://{domain}/services/api/v1.x/layers/6/versions/789/" ], "publish_strategy": "together", "error_strategy": "abort", "reference": "1234abcd"}Response 201
Headers
Location: https://{domain}/services/api/v1.x/publish/456/Body: the publish task, as in Publish detail. Check its state: a task whose items are still importing is waiting-for-items, and one using the manual strategy is waiting-for-approval once the imports finish.
Response 400
Headers
Content-Type: application/jsonBody
{"errors": {"items": ["Could not resolve publish item"]}, "status_code": 400}Other 400 messages include At least one item must be provided and Cannot add version to more than one active publish.
Response 409
Headers
Content-Type: application/jsonBody
{"error": "One or more of the drafts was already published."}Publish detail
Section titled “Publish detail”/publish/{id}/Get a publish taskGet the current state of a publish task.
Response 200
Headers
Content-Type: application/jsonBody
{ "id": 123, "url": "https://{domain}/services/api/v1.x/publish/123/", "state": "waiting-for-items", "created_at": "2015-08-19T00:00:01.000000Z", "created_by": { "id": 3, "url": "https://{domain}/services/api/v1.x/users/3/", "first_name": "Bob", "last_name": "Jones", "country": "NZ", "geotag": "global/oceania/new-zealand" }, "error_strategy": "abort", "publish_strategy": "together", "publish_at": null, "items": [ "https://{domain}/services/api/v1.x/layers/4/versions/44/", "https://{domain}/services/api/v1.x/tables/5/versions/55/", "https://{domain}/services/api/v1.x/layers/6/versions/66/" ], "reference": "1234abcd"}/publish/{id}/Cancel publish taskCancel a pending publish task.
Response 202
No body.
Response 409
Headers
Content-Type: application/jsonBody
{"not-cancelable": ["This publish is not cancelable"]}Approve publish
Section titled “Approve publish”/publish/{id}/approve/Approve a manual publish taskApproves a task with a manual publish strategy that is in the waiting-for-approval state.
Response 202
No body. Publishing begins shortly.
Response 409
Headers
Content-Type: application/jsonBody
{"not-approvable": ["This publish can not be approved"]}