Get a request status

Anytime you need to check the status of a Key Request, you can do so by sending a GET request to:

https://api.unloc.app/v1/partners/Your_Service_Provider_ID/key-requests/Your_Key_Request_ID

Example:

curl --location --request GET '<<api_url>>/v1/partners/<<service_provider_id>>/key-requests/<<key_request_id>>' \
--header 'Authorization: Bearer <<service_provider_api_key>>'

A successful response will look like this:

{
    "keyRequest": {
        "id": "<<key_request_id>>",
        "created": "2021-01-01T12:28:09.745Z",
        "receiverMsn": "+47666555444",
        "keyStart": "2021-01-01T19:48:00.000Z",
        "keyEnd": "2022-01-01T20:48:00.000Z",
        "message": "Your package delivery",
        "state": "pending",
        "keys": []
    }
}

Notice that the keys array is empty and the status is marked as pending. This is because the user is yet to approve the request.

If the user were to decline the Key Request, you would get a rejected status and should look for a way to engage with them again and reinitiate the approval flow (maybe the process's graphical User Experience wasn’t clear enough?).

On the other hand, when a request is approved, the status you get is accepted, and the keys array is populated with the keyId generated for each Lock. Here’s an example the status endpoint response after the user has approved the Key Request:

{
    "keyRequest": {
        "id": "<<key_request_id>>",
        "created": "2021-01-01T12:28:09.745Z",
        "receiverMsn": "+47666555444",
        "keyStart": "2021-01-01T19:48:00.000Z",
        "keyEnd": "2022-01-01T20:48:00.000Z",
        "message": "Your package delivery",
        "state": "accepted",
        "keys": [
            {
                "keyId": "fb5b68df-3a26-4bbe-eaad-a1b296bb1619"
            },
            {
                "keyId": "d59a92af-18be-481a-be00-21aefe3fdf16"
            }
        ]

    }
}

Need to get all of the Key Requests you have created? There's an endpoint for that!

Use the Get Key Requests endpoint to get a list with every Key Request you have created. This will be specially useful for your management dashboard to keep track of your service delivery.


What’s Next

Next up is the part of the process where you distribute Keys to the person that will provide the service.

Did this page help you?