mirror of https://github.com/nocodb/nocodb
Browse Source
* docs: dev resources * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/050.upload-via-api.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: review comments Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --------- Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>pull/8628/head
Raju Udava
6 months ago
committed by
GitHub
9 changed files with 665 additions and 0 deletions
@ -0,0 +1,86 @@ |
|||||||
|
--- |
||||||
|
title: 'Overview' |
||||||
|
description: 'NocoDB REST API Overview' |
||||||
|
--- |
||||||
|
|
||||||
|
Once you've created the schemas, you can manipulate the data or invoke actions using the REST APIs. We provide several types of APIs for different usages. Refer to the following links for more details: |
||||||
|
|
||||||
|
[Meta APIs](https://meta-apis-v2.nocodb.com/) |
||||||
|
|
||||||
|
- [Data APIs](https://data-apis-v2.nocodb.com/) |
||||||
|
|
||||||
|
Additional information on the REST APIs is provided below. |
||||||
|
|
||||||
|
## Query params |
||||||
|
|
||||||
|
| **Name** | **Alias** | **Use case** | **Default value** |**Example value** | |
||||||
|
|---|---|---|---|---| |
||||||
|
| [where](#comparison-operators) | [w](#comparison-operators) | Complicated where conditions | | `(colName,eq,colValue)~or(colName2,gt,colValue2)` <br />[Usage: Comparison operators](#comparison-operators) <br />[Usage: Logical operators](#logical-operators) | |
||||||
|
| limit | l | Number of rows to get (SQL limit value) | 10 | 20 | |
||||||
|
| offset | o | Offset for pagination (SQL offset value) | 0 | 20 | |
||||||
|
| sort | s | Sort by column name, Use `-` as a prefix for descending sort | | column_name | |
||||||
|
| fields | f | Required column names in result | * | column_name1,column_name2 | |
||||||
|
| shuffle | r | Shuffle the result for pagination | 0 | 1 (Only allow 0 or 1. Other values would see it as 0) | |
||||||
|
|
||||||
|
|
||||||
|
## Comparison Operators |
||||||
|
|
||||||
|
| Operation | Meaning | Example | |
||||||
|
|---|---|---| |
||||||
|
| eq | equal | (colName,eq,colValue) | |
||||||
|
| neq | not equal | (colName,neq,colValue) | |
||||||
|
| not | not equal (alias of neq) | (colName,not,colValue) | |
||||||
|
| gt | greater than | (colName,gt,colValue) | |
||||||
|
| ge | greater or equal | (colName,ge,colValue) | |
||||||
|
| lt | less than | (colName,lt,colValue) | |
||||||
|
| le | less or equal | (colName,le,colValue) | |
||||||
|
| is | is | (colName,is,true/false/null) | |
||||||
|
| isnot | is not | (colName,isnot,true/false/null) | |
||||||
|
| in | in | (colName,in,val1,val2,val3,val4) | |
||||||
|
| btw | between | (colName,btw,val1,val2) | |
||||||
|
| nbtw | not between | (colName,nbtw,val1,val2) | |
||||||
|
| like | like | (colName,like,%name) | |
||||||
|
| nlike | not like | (colName,nlike,%name) | |
||||||
|
| isWithin | is Within (Available in `Date` and `DateTime` only) | (colName,isWithin,sub_op) | |
||||||
|
| allof | includes all of | (colName,allof,val1,val2,...) | |
||||||
|
| anyof | includes any of | (colName,anyof,val1,val2,...) | |
||||||
|
| nallof | does not include all of (includes none or some, but not all of) | (colName,nallof,val1,val2,...) | |
||||||
|
| nanyof | does not include any of (includes none of) | (colName,nanyof,val1,val2,...) | |
||||||
|
|
||||||
|
## Comparison Sub-Operators |
||||||
|
|
||||||
|
The following sub-operators are available in the `Date` and `DateTime` columns. |
||||||
|
|
||||||
|
| Operation | Meaning | Example | |
||||||
|
|-----------------|-------------------------|-----------------------------------| |
||||||
|
| today | today | (colName,eq,today) | |
||||||
|
| tomorrow | tomorrow | (colName,eq,tomorrow) | |
||||||
|
| yesterday | yesterday | (colName,eq,yesterday) | |
||||||
|
| oneWeekAgo | one week ago | (colName,eq,oneWeekAgo) | |
||||||
|
| oneWeekFromNow | one week from now | (colName,eq,oneWeekFromNow) | |
||||||
|
| oneMonthAgo | one month ago | (colName,eq,oneMonthAgo) | |
||||||
|
| oneMonthFromNow | one month from now | (colName,eq,oneMonthFromNow) | |
||||||
|
| daysAgo | number of days ago | (colName,eq,daysAgo,10) | |
||||||
|
| daysFromNow | number of days from now | (colName,eq,daysFromNow,10) | |
||||||
|
| exactDate | exact date | (colName,eq,exactDate,2022-02-02) | |
||||||
|
|
||||||
|
For `isWithin` in `Date` and `DateTime` columns, the different set of sub-operators are used. |
||||||
|
|
||||||
|
| Operation | Meaning | Example | |
||||||
|
|------------------|-------------------------|-----------------------------------------| |
||||||
|
| pastWeek | the past week | (colName,isWithin,pastWeek) | |
||||||
|
| pastMonth | the past month | (colName,isWithin,pastMonth) | |
||||||
|
| pastYear | the past year | (colName,isWithin,pastYear) | |
||||||
|
| nextWeek | the next week | (colName,isWithin,nextWeek) | |
||||||
|
| nextMonth | the next month | (colName,isWithin,nextMonth) | |
||||||
|
| nextYear | the next year | (colName,isWithin,nextYear) | |
||||||
|
| nextNumberOfDays | the next number of days | (colName,isWithin,nextNumberOfDays,10) | |
||||||
|
| pastNumberOfDays | the past number of days | (colName,isWithin,pastNumberOfDays,10) | |
||||||
|
|
||||||
|
## Logical Operators |
||||||
|
|
||||||
|
| Operation | Example | |
||||||
|
|---|---| |
||||||
|
| ~or | (checkNumber,eq,JM555205)~or((amount,gt,200)~and(amount,lt,2000)) | |
||||||
|
| ~and | (checkNumber,eq,JM555205)~and((amount,gt,200)~and(amount,lt,2000)) | |
||||||
|
| ~not | ~not(checkNumber,eq,JM555205) | |
@ -0,0 +1,15 @@ |
|||||||
|
--- |
||||||
|
title: 'Accessing APIs' |
||||||
|
description: 'How to access NocoDB APIs with Auth or API token?' |
||||||
|
--- |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## API Tokens |
||||||
|
|
||||||
|
NocoDB APIs can be authorized by using API Tokens. API tokens allow us to integrate seamlessly with 3rd party apps. See [API Tokens Management](/account-settings/api-tokens) for more. |
||||||
|
|
||||||
|
## Swagger UI |
||||||
|
|
||||||
|
You can interact with the API's resources via the Swagger UI. For more details, see [Swagger APIs Doc](/bases/actions-on-base/#rest-apis) |
||||||
|
|
@ -0,0 +1,137 @@ |
|||||||
|
--- |
||||||
|
title: 'Upload via API' |
||||||
|
description: 'Upload files locally present or from public remote URL via API' |
||||||
|
hide_table_of_contents: true |
||||||
|
--- |
||||||
|
|
||||||
|
Sample code to upload files via API is listed below. |
||||||
|
Assumes `http://localhost:8080/` as the base URL for the API calls. |
||||||
|
|
||||||
|
# Upload local file |
||||||
|
|
||||||
|
```javascript |
||||||
|
let axios = require("axios").default; |
||||||
|
let FormData = require('form-data'); |
||||||
|
let fs = require('fs'); |
||||||
|
|
||||||
|
// Configurations |
||||||
|
// |
||||||
|
const project_id = '<Project Identifier>'; |
||||||
|
const table_id = '<Table Identifier>'; |
||||||
|
const xc_token = '<Auth Token>'; |
||||||
|
const file_path = '<Local File Path>'; |
||||||
|
|
||||||
|
|
||||||
|
// Insert Image |
||||||
|
// @param image_path : local file path |
||||||
|
// @return : JSON object to be used in insert record API for attachment field |
||||||
|
// |
||||||
|
async function insertImage (path) { |
||||||
|
const formData = new FormData(); |
||||||
|
formData.append("file", fs.createReadStream(path)); |
||||||
|
const data = await axios({ |
||||||
|
url: 'http://localhost:8080/api/v2/storage/upload', |
||||||
|
data: formData, |
||||||
|
headers:{ |
||||||
|
'Content-Type':`multipart/form-data;`, |
||||||
|
'xc-token': xc_token |
||||||
|
}, |
||||||
|
method: 'post', |
||||||
|
|
||||||
|
// Optional : storage file path |
||||||
|
params: {"path": "somePath"} |
||||||
|
}); |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
// Insert record with attachment |
||||||
|
// Assumes a table with two columns : |
||||||
|
// 'Title' of type SingleLineText and |
||||||
|
// 'Attachment' of type Attachment |
||||||
|
// |
||||||
|
async function uploadFileExample() { |
||||||
|
let response = await insertImage(file_path); |
||||||
|
|
||||||
|
let row = { |
||||||
|
"Title": "2", |
||||||
|
"Attachment": response.data |
||||||
|
}; |
||||||
|
|
||||||
|
await axios({ |
||||||
|
method: 'POST', |
||||||
|
url: `http://localhost:8080/api/v2/tables/${table_id}/records`, |
||||||
|
data: row, |
||||||
|
headers: { |
||||||
|
'xc-token': xc_token |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
(async () => { |
||||||
|
await uploadFileExample(); |
||||||
|
})(); |
||||||
|
``` |
||||||
|
|
||||||
|
# Upload via URL |
||||||
|
|
||||||
|
```javascript |
||||||
|
let axios = require("axios").default; |
||||||
|
let FormData = require('form-data'); |
||||||
|
let fs = require('fs'); |
||||||
|
|
||||||
|
// Configurations |
||||||
|
// |
||||||
|
const project_id = '<Project Identifier>'; |
||||||
|
const table_id = '<Table Identifier>'; |
||||||
|
const xc_token = '<Auth Token>'; |
||||||
|
|
||||||
|
// URL array : URLs of files to be uploaded |
||||||
|
const URLs = [{ url: '<URL1>' }, { url: '<URL2>' }]; |
||||||
|
|
||||||
|
// Insert Image |
||||||
|
// @param URLs : [] containing public URL for files to be uploaded |
||||||
|
// @return : JSON object to be used in insert record API for attachment field |
||||||
|
// |
||||||
|
async function insertImageByURL (URL_array) { |
||||||
|
const data = await axios({ |
||||||
|
url: 'http://localhost:8080/api/v2/storage/upload-by-url', |
||||||
|
data: URL_array, |
||||||
|
headers: { |
||||||
|
'xc-token': xc_token |
||||||
|
}, |
||||||
|
method: 'post', |
||||||
|
|
||||||
|
// Optional : storage file path |
||||||
|
params: {"path": "somePath"} |
||||||
|
}); |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
// Insert record with attachment |
||||||
|
// Assumes a table with two columns : |
||||||
|
// 'Title' of type SingleLineText and |
||||||
|
// 'Attachment' of type Attachment |
||||||
|
// |
||||||
|
async function uploadByUrlExample() { |
||||||
|
let response = await insertImageByURL(URLs); |
||||||
|
|
||||||
|
// Update two columns : Title and Attachment |
||||||
|
let row = { |
||||||
|
"Title": "3", |
||||||
|
"Attachment": response.data |
||||||
|
}; |
||||||
|
|
||||||
|
await axios({ |
||||||
|
method: 'POST', |
||||||
|
url: `http://localhost:8080/api/v2/tables/${table_id}/records`, |
||||||
|
data: row, |
||||||
|
headers: { |
||||||
|
'xc-token': xc_auth |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
(async () => { |
||||||
|
await uploadByUrlExample(); |
||||||
|
})(); |
||||||
|
``` |
@ -0,0 +1,8 @@ |
|||||||
|
{ |
||||||
|
"label": "REST APIs", |
||||||
|
"collapsible": true, |
||||||
|
"collapsed": true, |
||||||
|
"link": { |
||||||
|
"type": "generated-index" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
--- |
||||||
|
title: 'Webhook overview' |
||||||
|
description: 'Learn how to create, modify and delete webhooks.' |
||||||
|
tags: ['Webhook', 'Overview'] |
||||||
|
keywords: ['Webhook overview', 'NocoDB webhook', 'create webhook', 'modify webhook', 'delete webhook'] |
||||||
|
--- |
||||||
|
|
||||||
|
You can employ webhooks to notify external systems whenever there are additions, updates, or removals of records within NocoDB. This feature allows you to receive instantaneous notifications for any changes made to your database. NocoDB also offers webhooks for bulk endpoints for creating, updating, or deleting multiple records simultaneously. |
||||||
|
|
||||||
|
Note that, Webhooks currently are specific to associated table. |
||||||
|
|
||||||
|
- [Create Webhook](create-webhook) |
||||||
|
- [Disable Webhook](actions-on-webhook#enable/disable-webhook) |
||||||
|
- [Modify Webhook](actions-on-webhook#edit-webhook) |
||||||
|
- [Duplicate Webhook](actions-on-webhook#duplicate-webhook) |
||||||
|
- [Delete Webhook](actions-on-webhook#delete-webhook) |
||||||
|
|
@ -0,0 +1,340 @@ |
|||||||
|
--- |
||||||
|
title: 'Create webhook' |
||||||
|
description: 'Learn how to create a webhook in NocoDB.' |
||||||
|
tags: ['Webhook', 'Create'] |
||||||
|
keywords: ['NocoDB webhook', 'create webhook'] |
||||||
|
--- |
||||||
|
|
||||||
|
## Create Webhook |
||||||
|
|
||||||
|
### Accessing webhook page |
||||||
|
|
||||||
|
1. Click on table for which webhook needs to be configured on the left sidebar |
||||||
|
2. Open `Details` tab in topbar, |
||||||
|
3. Click on `Webhooks` tab |
||||||
|
4. Click `Add New Webhook` |
||||||
|
|
||||||
|
![Accessing webhook](/img/v2/webhook/create-webhook-1.png) |
||||||
|
|
||||||
|
### Configuring webhook |
||||||
|
|
||||||
|
1. Name of the webhook |
||||||
|
2. Select the event for which webhook needs to be triggered |
||||||
|
|
||||||
|
| Trigger | Details | |
||||||
|
|-------------------|-------------------------------------| |
||||||
|
| After Insert | After a single record is inserted | |
||||||
|
| After Update | After a single record is updated | |
||||||
|
| After Delete | After a single record is deleted | |
||||||
|
| After Bulk Insert | After bulk records are inserted | |
||||||
|
| After Bulk Update | After bulk records are updated | |
||||||
|
| After Bulk Delete | After bulk records are deleted | |
||||||
|
|
||||||
|
3. Method & URL: Configure the endpoint to which webhook needs to be triggered. Supported methods are GET, POST, DELETE, PUT, HEAD, PATCH |
||||||
|
4. Headers & Parameters: Configure Request headers & parameters (optional) |
||||||
|
5. Condition: Only records meeting the configured criteria will trigger webhook (optional) |
||||||
|
6. Test webhook (with sample payload) to verify if parameter are configured appropriately (optional) |
||||||
|
7. Save the webhook |
||||||
|
|
||||||
|
![Configuring webhook](/img/v2/automations/webhooks/create-webhook-2.png) |
||||||
|
|
||||||
|
|
||||||
|
### Webhook with conditions |
||||||
|
|
||||||
|
In case of webhook with conditions, only records meeting the configured criteria will trigger webhook. For example, trigger webhook only when `Status` is `Complete`. You can also configure multiple conditions using `AND` or `OR` operators. For example, trigger webhook only when `Status` is `Complete` and `Priority` is `High`. |
||||||
|
|
||||||
|
The webhook will be triggered only when the configured condition wasn't met before the record was updated. For example, if you have configured webhook with condition `Status` `is` `Complete` and `Priority` `is` `High` and you update the record with `Status` `Complete` and `Priority` `Low` to `High`, webhook will be triggered. However, if you update any other fields of the record with `Status` `Complete` and `Priority` `High`, webhook won't be triggered. |
||||||
|
|
||||||
|
In summary, the webhook will be triggered only when `Condition(old-record) = false` and `Condition(new-record) = true`. |
||||||
|
|
||||||
|
### Webhook response sample |
||||||
|
|
||||||
|
<Tabs> |
||||||
|
<TabItem value="After Insert" label="After Insert"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.insert", |
||||||
|
"id": "9dac1c54-b3be-49a1-a676-af388145fa8c", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_736wrpoas7tr0c", |
||||||
|
"view_name": "Film", |
||||||
|
"records": [ |
||||||
|
{ |
||||||
|
"FilmId": 1011, |
||||||
|
"Title": "FOO", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
<TabItem value="After Update" label="After Update"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.update", |
||||||
|
"id": "6a6ebfe4-b0b5-434e-b5d6-5212adbf82fa", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_736wrpoas7tr0c", |
||||||
|
"view_name": "Film", |
||||||
|
"previous_records": [ |
||||||
|
{ |
||||||
|
"FilmId": 1, |
||||||
|
"Title": "ACADEMY DINOSAUR", |
||||||
|
"Description": "A Epic Drama of a Feminist in The Canadian Rockies", |
||||||
|
"Actor List": [ |
||||||
|
{ |
||||||
|
"ActorId": 10, |
||||||
|
"FirstName": "CHRISTIAN" |
||||||
|
} |
||||||
|
], |
||||||
|
} |
||||||
|
], |
||||||
|
"records": [ |
||||||
|
{ |
||||||
|
"FilmId": 1, |
||||||
|
"Title": "ACADEMY DINOSAUR (Edited)", |
||||||
|
"Actor List": [ |
||||||
|
{ |
||||||
|
"ActorId": 10, |
||||||
|
"FirstName": "CHRISTIAN" |
||||||
|
} |
||||||
|
], |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
<TabItem value="After Delete" label="After Delete"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.delete", |
||||||
|
"id": "e593079f-70e5-4965-8944-5ff7aeed005c", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_736wrpoas7tr0c", |
||||||
|
"view_name": "Film", |
||||||
|
"records": [ |
||||||
|
{ |
||||||
|
"FilmId": 1010, |
||||||
|
"Title": "ALL-EDITED", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
<TabItem value="After Bulk Insert" label="After Bulk Insert"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.bulkInsert", |
||||||
|
"id": "f8397b06-a399-4a3a-b6b0-6d1c0c2f7578", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_3fq2e9q8drkblw", |
||||||
|
"view_name": "GridView", |
||||||
|
"records_inserted": 2 |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
<TabItem value="After Bulk Update" label="After Bulk Update"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.bulkUpdate", |
||||||
|
"id": "e983cea5-8e38-438e-96a0-048751f6830b", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_3fq2e9q8drkblw", |
||||||
|
"view_name": "Sheet-1", |
||||||
|
"previous_records": [ |
||||||
|
[ |
||||||
|
{ |
||||||
|
"FilmId": 1005, |
||||||
|
"Title": "Q", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"FilmId": 1004, |
||||||
|
"Title": "P", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
], |
||||||
|
"records": [ |
||||||
|
[ |
||||||
|
{ |
||||||
|
"FilmId": 1005, |
||||||
|
"Title": "Q-EDITED", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
"FilmId": 1004, |
||||||
|
"Title": "P-EDITED", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
} |
||||||
|
] |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
<TabItem value="After Bulk Delete" label="After Bulk Delete"> |
||||||
|
|
||||||
|
```bash |
||||||
|
{ |
||||||
|
"type": "records.after.bulkDelete", |
||||||
|
"id": "e7f1f4e5-7052-4ca2-9355-241ceb836f43", |
||||||
|
"data": { |
||||||
|
"table_id": "md_xzru7dcqrecc60", |
||||||
|
"table_name": "Film", |
||||||
|
"view_id": "vw_3fq2e9q8drkblw", |
||||||
|
"view_name": "Sheet-1", |
||||||
|
"records": [ |
||||||
|
[ |
||||||
|
{ |
||||||
|
"FilmId": 1022, |
||||||
|
"Title": "x", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
"FilmId": 1023, |
||||||
|
"Title": "x", |
||||||
|
"Language": { |
||||||
|
"LanguageId": 1, |
||||||
|
"Name": "English" |
||||||
|
}, |
||||||
|
} |
||||||
|
] |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
</TabItem> |
||||||
|
</Tabs> |
||||||
|
|
||||||
|
[//]: # (## Call Log) |
||||||
|
|
||||||
|
[//]: # () |
||||||
|
[//]: # (Call Log allows user to check the call history of the hook. By default, it has been disabled. However, it can be configured by using environment variable `NC_AUTOMATION_LOG_LEVEL`.) |
||||||
|
|
||||||
|
[//]: # () |
||||||
|
[//]: # (- `NC_AUTOMATION_LOG_LEVEL=OFF`: No logs will be displayed and no history will be inserted to meta database.) |
||||||
|
|
||||||
|
[//]: # (- `NC_AUTOMATION_LOG_LEVEL=ERROR`: only error logs will be displayed and history of error logs will be inserted to meta database.) |
||||||
|
|
||||||
|
[//]: # (- `NC_AUTOMATION_LOG_LEVEL=ALL`: Both error and success logs will be displayed and history of both types of logs will be inserted to meta database. **This option is only available for Enterprise Edition.**) |
||||||
|
|
||||||
|
[//]: # () |
||||||
|
[//]: # (![image](https://user-images.githubusercontent.com/35857179/228790148-1e3f21c7-9385-413a-843f-b93073ca6bea.png)) |
||||||
|
|
||||||
|
### Webhook with custom payload ☁ |
||||||
|
In the enterprise edition, you can set up a personalized payload for your webhook. Just head to the `Body` tab to make the necessary configurations. Users can utilize [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions), which allows them to access and manipulate the data easily. |
||||||
|
|
||||||
|
Use `{{ json event }}` to access the event data. Sample response is as follows |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"type": "records.after.insert", |
||||||
|
"id": "0698517a-d83a-4e72-bf7a-75f46b704ad1", |
||||||
|
"data": { |
||||||
|
"table_id": "m969t01blwprpef", |
||||||
|
"table_name": "Table-2", |
||||||
|
"view_id": "vwib3bvfxdqgymun", |
||||||
|
"view_name": "Table-2", |
||||||
|
"rows": [ |
||||||
|
{ |
||||||
|
"Id": 1, |
||||||
|
"Tags": "Sample Text", |
||||||
|
"CreatedAt": "2024-04-11T10:40:20.998Z", |
||||||
|
"UpdatedAt": "2024-04-11T10:40:20.998Z" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
|
||||||
|
:::info |
||||||
|
**Note:** The custom payload feature is only available in the enterprise edition. |
||||||
|
::: |
||||||
|
|
||||||
|
|
||||||
|
#### Discord Webhook |
||||||
|
Discord webhook can be configured to send messages to a Discord channel. Discord request body should contain content, embeds or attachments, otherwise request will fail. Below is an example of Discord webhook payload. More details can be found [here](https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html) |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"content": "Hello, this is a webhook message", |
||||||
|
"embeds": [ |
||||||
|
{ |
||||||
|
"title": "Webhook", |
||||||
|
"description": "This is a webhook message", |
||||||
|
"color": 16711680 |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
To send complete event data to Discord, use below payload |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"content" : {{ json ( json event ) }} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
One can also customize the payload as per the requirement. For example, to send only the `Title` field to Discord, use below payload. Note that, the value of `content` is what that will get displayed in the Discord channel. |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"content": "{{ event.data.rows.[0].Title }}" |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
## Environment Variables |
||||||
|
In self-hosted version, you can configure the following environment variables to customize the webhook behavior. |
||||||
|
- NC_ALLOW_LOCAL_HOOKS: Allow localhost based links to be triggered. Default: false |
||||||
|
|
||||||
|
Find more about environment variables [here](/getting-started/self-hosted/environment-variables) |
@ -0,0 +1,46 @@ |
|||||||
|
--- |
||||||
|
title: 'Actions on webhook' |
||||||
|
description: 'Learn how to enable/disable, duplicate and delete webhooks.' |
||||||
|
tags: ['Webhook', 'Delete', 'Duplicate', 'Disable', 'Enable'] |
||||||
|
keywords: ['Webhook overview', 'NocoDB webhook', 'create webhook', 'modify webhook', 'delete webhook'] |
||||||
|
--- |
||||||
|
|
||||||
|
### Enable/disable Webhook |
||||||
|
|
||||||
|
To disable a Webhook |
||||||
|
+ |
||||||
|
- Open `Webhook` tab to find list of webhooks created |
||||||
|
+ |
||||||
|
- Toggle `Activate` button to enable/disable |
||||||
|
|
||||||
|
![Webhook List](/img/v2/webhook/webhook-list-2.png) |
||||||
|
|
||||||
|
### Edit Webhook |
||||||
|
|
||||||
|
To edit a Webhook |
||||||
|
- Open `Webhook` tab to find list of webhooks created |
||||||
|
- Click on webhook to be edited |
||||||
|
- This will open up the webhook configuration page, which is similar to the page used for [creating webhook](/automation/webhook/create-webhook). Reconfigure the webhook as required |
||||||
|
- Click on `Save` button to save the changes |
||||||
|
|
||||||
|
### Duplicate Webhook |
||||||
|
|
||||||
|
To duplicate a Webhook |
||||||
|
- Open `Webhook` tab to find list of webhooks created |
||||||
|
- Click on `...` actions button associated with the webhook to be duplicate |
||||||
|
- Select `Duplicate` |
||||||
|
|
||||||
|
![Webhook context menu](/img/v2/webhook/webhook-list-3.png) |
||||||
|
|
||||||
|
A copy of the webhook will be created (disabled by default) with a suffix ` - Copy` |
||||||
|
|
||||||
|
### Delete Webhook |
||||||
|
|
||||||
|
To delete a Webhook |
||||||
|
- Open the `Webhook` tab to find the list of webhooks created |
||||||
|
- Click on the `...` actions button associated with the webhook to be deleted |
||||||
|
- Select `Delete` |
||||||
|
|
||||||
|
![Webhook context menu](/img/v2/webhook/webhook-list-3.png) |
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@ |
|||||||
|
{ |
||||||
|
"label": "Webhook", |
||||||
|
"collapsible": true, |
||||||
|
"collapsed": true, |
||||||
|
"link": { |
||||||
|
"type": "generated-index" |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue