From 080aae3af78dcd827c65b08e5e6faa6f5917fafc Mon Sep 17 00:00:00 2001 From: mayabarak Date: Sun, 19 May 2024 17:38:20 +0300 Subject: [PATCH 1/7] add docs for approval flow api --- docs/embeddable-uis/element/approval-flow.mdx | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 docs/embeddable-uis/element/approval-flow.mdx diff --git a/docs/embeddable-uis/element/approval-flow.mdx b/docs/embeddable-uis/element/approval-flow.mdx new file mode 100644 index 00000000..dd95ced9 --- /dev/null +++ b/docs/embeddable-uis/element/approval-flow.mdx @@ -0,0 +1,343 @@ +--- +sidebar_position: 2 +title: Approval Flow API +--- +import HelpSupportTile from "@site/src/components/elements/HelpSupportTile.js"; +import ActionContainer from "@site/src/components/elements/ActionContainer.js"; +import ActionTile from "@site/src/components/elements/ActionTile.js"; +import CodeDropdown from "@site/src/components/elements/CodeDropdown.js"; +import FlexWrapper from "@site/src/components/elements/FlexWrapper.js"; +import code from "@site/src/components/elements/codeBlock.json"; + +# approval flow API + +The Approval Flow API allows to create approval requests for specific action in your application. It also assigns relevant moderators to approve or deny user requests based on your decision. + +:::note +You can also find information about the approval Flow API in the [Permit Redoc](https://api.permit.io/v2/redoc#tag/Access-Requests). +::: + +### Initializing Permit + + + {/* If you already use Permit, skip this step. */} + To use Permit Elements, you need to be a **user of Permit**. When starting to use Permit, you will need to + initialize an instance of Permit in your backend logic. This **only needs to be done once**, both to use Permit and Elements. + Remember to copy your `SDK Secret Key` and pass it into the initialized Permit object. + + + +### Server-side Login Route + +To allow your client to `loginAs` themselves and get access to the Permit Element you will need to create a route in your backend server. + +The backend `loginAs` route is matched based on the Authentication methods you have implemented inside your App. +Most applications authenticate using a **Bearer Token** or **Cookies**, but you can also use any other **HTTP Security Header**. +Make sure you use the right code example below depending on your authentication method. + +The `loginAs` function takes two parameters - a unique `userId` you get from your **JWT** (JSON Web Token), and a `tenant_key` or `tenantId`. + +```js +permit.elements.loginAs({ userId, tenant }); +``` + +:::info IMPORTANT +The **user must belong to the tenant** that they will be logged into. If not, you will see a login error saying `USER_NOT_FOUND`. + +If the user gets logged out, they also exit the current tenant specified in the `loginAs` method. If you want to **change tenants** for +a user, you need to **log them out**, and **log them back in** to a different tenant. +::: + +Passing in the tenant is **compulsory** when logging in a user **server-side**. + + + To get the cookie, in the `redirect_url` (that you will get + from the `ticket` object) you will have `get_cookie`. + + + +## API requests + +To use the Approval Request API, follow these steps: + +[Get your `API_SECRET_KEY`](/api/api-with-cli/#get-your-api-key) from the dashboard and [get the current `project_id` and `env_id`](/api/examples/get-project-and-env)
. +Replace `API_SECRET_KEY` with the key from the Permit dashboard, as well as the `project_id` and `env_id` you got from the API in the following commands. + +### Creating an Approval request + +To create a new approval request, make a POST request to the following with the required data. + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + -data-raw + { + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + } \ +``` + +The return approval request object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": null, + "reviewer_user_id": null, + "reviewed_at": null, + "reviewer_comment": null, +} +``` +## Reviewer actions: + +### 1. Get an approval request + +To get a specific approval request, make a GET request to the following. +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' +``` +The return approval request object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "string", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "approved", + "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", + "reviewed_at": "2019-08-24T14:15:22Z", + "reviewer_comment": "transfer for a new client", +} +``` +### 2. Get all the Approval Requests + +You can filter approval flows by passing the following headers: +- `status` - Status of the approval request +- `resource` - Resource key of the approval request +- `resource_instance` - Resource instance key of the approval request + +To get a list of approval requests, make the following GET request: + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + -H 'status: Status of the approval flow' + -H 'resource: Resource key of the approval flow' + -H 'resource_instance: Resource instance key of the approval flow' + -H 'page: Page number of the results to fetch' #Default: 1 + -H 'per_page: The number of results per page (max 100)' #Default: 30 +``` + +The return approval request object will look like this: +```json +{ + "data": [ + { + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "approved", + "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", + "reviewed_at": "2019-08-24T14:15:22Z", + "reviewer_comment": "transfer for a new client", + } + ], + "total_count": 1, + "page_count": 1 +} +``` +:::info Info +Users who are not designated as reviewers will only have visibility into their own approval requests. +::: + + +### 3. Updating Reviewer details in the approval request + +To update an approval request, make the following PATCH request (data is optional): + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/reviewer' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + --data-raw + "reviewer_comment": "transfer for a new client", + "role": "ac4e70c8-d5be-48af-93eb-760f58fc91a9", + } \ +``` + +The return approval flow object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "approved", + "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", + "reviewed_at": "2019-08-24T14:15:22Z", + "reviewer_comment": "transfer for a new client", +} +``` + + +### 4. Approve approval request + +To approve an approval request, make the following PUT request (data is optional): + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/approve' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + --data-raw + { + "reviewer_comment": "transfer for a new client", + }\ +``` + +The return user object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "approved", + "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", + "reviewed_at": "2019-08-24T14:15:22Z", + "reviewer_comment": "transfer for a new client", +} +``` + +### 5. Deny approval flow + +To deny an approval request, make the following PUT request (data is optional): + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{access_request_id}/deny' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + --data-raw + "reviewer_comment": "need more info", + }\ +``` + +The return approval request object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "deny", + "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", + "reviewed_at": "2019-08-24T14:15:22Z", + "reviewer_comment": "need more info", +} +``` + +## Users actions: + +### 1. Cancel approval request + +To cancel an approval request, make the following PUT request: + +```bash +curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/cancel' \ + -H 'cookie: ' + -H 'element_id: ELEMENTS_CONFIG_ID' + --data-raw +{ + "reason": "done onboarding last week", +} \ +``` +The return approval request object will look like this: +```json +{ + "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", + "approval_request_details": { + "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", + "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", + }, + "reason": "I need to make transfer for my client", + "org_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "env_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "status": "cancel", + "reviewer_user_id": null, + "reviewed_at": null, + "reviewer_comment": null, +} +``` From be8859e06e805463459f1f464726a8c9930309cf Mon Sep 17 00:00:00 2001 From: mayabarak Date: Sun, 19 May 2024 17:43:43 +0300 Subject: [PATCH 2/7] fix typo --- docs/embeddable-uis/element/approval-flow.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/embeddable-uis/element/approval-flow.mdx b/docs/embeddable-uis/element/approval-flow.mdx index dd95ced9..f9055e62 100644 --- a/docs/embeddable-uis/element/approval-flow.mdx +++ b/docs/embeddable-uis/element/approval-flow.mdx @@ -272,7 +272,7 @@ The return user object will look like this: } ``` -### 5. Deny approval flow +### 5. Deny approval request To deny an approval request, make the following PUT request (data is optional): From 24924ef0dd1a973df35852de647aaf00f972b5eb Mon Sep 17 00:00:00 2001 From: mayabarak Date: Sun, 19 May 2024 18:00:54 +0300 Subject: [PATCH 3/7] add tenant --- docs/embeddable-uis/element/approval-flow.mdx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/embeddable-uis/element/approval-flow.mdx b/docs/embeddable-uis/element/approval-flow.mdx index f9055e62..c95d781c 100644 --- a/docs/embeddable-uis/element/approval-flow.mdx +++ b/docs/embeddable-uis/element/approval-flow.mdx @@ -104,7 +104,8 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "approval_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -219,7 +220,8 @@ The return approval flow object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "approval_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -255,7 +257,8 @@ The return user object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "approval_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -290,6 +293,7 @@ The return approval request object will look like this: { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", "approval_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -325,7 +329,8 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "approval_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, From 5030847fe750ab46d33c84a041ed19a34d26e4fa Mon Sep 17 00:00:00 2001 From: mayabarak Date: Tue, 21 May 2024 10:22:54 +0300 Subject: [PATCH 4/7] rename --- docs/embeddable-uis/element/approval-flow.mdx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/embeddable-uis/element/approval-flow.mdx b/docs/embeddable-uis/element/approval-flow.mdx index c95d781c..b79e2d39 100644 --- a/docs/embeddable-uis/element/approval-flow.mdx +++ b/docs/embeddable-uis/element/approval-flow.mdx @@ -1,6 +1,6 @@ --- sidebar_position: 2 -title: Approval Flow API +title: Approval Process API --- import HelpSupportTile from "@site/src/components/elements/HelpSupportTile.js"; import ActionContainer from "@site/src/components/elements/ActionContainer.js"; @@ -9,9 +9,9 @@ import CodeDropdown from "@site/src/components/elements/CodeDropdown.js"; import FlexWrapper from "@site/src/components/elements/FlexWrapper.js"; import code from "@site/src/components/elements/codeBlock.json"; -# approval flow API +# Approval Process API -The Approval Flow API allows to create approval requests for specific action in your application. It also assigns relevant moderators to approve or deny user requests based on your decision. +The Approval Process API allows to create approval requests for specific action in your application. It also assigns relevant moderators to approve or deny user requests based on your decision. :::note You can also find information about the approval Flow API in the [Permit Redoc](https://api.permit.io/v2/redoc#tag/Access-Requests). @@ -92,7 +92,7 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ -H 'element_id: ELEMENTS_CONFIG_ID' -data-raw { - "approval_request_details": { + "access_request_details": { "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -104,7 +104,7 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", @@ -135,7 +135,7 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -153,7 +153,7 @@ The return approval request object will look like this: ``` ### 2. Get all the Approval Requests -You can filter approval flows by passing the following headers: +You can filter approval processs by passing the following headers: - `status` - Status of the approval request - `resource` - Resource key of the approval request - `resource_instance` - Resource instance key of the approval request @@ -164,9 +164,9 @@ To get a list of approval requests, make the following GET request: curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ -H 'cookie: ' -H 'element_id: ELEMENTS_CONFIG_ID' - -H 'status: Status of the approval flow' - -H 'resource: Resource key of the approval flow' - -H 'resource_instance: Resource instance key of the approval flow' + -H 'status: Status of the approval process' + -H 'resource: Resource key of the approval process' + -H 'resource_instance: Resource instance key of the approval process' -H 'page: Page number of the results to fetch' #Default: 1 -H 'per_page: The number of results per page (max 100)' #Default: 30 ``` @@ -177,7 +177,8 @@ The return approval request object will look like this: "data": [ { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -212,15 +213,14 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approv -H 'element_id: ELEMENTS_CONFIG_ID' --data-raw "reviewer_comment": "transfer for a new client", - "role": "ac4e70c8-d5be-48af-93eb-760f58fc91a9", } \ ``` -The return approval flow object will look like this: +The return approval process object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", @@ -257,7 +257,7 @@ The return user object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", @@ -292,7 +292,7 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", @@ -329,7 +329,7 @@ The return approval request object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", - "approval_request_details": { + "access_request_details": { "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", From c142621380037b4a02c101d8b6ca2696e07a3e04 Mon Sep 17 00:00:00 2001 From: mayabarak Date: Tue, 21 May 2024 10:23:20 +0300 Subject: [PATCH 5/7] rename file --- .../element/{approval-flow.mdx => approval-process.mdx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/embeddable-uis/element/{approval-flow.mdx => approval-process.mdx} (100%) diff --git a/docs/embeddable-uis/element/approval-flow.mdx b/docs/embeddable-uis/element/approval-process.mdx similarity index 100% rename from docs/embeddable-uis/element/approval-flow.mdx rename to docs/embeddable-uis/element/approval-process.mdx From 1f360c51a97c9f1f1c2a8eb5e3f7d74d3a563bf8 Mon Sep 17 00:00:00 2001 From: mayabarak Date: Tue, 28 May 2024 14:18:53 +0300 Subject: [PATCH 6/7] rename --- ...val-process.mdx => operation_approval.mdx} | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) rename docs/embeddable-uis/element/{approval-process.mdx => operation_approval.mdx} (85%) diff --git a/docs/embeddable-uis/element/approval-process.mdx b/docs/embeddable-uis/element/operation_approval.mdx similarity index 85% rename from docs/embeddable-uis/element/approval-process.mdx rename to docs/embeddable-uis/element/operation_approval.mdx index b79e2d39..e33900d2 100644 --- a/docs/embeddable-uis/element/approval-process.mdx +++ b/docs/embeddable-uis/element/operation_approval.mdx @@ -1,6 +1,6 @@ --- sidebar_position: 2 -title: Approval Process API +title: Operation Approval API --- import HelpSupportTile from "@site/src/components/elements/HelpSupportTile.js"; import ActionContainer from "@site/src/components/elements/ActionContainer.js"; @@ -9,9 +9,9 @@ import CodeDropdown from "@site/src/components/elements/CodeDropdown.js"; import FlexWrapper from "@site/src/components/elements/FlexWrapper.js"; import code from "@site/src/components/elements/codeBlock.json"; -# Approval Process API +# Operation Approval API -The Approval Process API allows to create approval requests for specific action in your application. It also assigns relevant moderators to approve or deny user requests based on your decision. +The Operation Approval API allows to create operation approvals for specific action in your application. It also assigns relevant moderators to approve or deny user requests based on your decision. :::note You can also find information about the approval Flow API in the [Permit Redoc](https://api.permit.io/v2/redoc#tag/Access-Requests). @@ -84,7 +84,7 @@ Replace `API_SECRET_KEY` with the key from the Permit dashboard, as well as the ### Creating an Approval request -To create a new approval request, make a POST request to the following with the required data. +To create a new operation approval, make a POST request to the following with the required data. ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ @@ -93,14 +93,14 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ -data-raw { "access_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", - "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, "reason": "I need to make transfer for my client", } \ ``` -The return approval request object will look like this: +The return operation approval object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", @@ -119,23 +119,25 @@ The return approval request object will look like this: "reviewer_user_id": null, "reviewed_at": null, "reviewer_comment": null, + "type": "operation_approval" } ``` ## Reviewer actions: -### 1. Get an approval request +### 1. Get an operation approval -To get a specific approval request, make a GET request to the following. +To get a specific operation approval, make a GET request to the following. ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}' \ -H 'cookie: ' -H 'element_id: ELEMENTS_CONFIG_ID' ``` -The return approval request object will look like this: +The return operation approval object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", "access_request_details": { + "tenant": "34f5c98e-f430-457b-a812-92637d0c6fd0", "resource": "4d5215ed-38bb-48ed-879a-fdb9ca58522f", "resource_instance": "2d98d9f8-e1b7-4f1d-baad-2edbf6fa6c66", }, @@ -149,16 +151,17 @@ The return approval request object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "transfer for a new client", + "type": "operation_approval" } ``` ### 2. Get all the Approval Requests You can filter approval processs by passing the following headers: -- `status` - Status of the approval request -- `resource` - Resource key of the approval request -- `resource_instance` - Resource instance key of the approval request +- `status` - Status of the operation approval +- `resource` - Resource key of the operation approval +- `resource_instance` - Resource instance key of the operation approval -To get a list of approval requests, make the following GET request: +To get a list of operation approvals, make the following GET request: ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ @@ -171,7 +174,7 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow' \ -H 'per_page: The number of results per page (max 100)' #Default: 30 ``` -The return approval request object will look like this: +The return operation approval object will look like this: ```json { "data": [ @@ -192,6 +195,7 @@ The return approval request object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "transfer for a new client", + "type": "operation_approval" } ], "total_count": 1, @@ -199,13 +203,13 @@ The return approval request object will look like this: } ``` :::info Info -Users who are not designated as reviewers will only have visibility into their own approval requests. +Users who are not designated as reviewers will only have visibility into their own operation approvals. ::: -### 3. Updating Reviewer details in the approval request +### 3. Updating Reviewer details in the operation approval -To update an approval request, make the following PATCH request (data is optional): +To update an operation approval, make the following PATCH request (data is optional): ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/reviewer' \ @@ -235,13 +239,14 @@ The return approval process object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "transfer for a new client", + "type": "operation_approval" } ``` -### 4. Approve approval request +### 4. Approve operation approval -To approve an approval request, make the following PUT request (data is optional): +To approve an operation approval, make the following PUT request (data is optional): ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/approve' \ @@ -272,12 +277,13 @@ The return user object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "transfer for a new client", + "type": "operation_approval" } ``` -### 5. Deny approval request +### 5. Deny operation approval -To deny an approval request, make the following PUT request (data is optional): +To deny an operation approval, make the following PUT request (data is optional): ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{access_request_id}/deny' \ @@ -288,7 +294,7 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{access }\ ``` -The return approval request object will look like this: +The return operation approval object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", @@ -307,14 +313,15 @@ The return approval request object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "need more info", + "type": "operation_approval" } ``` ## Users actions: -### 1. Cancel approval request +### 1. Cancel operation approval -To cancel an approval request, make the following PUT request: +To cancel an operation approval, make the following PUT request: ```bash curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approval_request_id}/cancel' \ @@ -325,7 +332,7 @@ curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/approval_flow/{approv "reason": "done onboarding last week", } \ ``` -The return approval request object will look like this: +The return operation approval object will look like this: ```json { "requesting_user_id": "1c1e4ada-f282-40e6-b3b7-20b3a51c93b5", @@ -344,5 +351,6 @@ The return approval request object will look like this: "reviewer_user_id": null, "reviewed_at": null, "reviewer_comment": null, + "type": "operation_approval" } ``` From ddb779722309a9c875d8d0950f527a32113f34ca Mon Sep 17 00:00:00 2001 From: mayabarak Date: Tue, 4 Jun 2024 15:29:56 +0300 Subject: [PATCH 7/7] add values to list --- docs/embeddable-uis/element/operation_approval.mdx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/embeddable-uis/element/operation_approval.mdx b/docs/embeddable-uis/element/operation_approval.mdx index e33900d2..8d66c321 100644 --- a/docs/embeddable-uis/element/operation_approval.mdx +++ b/docs/embeddable-uis/element/operation_approval.mdx @@ -156,7 +156,7 @@ The return operation approval object will look like this: ``` ### 2. Get all the Approval Requests -You can filter approval processs by passing the following headers: +You can filter approval processes by passing the following headers: - `status` - Status of the operation approval - `resource` - Resource key of the operation approval - `resource_instance` - Resource instance key of the operation approval @@ -195,7 +195,12 @@ The return operation approval object will look like this: "reviewer_user_id": "1b287364-14ff-4b72-8953-b40399093a6f", "reviewed_at": "2019-08-24T14:15:22Z", "reviewer_comment": "transfer for a new client", - "type": "operation_approval" + "type": "operation_approval", + "requesting_user_email": "maya@permit.io", + "requesting_user_first_name": "Maya", + "requesting_user_last_name": "Barak", + "resource_key": "transfer", + "resource_instance_key": "transfer-1", } ], "total_count": 1,