Authentication

Some of the API requests (especially the ones that are read-only GET requests) do not require any authenication. The other ones, that modify data into the database, require broker authentication via API key. Additionally, owner tokens are issued to facilitate multiple actor roles upon object creation.

API keys

API key is username to use with Basic Authenication scheme.

Owner tokens

Getting token

The token is issued when object is created in the database:

$ http --auth broker: -j POST https://api-sandbox.openprocurement.org/api/0/tenders data:=@./school-tender.json
POST /api/0/tenders HTTP/1.1
Authorization: Basic YnJva2VyOg==
Content-Type: application/json; charset=utf-8

{
    "data": {
        "enquiryPeriod": {
            "endDate": "2015-12-01"
        },
        "items": [
            {
                "description": "Послуги шкільних їдалень"
            }
        ],
        "minimalStep": {
            "amount": 35000,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        },
        "procuringEntity": {
            "address": {
                "countryName": "Україна",
                "locality": "м. Вінниця",
                "postalCode": "21027",
                "region": "м. Вінниця",
                "streetAddress": "вул. Стахурського. 22"
            },
            "contactPoint": {
                "name": "Куца Світлана Валентинівна",
                "telephone": "+380 (432) 46-53-02",
                "url": "http://sch10.edu.vn.ua/"
            },
            "identifier": {
                "id": "21725150",
                "legalName": "Заклад \"Загальноосвітня школа І-ІІІ ступенів № 10 Вінницької міської ради\"",
                "scheme": "UA-EDR"
            },
            "name": "ЗОСШ #10 м.Вінниці"
        },
        "tenderPeriod": {
            "endDate": "2015-12-10"
        },
        "value": {
            "amount": 500000,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        }
    }
}

HTTP/1.1 201 Created
Content-Type: application/json; charset=UTF-8
Location: https://api-sandbox.openprocurement.org/api/0/tenders/166b4a36611047a492d85c3693b86b4e

{
    "access": {
        "token": "953613dd25d6421588b2597504b747ed"
    },
    "data": {
        "dateModified": "2014-12-26T21:30:56.586789+02:00",
        "enquiryPeriod": {
            "endDate": "2015-12-01T00:00:00+02:00",
            "startDate": "2014-12-26T21:30:56.522694+02:00"
        },
        "id": "166b4a36611047a492d85c3693b86b4e",
        "items": [
            {
                "description": "Послуги шкільних їдалень"
            }
        ],
        "minimalStep": {
            "amount": 35000.0,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        },
        "owner": "broker",
        "procuringEntity": {
            "address": {
                "countryName": "Україна",
                "locality": "м. Вінниця",
                "postalCode": "21027",
                "region": "м. Вінниця",
                "streetAddress": "вул. Стахурського. 22"
            },
            "contactPoint": {
                "name": "Куца Світлана Валентинівна",
                "telephone": "+380 (432) 46-53-02",
                "url": "http://sch10.edu.vn.ua/"
            },
            "identifier": {
                "id": "21725150",
                "legalName": "Заклад \"Загальноосвітня школа І-ІІІ ступенів № 10 Вінницької міської ради\"",
                "scheme": "UA-EDR"
            },
            "name": "ЗОСШ #10 м.Вінниці"
        },
        "status": "active.enquiries",
        "tenderID": "UA-2014-12-26-000050",
        "tenderPeriod": {
            "endDate": "2015-12-10T00:00:00+02:00",
            "startDate": "2015-12-01T00:00:00+02:00"
        },
        "value": {
            "amount": 500000.0,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        }
    }
}

You can see the access with token in response. Its value can be used to modify objects further under “Owner role”.

Using token

You can pass access token in following ways:

  1. acc_token URL query string parameter
  2. X-Access-Token HTTP request header
  3. access.token in the body of POST/PUT/PATCH request

See the example of the action with token passed as URL query string:

$ http --auth broker: -j PATCH https://api-sandbox.openprocurement.org/api/0/tenders/166b4a36611047a492d85c3693b86b4e?acc_token=953613dd25d6421588b2597504b747ed data:=@./school-tender-patch.json
PATCH /api/0/tenders/166b4a36611047a492d85c3693b86b4e?acc_token=953613dd25d6421588b2597504b747ed HTTP/1.1
Authorization: Basic YnJva2VyOg==
Content-Type: application/json; charset=utf-8

{
    "data": {
        "enquiryPeriod": {
            "endDate": "2015-05-29T00:00:00"
        },
        "items": [
            {
                "additionalClassifications": [
                    {
                        "description": "Послуги шкільних їдалень",
                        "id": "55.51.10.300",
                        "scheme": "ДКПП"
                    }
                ],
                "classification": {
                    "description": "Послуги з харчування у школах",
                    "id": "55523100-3",
                    "scheme": "CPV"
                },
                "description": "Послуги шкільних їдалень",
                "quantity": 9,
                "unit": {
                    "code": "MON",
                    "name": "month"
                }
            }
        ],
        "minimalStep": {
            "amount": 35000,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        },
        "tenderPeriod": {
            "endDate": "2015-06-07T10:00:00",
            "startDate": "2015-05-29T00:00:00"
        },
        "value": {
            "amount": 500000,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        }
    }
}

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

{
    "data": {
        "dateModified": "2014-12-26T21:30:58.424362+02:00",
        "enquiryPeriod": {
            "endDate": "2015-05-29T00:00:00+02:00",
            "startDate": "2014-12-26T21:30:56.522694+02:00"
        },
        "id": "166b4a36611047a492d85c3693b86b4e",
        "items": [
            {
                "additionalClassifications": [
                    {
                        "description": "Послуги шкільних їдалень",
                        "id": "55.51.10.300",
                        "scheme": "ДКПП"
                    }
                ],
                "classification": {
                    "description": "Послуги з харчування у школах",
                    "id": "55523100-3",
                    "scheme": "CPV"
                },
                "description": "Послуги шкільних їдалень",
                "quantity": 9,
                "unit": {
                    "code": "MON",
                    "name": "month"
                }
            }
        ],
        "minimalStep": {
            "amount": 35000.0,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        },
        "owner": "broker",
        "procuringEntity": {
            "address": {
                "countryName": "Україна",
                "locality": "м. Вінниця",
                "postalCode": "21027",
                "region": "м. Вінниця",
                "streetAddress": "вул. Стахурського. 22"
            },
            "contactPoint": {
                "name": "Куца Світлана Валентинівна",
                "telephone": "+380 (432) 46-53-02",
                "url": "http://sch10.edu.vn.ua/"
            },
            "identifier": {
                "id": "21725150",
                "legalName": "Заклад \"Загальноосвітня школа І-ІІІ ступенів № 10 Вінницької міської ради\"",
                "scheme": "UA-EDR"
            },
            "name": "ЗОСШ #10 м.Вінниці"
        },
        "status": "active.enquiries",
        "tenderID": "UA-2014-12-26-000050",
        "tenderPeriod": {
            "endDate": "2015-06-07T10:00:00+02:00",
            "startDate": "2015-05-29T00:00:00+02:00"
        },
        "value": {
            "amount": 500000.0,
            "currency": "UAH",
            "valueAddedTaxIncluded": true
        }
    }
}