# Device API

## Update Device Public Key Endpoint

Use this endpoint to update the public key of a registered device. To ensure that only a genuine device can update its public key, the device has to authenticate by providing a private key JWT. Furthermore the device has to provide a proof of possession (PoP) object to demonstrate possession of the private key corresponding to the public key it tries to update.

{% hint style="info" %}
For additional details about the JWT and the PoP object visit our [developer guide](https://iothentix.gitbook.io/developer-guide/json-web-token-jwt/update-public-key-jwt).
{% endhint %}

## Renew public key

<mark style="color:green;">`POST`</mark> `coaps://iot-idp.demo.coap-apps.iothentix.io/device/update/pubkey`

#### Request Body

| Name                                             | Type   | Description                               |
| ------------------------------------------------ | ------ | ----------------------------------------- |
| pop<mark style="color:red;">\*</mark>            | String | Proof of Possession object                |
| client\_secret<mark style="color:red;">\*</mark> | String | Signed JWT containing the new public key. |

{% tabs %}
{% tab title="400: Bad Request The request format was incorrect." %}

{% endtab %}

{% tab title="403: Forbidden The private key JWT was invalid." %}

{% endtab %}

{% tab title="500: Internal Server Error Internal error in the IdP infrastructure. " %}

{% endtab %}

{% tab title="201: Created Successful update of the registered public key" %}

```json
{
    "Success": "Public key updated"
}
```

{% endtab %}

{% tab title="405: Method Not Allowed The requested method is not allowed for this resource." %}

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iothentix.gitbook.io/api-reference/reference/coap-api-reference/device-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
