2
0

📝 Introduce auto generate API doc

This commit is contained in:
Baptiste Arnaud
2022-11-22 17:30:20 +01:00
parent 04af489119
commit 11695efb57
60 changed files with 1480 additions and 914 deletions

View File

@ -1,118 +0,0 @@
import { Required, Optional, Tag } from '../src/js/api-helpers.js'
# API documentation
Each request must be authenticated with an API key using the Bearer Token method. You can obtain an API key for your account by going to your user settings.
The API is a work in progress. The current version is dedicated to Automation services that wish to implement a native Typebot integration.
## Endpoints
### <Tag color="green">GET</Tag> /api/users/me
Get authenticated user information:
```bash title="Try it yourself"
curl -i -X GET https://typebot.io/api/users/me \
-H 'Authorization: Bearer ${TOKEN}'
```
```json title="Response 200 OK"
{ "id": "userid", "email": "user@email.com" }
```
### <Tag color="green">GET</Tag> /api/typebots
List user's typebots:
```bash title="Try it yourself"
curl -i -X GET https://typebot.io/api/typebots \
-H 'Authorization: Bearer ${TOKEN}'
```
```json title="Response 200 OK"
{
"typebots": [
{
"name": "My typebot 1",
"id": "typebot1"
},
{
"name": "My typebot 2",
"id": "typebot2"
}
]
}
```
### <Tag color="green">GET</Tag> /api/typebots/<Tag>typebotId</Tag>/webhookBlocks
List webhook blocks in a typebot. These are the blocks you can register a Webhook URL:
```bash title="Try it yourself"
curl -i -X GET https://typebot.io/api/typebots/$TYPEBOT_ID/webhookBlocks \
-H 'Authorization: Bearer ${TOKEN}'
```
```json title="Response 200 OK"
{
"blocks": [
{
"blockId": "blockId",
"name": "Group #2 > blockId",
"url": "https://my-webhook.com/webhook"
}
]
}
```
### <Tag color="green">GET</Tag> /api/typebots/<Tag>typebotId</Tag>/blocks/<Tag>blockId</Tag>/sampleResult
Get a sample of what the webhook body will look like when triggered
```bash title="Try it yourself"
curl -i -X GET https://typebot.io/api/typebots/$TYPEBOT_ID/blocks/$BLOCK_ID/sampleResult \
-H 'Authorization: Bearer ${TOKEN}'
```
### <Tag color="orange">POST</Tag> /api/typebots/<Tag>typebotId</Tag>/blocks/<Tag>blockId</Tag>/subscribeWebhook
Subscribe the block to a specified webhook URL
```bash title="Try it yourself"
curl -i -X POST https://typebot.io/api/typebots/$TYPEBOT_ID/blocks/$BLOCK_ID/subscribeWebhook \
-H 'Authorization: Bearer ${TOKEN}'\
--header 'Content-Type: application/json' \
--data '{"url": "https://domain.com/my-webhook"}'
```
```json title="Response 200 OK"
{
"message": "success"
}
```
#### JSON body data
<hr />
**url** <Required />
The url you want to subscribe to.
<hr />
### <Tag color="orange">POST</Tag> /api/typebots/<Tag>typebotId</Tag>/blocks/<Tag>blockId</Tag>/unsubscribeWebhook
Unsubscribe the current webhook on block
```bash title="Try it yourself"
curl -i -X POST https://typebot.io/api/typebots/$TYPEBOT_ID/blocks/$BLOCK_ID/unsubscribeWebhook \
-H 'Authorization: Bearer ${TOKEN}'\
```
```json title="Response 200 OK"
{
"message": "success"
}
```