2 Phase Commit

Mechanism of the 2-phase commit

The 2-phase commit provides a mechanism for CDB to publish only the tenders that clients are able to control and duplicates of which they have rights to cancel.

The reason for duplicated tenders can be cases when the requester did not receive a response from the server about tender creation and, therefore, repeated the request. Removing such tenders requires administrative intervention.

Creating tender with single-phase commit

Sending a single-phase request for a tender creation (POST /tenders) according to the “old” mechanism, that creates a tender already in the active.enquiries status:

POST /api/2.3/tenders?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 2359
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "tenderPeriod": {
      "endDate": "2017-08-08T17:36:49.306344"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35
    },
    "enquiryPeriod": {
      "endDate": "2017-08-01T17:36:49.306344"
    },
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500
    },
    "procuringEntity": {
      "contactPoint": {
        "name": "Державне управління справами",
        "telephone": "0440000000"
      },
      "identifier": {
        "scheme": "UA-EDR",
        "id": "00037256",
        "uri": "http://www.dus.gov.ua/"
      },
      "name": "Державне управління справами",
      "kind": "general",
      "address": {
        "countryName": "Україна",
        "postalCode": "01220",
        "region": "м. Київ",
        "streetAddress": "вул. Банкова, 11, корпус 1",
        "locality": "м. Київ"
      }
    },
    "items": [
      {
        "description": "футляри до державних нагород",
        "classification": {
          "scheme": "ДК021",
          "id": "44617100-9",
          "description": "Cartons"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "17.21.1",
            "description": "папір і картон гофровані, паперова й картонна тара"
          }
        ],
        "deliveryAddress": {
          "countryName": "Україна",
          "postalCode": "79000",
          "region": "м. Київ",
          "streetAddress": "вул. Банкова 1",
          "locality": "м. Київ"
        },
        "deliveryDate": {
          "startDate": "2017-07-27T17:36:49.306344",
          "endDate": "2017-07-30T17:36:49.306344"
        },
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ]
  }
}


201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/2.3/tenders/f3641d0ba0f042e8b49de06d5c7921af

{
  "access": {
    "token": "2ef61fa89e8a451ba4149d2f8e31173b"
  },
  "data": {
    "procurementMethod": "open",
    "status": "active.enquiries",
    "awardCriteria": "lowestCost",
    "tenderPeriod": {
      "startDate": "2017-08-01T17:36:49.306344+03:00",
      "endDate": "2017-08-08T17:36:49.306344+03:00"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35.0,
      "valueAddedTaxIncluded": true
    },
    "items": [
      {
        "description": "футляри до державних нагород",
        "classification": {
          "scheme": "ДК021",
          "description": "Cartons",
          "id": "44617100-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "17.21.1",
            "description": "папір і картон гофровані, паперова й картонна тара"
          }
        ],
        "deliveryAddress": {
          "postalCode": "79000",
          "countryName": "Україна",
          "streetAddress": "вул. Банкова 1",
          "region": "м. Київ",
          "locality": "м. Київ"
        },
        "deliveryDate": {
          "startDate": "2017-07-27T17:36:49.306344+03:00",
          "endDate": "2017-07-30T17:36:49.306344+03:00"
        },
        "id": "4ee2b0431a064e0eb155eeb650bdfdd0",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-07-25T17:36:55.659566+03:00",
    "next_check": "2017-08-01T17:36:49.306344+03:00",
    "procuringEntity": {
      "contactPoint": {
        "name": "Державне управління справами",
        "telephone": "0440000000"
      },
      "identifier": {
        "scheme": "UA-EDR",
        "id": "00037256",
        "uri": "http://www.dus.gov.ua/"
      },
      "name": "Державне управління справами",
      "kind": "general",
      "address": {
        "postalCode": "01220",
        "countryName": "Україна",
        "streetAddress": "вул. Банкова, 11, корпус 1",
        "region": "м. Київ",
        "locality": "м. Київ"
      }
    },
    "enquiryPeriod": {
      "startDate": "2017-07-25T17:36:55.659520+03:00",
      "endDate": "2017-08-01T17:36:49.306344+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-07-25T17:36:55.662421+03:00",
    "id": "f3641d0ba0f042e8b49de06d5c7921af",
    "tenderID": "UA-2017-07-25-000001"
  }
}

Creating tender with 2-phase commit

Tender becomes available after the successful completion of the following requests:

  1. Creation of the tender in the draft status.
  2. Transfer of the tender to active.enquiries status through a separate request (publication).

Creation of a tender

A request POST /tenders creates a tender in status draft. As a result, an acc_token is passed for the further tender management.

POST /api/2.3/tenders?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 2378
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "status": "draft",
    "tenderPeriod": {
      "endDate": "2017-08-08T17:36:49.306344"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35
    },
    "enquiryPeriod": {
      "endDate": "2017-08-01T17:36:49.306344"
    },
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500
    },
    "procuringEntity": {
      "contactPoint": {
        "name": "Державне управління справами",
        "telephone": "0440000000"
      },
      "identifier": {
        "scheme": "UA-EDR",
        "id": "00037256",
        "uri": "http://www.dus.gov.ua/"
      },
      "name": "Державне управління справами",
      "kind": "general",
      "address": {
        "countryName": "Україна",
        "postalCode": "01220",
        "region": "м. Київ",
        "streetAddress": "вул. Банкова, 11, корпус 1",
        "locality": "м. Київ"
      }
    },
    "items": [
      {
        "description": "футляри до державних нагород",
        "classification": {
          "scheme": "ДК021",
          "id": "44617100-9",
          "description": "Cartons"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "17.21.1",
            "description": "папір і картон гофровані, паперова й картонна тара"
          }
        ],
        "deliveryAddress": {
          "countryName": "Україна",
          "postalCode": "79000",
          "region": "м. Київ",
          "streetAddress": "вул. Банкова 1",
          "locality": "м. Київ"
        },
        "deliveryDate": {
          "startDate": "2017-07-27T17:36:49.306344",
          "endDate": "2017-07-30T17:36:49.306344"
        },
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ]
  }
}


201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/2.3/tenders/e66dcc48a19e498984e3e5e51131ad68

{
  "access": {
    "token": "75424b9a8c2842d0a9c24e477ccef649"
  },
  "data": {
    "procurementMethod": "open",
    "status": "draft",
    "awardCriteria": "lowestCost",
    "tenderPeriod": {
      "startDate": "2017-08-01T17:36:49.306344+03:00",
      "endDate": "2017-08-08T17:36:49.306344+03:00"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35.0,
      "valueAddedTaxIncluded": true
    },
    "items": [
      {
        "description": "футляри до державних нагород",
        "classification": {
          "scheme": "ДК021",
          "description": "Cartons",
          "id": "44617100-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "17.21.1",
            "description": "папір і картон гофровані, паперова й картонна тара"
          }
        ],
        "deliveryAddress": {
          "postalCode": "79000",
          "countryName": "Україна",
          "streetAddress": "вул. Банкова 1",
          "region": "м. Київ",
          "locality": "м. Київ"
        },
        "deliveryDate": {
          "startDate": "2017-07-27T17:36:49.306344+03:00",
          "endDate": "2017-07-30T17:36:49.306344+03:00"
        },
        "id": "3e25bda8806e4d27a03dc5f9e4805f5e",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-07-25T17:36:50.226421+03:00",
    "procuringEntity": {
      "contactPoint": {
        "name": "Державне управління справами",
        "telephone": "0440000000"
      },
      "identifier": {
        "scheme": "UA-EDR",
        "id": "00037256",
        "uri": "http://www.dus.gov.ua/"
      },
      "name": "Державне управління справами",
      "kind": "general",
      "address": {
        "postalCode": "01220",
        "countryName": "Україна",
        "streetAddress": "вул. Банкова, 11, корпус 1",
        "region": "м. Київ",
        "locality": "м. Київ"
      }
    },
    "enquiryPeriod": {
      "startDate": "2017-07-25T17:36:50.226395+03:00",
      "endDate": "2017-08-01T17:36:49.306344+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-07-25T17:36:50.228135+03:00",
    "id": "e66dcc48a19e498984e3e5e51131ad68",
    "tenderID": "UA-2017-07-25-000001"
  }
}

Tender with the draft status is “invisible” in the GET /tenders list. Chronograph does not “see” it, therefore, does not switch statuses.

Publication of a tender

The request PATCH /tenders/{id}?acc_token=... {“data”:{“status”:”active.enquiries”}} changes status of tender (according to the request), therefore, publishes it (“visualizes” it in the GET /tenders list).

PATCH /api/2.3/tenders/e66dcc48a19e498984e3e5e51131ad68?acc_token=75424b9a8c2842d0a9c24e477ccef649 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 40
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "status": "active.enquiries"
  }
}


200 OK
Content-Type: application/json; charset=UTF-8

{
  "data": {
    "procurementMethod": "open",
    "status": "active.enquiries",
    "awardCriteria": "lowestCost",
    "tenderPeriod": {
      "startDate": "2017-08-01T17:36:49.306344+03:00",
      "endDate": "2017-08-08T17:36:49.306344+03:00"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35.0,
      "valueAddedTaxIncluded": true
    },
    "items": [
      {
        "description": "футляри до державних нагород",
        "classification": {
          "scheme": "ДК021",
          "description": "Cartons",
          "id": "44617100-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "17.21.1",
            "description": "папір і картон гофровані, паперова й картонна тара"
          }
        ],
        "deliveryAddress": {
          "postalCode": "79000",
          "countryName": "Україна",
          "streetAddress": "вул. Банкова 1",
          "region": "м. Київ",
          "locality": "м. Київ"
        },
        "deliveryDate": {
          "startDate": "2017-07-27T17:36:49.306344+03:00",
          "endDate": "2017-07-30T17:36:49.306344+03:00"
        },
        "id": "3e25bda8806e4d27a03dc5f9e4805f5e",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-07-25T17:36:50.255342+03:00",
    "next_check": "2017-08-01T17:36:49.306344+03:00",
    "procuringEntity": {
      "contactPoint": {
        "name": "Державне управління справами",
        "telephone": "0440000000"
      },
      "identifier": {
        "scheme": "UA-EDR",
        "id": "00037256",
        "uri": "http://www.dus.gov.ua/"
      },
      "name": "Державне управління справами",
      "kind": "general",
      "address": {
        "postalCode": "01220",
        "countryName": "Україна",
        "streetAddress": "вул. Банкова, 11, корпус 1",
        "region": "м. Київ",
        "locality": "м. Київ"
      }
    },
    "enquiryPeriod": {
      "startDate": "2017-07-25T17:36:50.226395+03:00",
      "endDate": "2017-08-01T17:36:49.306344+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-07-25T17:36:50.255342+03:00",
    "id": "e66dcc48a19e498984e3e5e51131ad68",
    "tenderID": "UA-2017-07-25-000001"
  }
}

All tenders created in the CDB but not yet published will not be displayed on the web platform and, therefore, will not lead to their announcement.

Repeating of the request for publication in case of problem with receiving a response from the server will not cause errors.

The new mechanism is available along with the “old” one. The “old” is likely to be turned off in one of the later releases.

Work with errors

In case of unsuccessful request and/or 5xx errors you should check modified object data (tender, bid, award, etc.), since 5xx error response does not necessarily guarantee that request has not been performed. You should repeat this request with some interval until successful result.

You can view more detailed error description here.

Here is an example of incorrectly formed request. This error indicates that the data is not found in the body of JSON.

POST /api/2.3/tenders?opt_pretty=1 HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 4
Content-Type: application/json
Host: api-sandbox.openprocurement.org


422 Unprocessable Entity
Content-Type: application/json; charset=UTF-8

{
  "status": "error",
  "errors": [
    {
      "description": "No JSON object could be decoded",
      "location": "body",
      "name": "data"
    }
  ]
}