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-07-08T18:05:33.770353"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35
    },
    "enquiryPeriod": {
      "endDate": "2017-07-01T18:05:33.770353"
    },
    "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-06-26T18:05:33.770353",
          "endDate": "2017-06-29T18:05:33.770353"
        },
        "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/f860f9fe94574d729c87f81cea222b46

{
  "access": {
    "token": "b84904c40e484b2e9be9af92d1cca8ae"
  },
  "data": {
    "procurementMethod": "open",
    "status": "active.enquiries",
    "awardCriteria": "lowestCost",
    "tenderPeriod": {
      "startDate": "2017-07-01T18:05:33.770353+03:00",
      "endDate": "2017-07-08T18:05:33.770353+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-06-26T18:05:33.770353+03:00",
          "endDate": "2017-06-29T18:05:33.770353+03:00"
        },
        "id": "19e00fd134d041c0a63f8c6463000392",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-06-24T18:05:45.698533+03:00",
    "next_check": "2017-07-01T18:05:33.770353+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-06-24T18:05:45.698458+03:00",
      "endDate": "2017-07-01T18:05:33.770353+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-06-24T18:05:45.704170+03:00",
    "id": "f860f9fe94574d729c87f81cea222b46",
    "tenderID": "UA-2017-06-24-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-07-08T18:05:33.770353"
    },
    "title": "футляри до державних нагород",
    "minimalStep": {
      "currency": "UAH",
      "amount": 35
    },
    "enquiryPeriod": {
      "endDate": "2017-07-01T18:05:33.770353"
    },
    "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-06-26T18:05:33.770353",
          "endDate": "2017-06-29T18:05:33.770353"
        },
        "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/fb27cfb91c1b4b1480dd9acf99571a9a

{
  "access": {
    "token": "fe7ef3656f9d4604b795b21cf68601c5"
  },
  "data": {
    "procurementMethod": "open",
    "status": "draft",
    "awardCriteria": "lowestCost",
    "tenderPeriod": {
      "startDate": "2017-07-01T18:05:33.770353+03:00",
      "endDate": "2017-07-08T18:05:33.770353+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-06-26T18:05:33.770353+03:00",
          "endDate": "2017-06-29T18:05:33.770353+03:00"
        },
        "id": "7c7d1b9dcb94481c8468da63175965d4",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-06-24T18:05:35.188545+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-06-24T18:05:35.188488+03:00",
      "endDate": "2017-07-01T18:05:33.770353+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-06-24T18:05:35.192827+03:00",
    "id": "fb27cfb91c1b4b1480dd9acf99571a9a",
    "tenderID": "UA-2017-06-24-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/fb27cfb91c1b4b1480dd9acf99571a9a?acc_token=fe7ef3656f9d4604b795b21cf68601c5 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-07-01T18:05:33.770353+03:00",
      "endDate": "2017-07-08T18:05:33.770353+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-06-26T18:05:33.770353+03:00",
          "endDate": "2017-06-29T18:05:33.770353+03:00"
        },
        "id": "7c7d1b9dcb94481c8468da63175965d4",
        "unit": {
          "code": "44617100-9",
          "name": "item"
        },
        "quantity": 5
      }
    ],
    "procurementMethodType": "belowThreshold",
    "value": {
      "currency": "UAH",
      "amount": 500.0,
      "valueAddedTaxIncluded": true
    },
    "submissionMethod": "electronicAuction",
    "date": "2017-06-24T18:05:35.251618+03:00",
    "next_check": "2017-07-01T18:05:33.770353+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-06-24T18:05:35.188488+03:00",
      "endDate": "2017-07-01T18:05:33.770353+03:00"
    },
    "owner": "broker",
    "dateModified": "2017-06-24T18:05:35.251618+03:00",
    "id": "fb27cfb91c1b4b1480dd9acf99571a9a",
    "tenderID": "UA-2017-06-24-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"
    }
  ]
}