# API Keys

### What is the API Keys feature:

A feature developed by Pier Cloud that allows you to create keys to integrate the customer environment with the Pier Cloud service API.

### How to use the API Keys feature:

1. The system will display the side menu with some configuration options, where the "**API Keys**" option must be selected:

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FgwUj4HPrOAZfG0LXUPmG%2Fimage.png?alt=media&#x26;token=68640c90-e45d-421c-8ac4-b28b40781c44" alt=""><figcaption></figcaption></figure>

2. On the main screen, the system allows you to view the list of registered API Keys and add new Keys by clicking the "**Add**" button:

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FezehZ9wOkzWExALnBC5d%2Fimage.png?alt=media&#x26;token=95331ad7-3042-4144-a78a-172576e163c6" alt=""><figcaption></figcaption></figure>

3. The screen for registering new organizations will be displayed, where you will need to enter the following information:

* **Name**: Provide the name of the organization or application you wish to register
* **Description**: Provide a brief description of the key to be created:
* **Scopes**: Enter the permission role scopes, which will identify the functionalities that the client will have access to and the type of access.
* **Token lifespan**: Determine the duration of the client's access key, by default it will be one hour, but the unit of minutes can also be used.
* **Unit**: Specify the unit of time that will be used in the token duration, which can be hours or minutes.
  * For hours, the system allows you to include a maximum of 24h
  * For minutes, the system allows you to include a maximum time of 55min

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FAYsopSn1hcGuMtqJgxPT%2Fimage.png?alt=media&#x26;token=425565de-7a9c-4ebb-a98c-ffa3745256cb" alt=""><figcaption></figcaption></figure>

After entering the necessary information, clicking on the "**Save**" button, the system will generate a **Client secret** to be copied, by clicking on the icon "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2Fjyt6ixcnOuCL2MSfv1JX%2Fimage.png?alt=media\&token=32d3582e-1b44-4267-8563-676d66c945eb)" and stored in a safe location.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FQoDKrSrWmoSQZ1awdVE3%2Fimage.png?alt=media&#x26;token=8234b576-086d-489c-9c89-4031959ddbd9" alt=""><figcaption></figcaption></figure>

* Note: When closing the window, the created secret will no longer be displayed and must be saved in a safe location before closing the window.

When you click **Close**, the system will return to the main API Keys screen, where the key created for the specified lifetime will be displayed.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FVYhYathywlex37ztj44V%2Fimage.png?alt=media&#x26;token=0e47872f-e74b-4c54-bc47-3870252824db" alt=""><figcaption></figcaption></figure>

4. Filters:&#x20;

On the main screen, the system allows you to apply some search filters:

* **API Keys**: You can search by the name of the key you want to view
* **Status**: You can also search by the status of the key, which are: All, Active and Inactive.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2F3ecCcNVF1u5tuvMPfMVf%2Fimage.png?alt=media&#x26;token=7639e42f-6036-4537-ab48-3d5e2e1b233d" alt=""><figcaption></figcaption></figure>

5. Actions:

The system also allows you to perform some actions for each registered organization:

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FTK0epUw9adRLDw3kQygT%2Fimage.png?alt=media&#x26;token=5734a7cd-96f1-4ca9-a074-042a61e155c6" alt=""><figcaption></figcaption></figure>

* **Copy to clipboard**: By clicking on the "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FFYCFapoqVbd73KmvDv5v%2Fimage.png?alt=media\&token=1f5f0e41-33bc-42fb-a122-ce21c99cdeb2)" icon, the system allows you to copy the information and paste it into a clipboard.
* **Activate / Deactivate**: By clicking on the "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FYe5b1HfINeRxwyRJzSzV%2Fimage.png?alt=media\&token=6086218b-d929-4bcd-bab6-ce3dc3ab0964)" icon, you can activate or deactivate the created key.
* **Delete**: By clicking on the trash can icon "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2Fsw0q8lGeyUsZsik3aC9A%2Fimage.png?alt=media\&token=9d608870-ef84-40cd-8fed-adf09dcbc710)", the system will display a confirmation message for the user to confirm the deletion of the key.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2Fny4I9cs5eSmPAzAwgojx%2Fimage.png?alt=media&#x26;token=c3e5074e-2bf0-4220-b3ae-158602e3a1d9" alt=""><figcaption></figcaption></figure>

* **Edit**: By clicking on the pencil icon "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FRGtX3B9bhWZf7GyVSbdi%2Fimage.png?alt=media\&token=3912baf3-f0c8-47a0-8d5b-5270d3dd82f9)", the system will open the editing screen, allowing you to change information such as: Name, Description, Scopes, Lifetime and Time Unit. It is not allowed to edit the Client ID.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FIK6ZryEzzyru8YlUYe3F%2Fimage.png?alt=media&#x26;token=fb48cdcc-ba53-4bb6-b6c0-4ce64197ac19" alt=""><figcaption></figcaption></figure>

* **Generate new client secret**: By clicking on the pencil key "![](https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FmUxyphh1O3R22ID7hh4C%2Fimage.png?alt=media\&token=201cbd98-eb7d-48cb-92ea-addc9a608ff4)",  the system allows you to generate a new client secret that will replace the previously generated client secret.

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2FCrc7TVJWgMxUnz6dCipW%2Fimage.png?alt=media&#x26;token=6d81eabc-a09b-49b0-b14e-3361b5edcae6" alt=""><figcaption></figcaption></figure>

By clicking on the "**Generate new client secret**" button, a window will be displayed with the new secret generated, so that it can be copied and stored in a safe location:

<figure><img src="https://1687673077-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ9sinLUl52lDK1vg6b8g%2Fuploads%2F7EjlnmBkeL1h1jDRk8Ko%2Fimage.png?alt=media&#x26;token=236f49a0-1c14-4edc-ad23-0af3030ae373" alt=""><figcaption></figcaption></figure>

Finally, to access the endpoints using this created key, we have additional documentation that can be accessed via this [link](https://docs.piercloud.com.br/api-docs-pier-cloud/api-pier-cloud/public-routes-en-us).
