A pact between GDS API Adapters and Publishing API

Requests from GDS API Adapters to Publishing API

Interactions

Given there are live content items with base_paths /foo and /bar, upon receiving a /lookup-by-base-path-request from GDS API Adapters, with

{
  "method": "post",
  "path": "/lookup-by-base-path",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "base_paths": [
      "/foo"
    ]
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "/foo": "08f86d00-e95f-492f-af1d-470c5ba4752e"
  }
}

Given there is a draft content item with base_path /foo, upon receiving a /lookup-by-base-path-request from GDS API Adapters, with

{
  "method": "post",
  "path": "/lookup-by-base-path",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "base_paths": [
      "/foo"
    ],
    "with_drafts": true
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "/foo": "cbb460a7-60de-4a74-b5be-0b27c6d6af9b"
  }
}

Given taxon links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a bulk_links request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/links/by-content-id",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "content_ids": [
      "bed722e6-db68-43e5-9079-063f623335a7",
      "f40a63ce-ac0c-4102-84d1-f1835cb7daac"
    ]
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "bed722e6-db68-43e5-9079-063f623335a7": {
      "links": {
        "taxons": [
          "20583132-1619-4c68-af24-77583172c070"
        ]
      },
      "version": 2
    },
    "f40a63ce-ac0c-4102-84d1-f1835cb7daac": {
      "links": {
      },
      "version": 0
    }
  }
}

Given there are live content items with base_paths /foo and /bar, upon receiving a get editions request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/editions",
  "query": "fields%5B%5D=content_id",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "results": [
      {
        "content_id": "08f86d00-e95f-492f-af1d-470c5ba4752e"
      },
      {
        "content_id": "ca6c58a6-fb9d-479d-b3e6-74908781cb18"
      }
    ],
    "links": [
      {
        "href": "http://example.org/v2/editions?fields%5B%5D=content_id",
        "rel": "self"
      }
    ]
  }
}

Given there are 4 live content items with fixed updated timestamps, upon receiving a get editions request for 2 per page from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/editions",
  "query": "fields%5B%5D=content_id&per_page=2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "results": [
      {
        "content_id": "bd50a6d9-f03d-4ccf-94aa-ad79579990a9"
      },
      {
        "content_id": "989033fe-252a-4e69-976d-5c0059bca949"
      }
    ],
    "links": [
      {
        "href": "http://example.org/v2/editions?fields%5B%5D=content_id&per_page=2&after=2017-02-01T00%3A00%3A00.000000Z%2C2",
        "rel": "next"
      },
      {
        "href": "http://example.org/v2/editions?fields%5B%5D=content_id&per_page=2",
        "rel": "self"
      }
    ]
  }
}

Given a content item exists in multiple locales with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get entries request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 1,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "locale": "en"
      }
    ]
  }
}

Given there is content with document_type 'topic', upon receiving a get entries request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 2,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "title": "Content Item A",
        "base_path": "/a-base-path"
      },
      {
        "title": "Content Item B",
        "base_path": "/another-base-path"
      }
    ]
  }
}

Given a content item exists in multiple locales with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get entries request with a specific locale from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 1,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=fr&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "locale": "fr"
      }
    ]
  }
}

Given a content item exists in multiple locales with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get entries request with an 'all' locale from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 3,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=locale&locale=all&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "locale": "en"
      },
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "locale": "fr"
      },
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "locale": "ar"
      }
    ]
  }
}

Given a content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7 and it has details, upon receiving a get entries request with details field from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=content_id&fields%5B%5D=details",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 1,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&fields%5B%5D=details&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
        "details": {
          "foo": "bar"
        }
      }
    ]
  }
}

Given there is content with document_type 'topic', upon receiving a get entries request with search_in and q parameters from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 1,
    "pages": 1,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=content_id&q=an+internal+name&search_in%5B%5D=details.internal_name&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "content_id": "aaaaaaaa-aaaa-1aaa-aaaa-aaaaaaaaaaaa"
      }
    ]
  }
}

Given there is content with document_type 'topic', upon receiving a get linkables request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/linkables",
  "query": "document_type=topic",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": [
    {
      "title": "Content Item A",
      "internal_name": "an internal name",
      "content_id": "aaaaaaaa-aaaa-1aaa-aaaa-aaaaaaaaaaaa",
      "publication_state": "draft",
      "base_path": "/a-base-path"
    },
    {
      "title": "Content Item B",
      "internal_name": "Content Item B",
      "content_id": "bbbbbbbb-bbbb-2bbb-bbbb-bbbbbbbbbbbb",
      "publication_state": "published",
      "base_path": "/another-base-path"
    }
  ]
}

Given there are two documents with a 'topic' link to another document, upon receiving a get linked request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/linked/6cb2cf8c-670f-4de3-97d5-6ad9114581c7",
  "query": "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": [
    {
      "content_id": "e2961462-bc37-48e9-bb98-c981ef1a2d59",
      "base_path": "/item-b"
    },
    {
      "content_id": "08dfd5c3-d935-4e81-88fd-cfe65b78893d",
      "base_path": "/item-a"
    }
  ]
}

Given there are two link changes with a link_type of 'taxons', upon receiving a get links changes request for changes with a link_type of 'taxons' from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/links/changes",
  "query": "link_types%5B%5D=taxons",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "link_changes": [
      {
        "source": {
          "title": "Edition Title A1",
          "base_path": "/base/path/a1",
          "content_id": "aaaaaaaa-aaaa-1aaa-aaaa-aaaaaaaaaaaa"
        },
        "target": {
          "title": "Edition Title B1",
          "base_path": "/base/path/b1",
          "content_id": "bbbbbbbb-bbbb-1bbb-bbbb-bbbbbbbbbbbb"
        },
        "link_type": "taxons",
        "change": "add",
        "user_uid": "11111111-1111-1111-1111-111111111111",
        "created_at": "2017-01-01T09:00:00.100Z"
      },
      {
        "source": {
          "title": "Edition Title A2",
          "base_path": "/base/path/a2",
          "content_id": "aaaaaaaa-aaaa-2aaa-aaaa-aaaaaaaaaaaa"
        },
        "target": {
          "title": "Edition Title B2",
          "base_path": "/base/path/b2",
          "content_id": "bbbbbbbb-bbbb-2bbb-bbbb-bbbbbbbbbbbb"
        },
        "link_type": "taxons",
        "change": "remove",
        "user_uid": "22222222-2222-2222-2222-222222222222",
        "created_at": "2017-01-01T09:00:00.100Z"
      }
    ]
  }
}

Given empty links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-expanded-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/expanded-links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "expanded_links": {
    }
  }
}

Given organisation links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-expanded-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/expanded-links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "expanded_links": {
      "organisations": [
        {
          "content_id": "20583132-1619-4c68-af24-77583172c070"
        }
      ]
    }
  }
}

Given no links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-expanded-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/expanded-links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 404
}

Given empty links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
    }
  }
}

Given organisation links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
      "organisations": [
        "20583132-1619-4c68-af24-77583172c070"
      ]
    }
  }
}

Given no links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a get-links request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7"
}

Publishing API will respond with:

{
  "status": 404
}

Given there are 4 live content items with fixed updated timestamps, upon receiving a next page editions request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/editions",
  "query": "fields%5B%5D=content_id&per_page=2&after=2017-02-01T00%3A00%3A00.000000Z%2C2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "results": [
      {
        "content_id": "271d4270-9186-4d60-b2ca-1d7dae7e0f73"
      },
      {
        "content_id": "638af19c-27fc-4cc9-a914-4cca49028688"
      }
    ],
    "links": [
      {
        "href": "http://example.org/v2/editions?fields%5B%5D=content_id&per_page=2&after=2017-02-01T00%3A00%3A00.000000Z%2C2",
        "rel": "self"
      },
      {
        "href": "http://example.org/v2/editions?fields%5B%5D=content_id&per_page=2&before=2017-03-01T00%3A00%3A00.000000Z%2C3",
        "rel": "previous"
      }
    ]
  }
}

Given organisation links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a patch blank organisation links request from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "organisations": [

      ]
    }
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
    }
  }
}

Given no links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a patch organisation links request from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    }
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    }
  }
}

Given organisation links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a patch organisation links request from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    }
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    }
  }
}

Given organisation links exist for content_id bed722e6-db68-43e5-9079-063f623335a7, upon receiving a patch topic links request from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "topics": [
        "225df4a8-2945-4e9b-8799-df7424a90b69"
      ]
    }
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "links": {
      "topics": [
        "225df4a8-2945-4e9b-8799-df7424a90b69"
      ],
      "organisations": [
        "20583132-1619-4c68-af24-77583172c070"
      ]
    }
  }
}

Given a draft content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a publish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "major"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given a draft content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7 and locale: fr, upon receiving a publish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "major",
    "locale": "fr"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a publish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "major"
  }
}

Publishing API will respond with:

{
  "status": 404
}

Given a published content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a publish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "major"
  }
}

Publishing API will respond with:

{
  "status": 409,
  "body": {
    "error": {
      "code": 409,
      "message": "Cannot publish an already published content item"
    }
  }
}

Given the content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a publish request for version 2 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "minor",
    "previous_version": 2
  }
}

Publishing API will respond with:

{
  "status": 409,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 409,
      "message": "Conflict",
      "fields": {
        "previous_version": [
          "does not match"
        ]
      }
    }
  }
}

Given the content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a publish request for version 3 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": "minor",
    "previous_version": 3
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given an unpublished content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a republish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/republish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a republish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/republish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
  }
}

Publishing API will respond with:

{
  "status": 404
}

Given the published content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a republish request for version 2 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/republish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "previous_version": 2
  }
}

Publishing API will respond with:

{
  "status": 409,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 409,
      "message": "Conflict",
      "fields": {
        "previous_version": [
          "does not match"
        ]
      }
    }
  }
}

Given the published content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a republish request for version 3 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/republish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "previous_version": 3
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a request for a non-existent content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 404,
      "message": "not found"
    }
  }
}

Given there are live content items with base_paths /foo and /bar, upon receiving a request for multiple base_paths from GDS API Adapters, with

{
  "method": "post",
  "path": "/lookup-by-base-path",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "base_paths": [
      "/foo",
      "/bar"
    ]
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "/foo": "08f86d00-e95f-492f-af1d-470c5ba4752e",
    "/bar": "ca6c58a6-fb9d-479d-b3e6-74908781cb18"
  }
}

Given /test-item has been reserved by the Publisher application, upon receiving a request from the Whitehall application to create a content item at /test-item from GDS API Adapters, with

{
  "method": "put",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "base_path": "/test-item",
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "title": "Instructions for crawler robots",
    "description": "robots.txt provides rules for which parts of GOV.UK are permitted to be crawled by different bots.",
    "schema_name": "special_route",
    "document_type": "special_route",
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "publishing_app": "whitehall",
    "rendering_app": "static",
    "locale": "en",
    "routes": [
      {
        "path": "/test-item",
        "type": "exact"
      }
    ],
    "update_type": "major",
    "details": {
    }
  }
}

Publishing API will respond with:

{
  "status": 422,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 422,
      "message": "Conflict",
      "fields": {
        "base_path": [
          "is already in use by the 'publisher' app"
        ]
      }
    }
  }
}

Given /test-item has been reserved by the Publisher application, upon receiving a request to change publishing app from GDS API Adapters, with

{
  "method": "put",
  "path": "/paths/test-item",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "whitehall"
  }
}

Publishing API will respond with:

{
  "status": 422,
  "body": {
    "error": {
      "code": 422,
      "message": "Unprocessable",
      "fields": {
        "base_path": [
          "has been reserved"
        ]
      }
    }
  }
}

Given /test-item has been reserved by the Publisher application, upon receiving a request to change publishing app with override_existing set from GDS API Adapters, with

{
  "method": "put",
  "path": "/paths/test-item",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "whitehall",
    "override_existing": "true"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given no content exists, upon receiving a request to create a content item without links from GDS API Adapters, with

{
  "method": "put",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "base_path": "/robots.txt",
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "title": "Instructions for crawler robots",
    "description": "robots.txt provides rules for which parts of GOV.UK are permitted to be crawled by different bots.",
    "schema_name": "special_route",
    "document_type": "special_route",
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "publishing_app": "static",
    "rendering_app": "static",
    "locale": "en",
    "routes": [
      {
        "path": "/robots.txt",
        "type": "exact"
      }
    ],
    "update_type": "major",
    "details": {
    }
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a request to create a publish intent from GDS API Adapters, with

{
  "method": "put",
  "path": "/publish-intent/test-intent",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "publish_time": "2019-11-11t17:56:17+00:00"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "publish_time": "2019-11-11t17:56:17+00:00"
  }
}

Given no content exists, upon receiving a request to create an invalid content-item from GDS API Adapters, with

{
  "method": "put",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "base_path": "not a url path",
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "title": "Instructions for crawler robots",
    "description": "robots.txt provides rules for which parts of GOV.UK are permitted to be crawled by different bots.",
    "schema_name": "special_route",
    "document_type": "special_route",
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "publishing_app": "static",
    "rendering_app": "static",
    "locale": "en",
    "routes": [
      {
        "path": "not a url path",
        "type": "exact"
      }
    ],
    "update_type": "major",
    "details": {
    }
  }
}

Publishing API will respond with:

{
  "status": 422,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": [
    {
      "schema": {
      },
      "fragment": "#/base_path",
      "message": "The property '#/base_path' value \"not a url path\" did not match the regex '^/(([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})+(/([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)*)?$' in schema 729a13d6-8ddb-5ba8-b116-3b7604dc3d3d#",
      "failed_attribute": "Pattern"
    }
  ]
}

Given a publish intent exists at /test-intent, upon receiving a request to delete a publish intent from GDS API Adapters, with

{
  "method": "delete",
  "path": "/publish-intent/test-intent"
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given no content exists, upon receiving a request to delete a publish intent from GDS API Adapters, with

{
  "method": "delete",
  "path": "/publish-intent/test-intent"
}

Publishing API will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given a content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to discard draft content from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/discard-draft",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a request to discard draft content from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/discard-draft",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
  }
}

Publishing API will respond with:

{
  "status": 404
}

Given a French content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to discard French draft content from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/discard-draft",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "locale": "fr"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving a request to put a path from GDS API Adapters, with

{
  "method": "put",
  "path": "/paths/test-intent",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "publisher"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given a content item exists in multiple locales with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "locale=fr",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "fr",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    }
  }
}

Given a content item exists in with a superseded version with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "publication_state": "published"
  }
}

Given a content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    }
  }
}

Given a published content item exists with a draft edition for content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "locale=en",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "details": {
    },
    "state_history": {
      "1": "published",
      "2": "draft"
    },
    "publication_state": "draft"
  }
}

Given an unpublished content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "state_history": {
      "1": "unpublished"
    },
    "publication_state": "unpublished"
  }
}

Given a draft content item exists with content_id bed722e6-db68-43e5-9079-063f623335a7 with a blocking live item at the same path, upon receiving a request to return the draft content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "warnings": {
      "content_item_blocking_publish": "message"
    },
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "details": {
    },
    "publication_state": "draft"
  }
}

Given no content exists, upon receiving a request to return the items linked to it from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/linked/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "fields%5B%5D=content_id&fields%5B%5D=base_path&link_type=topic",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 404,
      "message": "not found"
    }
  }
}

Given a draft content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the live content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "details": {
    },
    "state_history": {
      "1": "draft"
    },
    "publication_state": "draft"
  }
}

Given a published content item exists with a draft edition for content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the live content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "locale=en&version=1",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "state_history": {
      "1": "published",
      "2": "draft"
    },
    "publication_state": "published"
  }
}

Given a published content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the live content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "state_history": {
      "1": "published"
    },
    "publication_state": "published"
  }
}

Given a content item exists in with a superseded version with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the published content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "version=2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "publication_state": "published"
  }
}

Given a content item exists in with a superseded version with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving a request to return the superseded content item from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "query": "version=1",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "document_type": "special_route",
    "schema_name": "special_route",
    "publishing_app": "publisher",
    "rendering_app": "frontend",
    "locale": "en",
    "routes": [
      {
      }
    ],
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "details": {
    },
    "publication_state": "superseded"
  }
}

Given no content exists, upon receiving a request to unreserve a non-existant path from GDS API Adapters, with

{
  "method": "delete",
  "path": "/paths/test-item",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "publisher"
  }
}

Publishing API will respond with:

{
  "status": 404,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given /test-item has been reserved by the Publisher application, upon receiving a request to unreserve a path from GDS API Adapters, with

{
  "method": "delete",
  "path": "/paths/test-item",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "publisher"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given /test-item has been reserved by the Publisher application, upon receiving a request to unreserve a path owned by another app from GDS API Adapters, with

{
  "method": "delete",
  "path": "/paths/test-item",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "publishing_app": "whitehall"
  }
}

Publishing API will respond with:

{
  "status": 422,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  }
}

Given the content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a request to update the content item at version 2 from GDS API Adapters, with

{
  "method": "put",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "base_path": "/robots.txt",
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "title": "Instructions for crawler robots",
    "description": "robots.txt provides rules for which parts of GOV.UK are permitted to be crawled by different bots.",
    "schema_name": "manual",
    "document_type": "manual",
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "publishing_app": "static",
    "rendering_app": "static",
    "locale": "en",
    "routes": [
      {
        "path": "/robots.txt",
        "type": "exact"
      }
    ],
    "update_type": "major",
    "details": {
      "body": [

      ]
    },
    "previous_version": "2"
  }
}

Publishing API will respond with:

{
  "status": 409,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 409,
      "message": "Conflict",
      "fields": {
        "previous_version": [
          "does not match"
        ]
      }
    }
  }
}

Given the content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a request to update the content item at version 3 from GDS API Adapters, with

{
  "method": "put",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "base_path": "/robots.txt",
    "content_id": "bed722e6-db68-43e5-9079-063f623335a7",
    "title": "Instructions for crawler robots",
    "description": "robots.txt provides rules for which parts of GOV.UK are permitted to be crawled by different bots.",
    "schema_name": "manual",
    "document_type": "manual",
    "public_updated_at": "2015-07-30T13:58:11.000Z",
    "publishing_app": "static",
    "rendering_app": "static",
    "locale": "en",
    "routes": [
      {
        "path": "/robots.txt",
        "type": "exact"
      }
    ],
    "update_type": "major",
    "details": {
      "body": [

      ]
    },
    "previous_version": "3"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given the linkset for bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a request to update the linkset at version 2 from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    },
    "previous_version": 2
  }
}

Publishing API will respond with:

{
  "status": 409,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 409,
      "message": "Conflict",
      "fields": {
        "previous_version": [
          "does not match"
        ]
      }
    }
  }
}

Given the linkset for bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving a request to update the linkset at version 3 from GDS API Adapters, with

{
  "method": "patch",
  "path": "/v2/links/bed722e6-db68-43e5-9079-063f623335a7",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "links": {
      "organisations": [
        "591436ab-c2ae-416f-a3c5-1901d633fbfb"
      ]
    },
    "previous_version": 3
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given a draft content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving an invalid publish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/publish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "update_type": ""
  }
}

Publishing API will respond with:

{
  "status": 422,
  "body": {
    "error": {
      "code": 422,
      "message": "Unprocessable entity",
      "fields": {
        "update_type": [
          "is required"
        ]
      }
    }
  }
}

Given a published content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving an invalid unpublish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "not-a-valid-type"
  }
}

Publishing API will respond with:

{
  "status": 422,
  "body": {
    "error": {
      "code": 422,
      "message": "not-a-valid-type is not a valid unpublishing type",
      "fields": {
      }
    }
  }
}

Given a published content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving an unpublish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "gone"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given an unpublished content item exists with content_id: bed722e6-db68-43e5-9079-063f623335a7, upon receiving an unpublish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "gone"
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given no content exists, upon receiving an unpublish request from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "gone"
  }
}

Publishing API will respond with:

{
  "status": 404
}

Given the published content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving an unpublish request for version 2 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "gone",
    "previous_version": 2
  }
}

Publishing API will respond with:

{
  "status": 409,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "error": {
      "code": 409,
      "message": "Conflict",
      "fields": {
        "previous_version": [
          "does not match"
        ]
      }
    }
  }
}

Given the published content item bed722e6-db68-43e5-9079-063f623335a7 is at version 3, upon receiving an unpublish request for version 3 from GDS API Adapters, with

{
  "method": "post",
  "path": "/v2/content/bed722e6-db68-43e5-9079-063f623335a7/unpublish",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Content-Type": "application/json",
    "Authorization": "Bearer example-bearer-token"
  },
  "body": {
    "type": "gone",
    "previous_version": 3
  }
}

Publishing API will respond with:

{
  "status": 200
}

Given there are four content items with document_type 'topic', upon receiving get the first page request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=1&per_page=2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 4,
    "pages": 2,
    "current_page": 1,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
        "rel": "next"
      },
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
        "rel": "self"
      }
    ],
    "results": [
      {
        "title": "title_1",
        "base_path": "/path_1"
      },
      {
        "title": "title_2",
        "base_path": "/path_2"
      }
    ]
  }
}

Given there are four content items with document_type 'topic', upon receiving get the second page request from GDS API Adapters, with

{
  "method": "get",
  "path": "/v2/content",
  "query": "document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&page=2&per_page=2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/75.2.0 ()",
    "Authorization": "Bearer example-bearer-token"
  }
}

Publishing API will respond with:

{
  "status": 200,
  "body": {
    "total": 4,
    "pages": 2,
    "current_page": 2,
    "links": [
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=1",
        "rel": "previous"
      },
      {
        "href": "http://example.org/v2/content?document_type=topic&fields%5B%5D=title&fields%5B%5D=base_path&per_page=2&page=2",
        "rel": "self"
      }
    ],
    "results": [
      {
        "title": "title_3",
        "base_path": "/path_3"
      },
      {
        "title": "title_4",
        "base_path": "/path_4"
      }
    ]
  }
}