Skip to content

Publishing API

The Publishing API allows for draft versions of versioned objects - i.e. documents, layers and tables - to be scheduled for publishing together.

GET/publish/List publish tasks

Returns 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.

  • 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/json

Body

[
{
"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"
}
]
POST/publish/Create a new publish task

Create 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 together strategy will publish all items once they have all finished importing/updating.
  • The manual strategy 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 abort strategy will leave all items in their draft state if one of them encounters an error during importing/updating.
  • The ignore strategy will publish any successful items and leave any errored items in their draft state

reference: Optional user-defined reference.

Request

Headers

Content-Type: application/json

Body

{
"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/json

Body

{"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/json

Body

{"error": "One or more of the drafts was already published."}
GET/publish/{id}/Get a publish task

Get the current state of a publish task.

Response 200

Headers

Content-Type: application/json

Body

{
"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"
}
DELETE/publish/{id}/Cancel publish task

Cancel a pending publish task.

Response 202

No body.

Response 409

Headers

Content-Type: application/json

Body

{"not-cancelable": ["This publish is not cancelable"]}
POST/publish/{id}/approve/Approve a manual publish task

Approves 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/json

Body

{"not-approvable": ["This publish can not be approved"]}