Tutorial

Plan creation

Creating plan procurement

Let’s create a plan:

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

{
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння гірчиці",
        "classification": {
          "scheme": "ДК021",
          "description": "Mustard seeds",
          "id": "03111600-8"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.92",
            "description": "Насіння гірчиці"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-06T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 1000
      },
      {
        "description": "Насіння соняшнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Sunflower seeds",
          "id": "03111300-5"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.95",
            "description": "Насіння соняшнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-07T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 2000
      },
      {
        "description": "Насіння бавовнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Cotton seeds",
          "id": "03111400-6"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.84",
            "description": "Насіння бавовнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-08T17:41:39.677983"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 3000
      }
    ],
    "budget": {
      "amountNet": 12222,
      "description": "budget_description",
      "project": {
        "name": "proj_name",
        "id": "123"
      },
      "currency": "UAH",
      "amount": 10000,
      "id": "12303111000-2"
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983"
      }
    }
  }
}

Response: 201 Created
Content-Type: application/json; charset=UTF-8
Location: http://api-sandbox.openprocurement.org/api/2.3/plans/52862ec099ff4debbf9f26a0980f27f3
{
  "access": {
    "token": "fc9c0f555bf24dffa2b855ed618bc81c"
  },
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння гірчиці",
        "classification": {
          "scheme": "ДК021",
          "description": "Mustard seeds",
          "id": "03111600-8"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.92",
            "description": "Насіння гірчиці"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-06T17:41:39.677983+03:00"
        },
        "id": "f8173e5bf8754aec89a47a624b3cefd1",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 1000
      },
      {
        "description": "Насіння соняшнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Sunflower seeds",
          "id": "03111300-5"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.95",
            "description": "Насіння соняшнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-07T17:41:39.677983+03:00"
        },
        "id": "3b0208637aa44a99b388a9b540533a1c",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 2000
      },
      {
        "description": "Насіння бавовнику",
        "classification": {
          "scheme": "ДК021",
          "description": "Cotton seeds",
          "id": "03111400-6"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.11.84",
            "description": "Насіння бавовнику"
          }
        ],
        "deliveryDate": {
          "endDate": "2017-07-08T17:41:39.677983+03:00"
        },
        "id": "7266c3c7b95246718021ab671207335e",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 3000
      }
    ],
    "planID": "UA-P-2017-06-21-000001",
    "budget": {
      "amountNet": 12222.0,
      "description": "budget_description",
      "project": {
        "id": "123",
        "name": "proj_name"
      },
      "currency": "UAH",
      "amount": 10000.0,
      "id": "12303111000-2"
    },
    "datePublished": "2017-06-21T17:41:40.564867+03:00",
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983+03:00"
      }
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "owner": "broker",
    "dateModified": "2017-06-21T17:41:40.588719+03:00",
    "id": "52862ec099ff4debbf9f26a0980f27f3"
  }
}

We have 201 Created response code, Location header and body with extra id, planID, and dateModified properties.

Let’s check what plan registry contains:

GET /api/2.3/plans HTTP/1.0
Host: api-sandbox.openprocurement.org

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "next_page": {
    "path": "/api/2.3/plans?offset=",
    "uri": "http://api-sandbox.openprocurement.org/api/2.3/plans?offset=",
    "offset": ""
  },
  "data": []
}

We do see the internal id of a plan (that can be used to construct full URL by prepending http://api-sandbox.openprocurement.org/api/0/plans/) and its dateModified datestamp.

Modifying plan

Let’s update plan by supplementing it with all other essential properties:

PATCH /api/2.3/plans/52862ec099ff4debbf9f26a0980f27f3?acc_token=fc9c0f555bf24dffa2b855ed618bc81c HTTP/1.0
Authorization: Basic YnJva2VyOg==
Content-Length: 652
Content-Type: application/json
Host: api-sandbox.openprocurement.org

{
  "data": {
    "items": [
      {
        "description": "Насіння овочевих культур",
        "classification": {
          "scheme": "ДК021",
          "description": "Vegetable seeds",
          "id": "03111700-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.13.6",
            "description": "Насіння овочевих культур"
          }
        ],
        "deliveryDate": {
          "endDate": "2016-06-01T23:06:30.023018+03:00"
        },
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 5000
      }
    ]
  }
}

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "data": {
    "classification": {
      "scheme": "ДК021",
      "description": "Seeds",
      "id": "03111000-2"
    },
    "items": [
      {
        "description": "Насіння овочевих культур",
        "classification": {
          "scheme": "ДК021",
          "description": "Vegetable seeds",
          "id": "03111700-9"
        },
        "additionalClassifications": [
          {
            "scheme": "ДКПП",
            "id": "01.13.6",
            "description": "Насіння овочевих культур"
          }
        ],
        "deliveryDate": {
          "endDate": "2016-06-01T23:06:30.023018+03:00"
        },
        "id": "f8173e5bf8754aec89a47a624b3cefd1",
        "unit": {
          "code": "KGM",
          "name": "кг"
        },
        "quantity": 5000
      }
    ],
    "planID": "UA-P-2017-06-21-000001",
    "budget": {
      "amountNet": 12222.0,
      "description": "budget_description",
      "project": {
        "id": "123",
        "name": "proj_name"
      },
      "currency": "UAH",
      "amount": 10000.0,
      "id": "12303111000-2"
    },
    "datePublished": "2017-06-21T17:41:40.564867+03:00",
    "tender": {
      "procurementMethod": "open",
      "procurementMethodType": "belowThreshold",
      "tenderPeriod": {
        "startDate": "2017-06-28T17:41:39.677983+03:00"
      }
    },
    "additionalClassifications": [
      {
        "scheme": "КЕКВ",
        "id": "1",
        "description": "-"
      }
    ],
    "procuringEntity": {
      "identifier": {
        "scheme": "UA-EDR",
        "id": "111983",
        "legalName": "ДП Державне Управління Справами"
      },
      "name": "ДУС"
    },
    "owner": "broker",
    "dateModified": "2017-06-21T17:41:40.747307+03:00",
    "id": "52862ec099ff4debbf9f26a0980f27f3"
  }
}

We see the added properies have merged with existing plan data. Additionally, the dateModified property was updated to reflect the last modification datestamp.

Checking the listing again reflects the new modification date:

GET /api/2.3/plans HTTP/1.0
Host: api-sandbox.openprocurement.org

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
  "next_page": {
    "path": "/api/2.3/plans?offset=2017-06-21T17%3A41%3A40.588719%2B03%3A00",
    "uri": "http://api-sandbox.openprocurement.org/api/2.3/plans?offset=2017-06-21T17%3A41%3A40.588719%2B03%3A00",
    "offset": "2017-06-21T17:41:40.588719+03:00"
  },
  "data": [
    {
      "id": "52862ec099ff4debbf9f26a0980f27f3",
      "dateModified": "2017-06-21T17:41:40.588719+03:00"
    }
  ]
}