diff --git a/docs/api-reference/generate-key.mdx b/docs/api-reference/generate-key.mdx new file mode 100644 index 0000000000..29d1b3b3e1 --- /dev/null +++ b/docs/api-reference/generate-key.mdx @@ -0,0 +1,44 @@ +--- +title: "Generate API Key" +icon: "key" +description: "Here is how you can generate an API key which gives you full access to the Formbricks Management API. Keep it safe!" +--- + + As of now, API keys are located in the Project Configuration page. We are moving them to the Organization Settings page in the upcoming release. For you, nothing will change. + + +## Generate API key + + + + Go to the Configuration page of your project: + ![Configuration Page](/images/api-reference/config.webp) + + + + Click on the **API Keys** tab. + + + + Decide if you want to generate a key for the development or production environment. If you want to switch environemnts you can do so in the top right corner. Click on the corresponding button. + + + + Add a label to your key to help you identify it. + ![Label key](/images/api-reference/label.webp) + + + + Copy the API key and save it in a secure location. You won't be able to see it again. + + Store API key safely! Anyone who has your API key has full control over your + account. For security reasons, you cannot view the API key again. + + + + +## Delete API key + +- On **Configuration** > **API Keys** page, find the key you wish to revoke and select “Delete”. + +- Your API key will stop working immediately. \ No newline at end of file diff --git a/docs/api-reference/introduction.mdx b/docs/api-reference/introduction.mdx deleted file mode 100644 index 854b65f0b0..0000000000 --- a/docs/api-reference/introduction.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "API v1.0.0" -icon: "code-compare" ---- - -Formbricks offers two types of APIs: the **Public Client API** and the **Management API**. Each API serves a different purpose, has *different* authentication requirements, and provides access to different data and settings. - -### API Key Setup - -Checkout the [API Key Setup](/api-reference/rest-api) to access the Management APIs with an API Key. - -If you’ve forked the collection and are running it, update the `apiKey` and `environmentId` in the collection variables with your values. We also provide post-run scripts to help auto-assign variables when running scripts. - -Need more help? Visit our [Website](https://formbricks.com/) or join our [Discord](https://formbricks.com/discord)! diff --git a/docs/api-reference/rest-api.mdx b/docs/api-reference/rest-api.mdx index 404099eca0..8adfd726e3 100644 --- a/docs/api-reference/rest-api.mdx +++ b/docs/api-reference/rest-api.mdx @@ -5,9 +5,8 @@ description: " Formbricks provides two APIs: the Public Client API for frontend survey interactions and the Management API for backend management tasks." --- - - View our [API Documentation](/api-reference) in more than 30 frameworks and languages. - +Formbricks offers two types of APIs: the **Public Client API** and the **Management API**. Each API serves a different purpose, has *different* authentication requirements, and provides access to different data and settings. + ## Public Client API @@ -17,7 +16,7 @@ We currently have the following Client API methods exposed and below is their do - [Displays API](/api-reference/client-api->-display/create-display) - Mark a survey as displayed or link a display to a response for a person. -- [People API](/api-reference/client-api->-people/create-person) - Create & Update a Person (e.g., attributes, email, userId, etc.) +- [Contacts API](/api-reference/client-api->-contacts/update-contact-attributes) - Update contact attributes. - [Responses API](/api-reference/client-api->-response/create-response) - Create & Update a Response for a Survey. @@ -41,88 +40,7 @@ We currently have the following Management API methods exposed and below is thei - [Webhook API](/api-reference/management-api->-webhook/get-all-webhooks) - List, Create, and Delete Webhooks -## How to Generate an API key -API requests require a personal API key for authorization. This API key gives you the same rights as if you were logged in at Formbricks UI - **keep it private!** - -- Go to your settings on [Formbricks UI](https://app.formbricks.com). - -- Go to page “API keys” - -![API Keys](https://res.cloudinary.com/dwdb9tvii/image/upload/v1738097810/image_jvhqsd.jpg) - -- Create a key for the development or production environment. - -- Copy the key immediately. You won’t be able to see it again. - -![API Key Label](https://res.cloudinary.com/dwdb9tvii/image/upload/v1738098072/image_zjkvok.jpg) - - - **Store API key safely! Anyone who has your API key has full control over your - account. For security reasons, you cannot view the API key again.** - - -## Test your API Key - -Hit the below request to verify that you are authenticated with your API Key and the server is responding. - -### Get My Profile - -Get the project details and environment type of your account. - -### Mandatory Headers - -| Name | x-Api-Key | -| --------------- | ------------------------ | -| **Type** | string | -| **Description** | Your Formbricks API key. | - -### Request - -```bash cURL -GET - /api/v1/me - -curl --location \ -'https://app.formbricks.com/api/v1/me' \ ---header \ -'x-api-key: ' -``` - -### Response - - - - -```bash 200 (Success) -{ - "id": "cll2m30r70004mx0huqkitgqv", - "createdAt": "2023-08-08T18:04:59.922Z", - "updatedAt": "2023-08-08T18:04:59.922Z", - "type": "production", - "project": { - "id": "cll2m30r60003mx0hnemjfckr", - "name": "My Project" - }, - "appSetupCompleted": false, - "websiteSetupCompleted": false, -} -``` - -```bash 401 (Not Authenticated) -Not authenticated -``` - - - -### Delete a personal API key - -- Go to settings on [app.formbricks.com](https://app.formbricks.com/). - -- Go to the page “API keys”. - -- Find the key you wish to revoke and select “Delete”. - -- Your API key will stop working immediately. --- diff --git a/docs/api-reference/test-key.mdx b/docs/api-reference/test-key.mdx new file mode 100644 index 0000000000..a2f55d3ceb --- /dev/null +++ b/docs/api-reference/test-key.mdx @@ -0,0 +1,50 @@ +--- +title: "Test API Key" +icon: "message-check" +description: "Here is how you can test your API key to make sure it is working." +--- + +To test if your API key is working, you can use the following request: + +### Mandatory Headers + +| Name | x-Api-Key | +| --------------- | ------------------------ | +| **Type** | string | +| **Description** | Your Formbricks API key. | + +### Request + +```bash cURL +GET - /api/v1/me + +curl --location \ +'https://app.formbricks.com/api/v1/me' \ +--header \ +'x-api-key: ' +``` + +### Response + + + + +```bash 200 (Success) +{ + "id": "cll2m30r70004mx0huqkitgqv", + "createdAt": "2023-08-08T18:04:59.922Z", + "updatedAt": "2023-08-08T18:04:59.922Z", + "type": "production", + "project": { + "id": "cll2m30r60003mx0hnemjfckr", + "name": "My Project" + }, + "appSetupCompleted": false, + "websiteSetupCompleted": false, +} +``` + +```bash 401 (Not Authenticated) +Not authenticated +``` + diff --git a/docs/images/api-reference/config.webp b/docs/images/api-reference/config.webp new file mode 100644 index 0000000000..09f2aefb5f Binary files /dev/null and b/docs/images/api-reference/config.webp differ diff --git a/docs/images/api-reference/label.webp b/docs/images/api-reference/label.webp new file mode 100644 index 0000000000..e41002841c Binary files /dev/null and b/docs/images/api-reference/label.webp differ diff --git a/docs/mint.json b/docs/mint.json index 0db5d8b1e0..57062bf1d5 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -289,7 +289,7 @@ }, { "group": "API Documentation", - "pages": ["api-reference/introduction", "api-reference/rest-api"] + "pages": ["api-reference/rest-api", "api-reference/generate-key", "api-reference/test-key"] } ], "redirects": [