Add webhook APIs
This commit is contained in:
parent
df1ed0e91d
commit
d94f2f83fb
19
README.md
19
README.md
@ -440,4 +440,21 @@ Various useful helper functions.
|
|||||||
* `time.toDateString(timestamp)`: Get a localized date string for a UNIX timestamp.
|
* `time.toDateString(timestamp)`: Get a localized date string for a UNIX timestamp.
|
||||||
* `time.toTimeString(timestamp)`: Get a time string for a UNIX timestamp, for example, "2:01 PM".
|
* `time.toTimeString(timestamp)`: Get a time string for a UNIX timestamp, for example, "2:01 PM".
|
||||||
* `uuid.v4()`: Generate a version 4 UUID string, for example, "fcca5b12-6a11-46eb-96e4-5ed6365de977".
|
* `uuid.v4()`: Generate a version 4 UUID string, for example, "fcca5b12-6a11-46eb-96e4-5ed6365de977".
|
||||||
* `uuid.short()`: Generate a 16-character random alphanumeric string, for example, "4210cd8f584e6f6c".
|
* `uuid.short()`: Generate a 16-character random alphanumeric string, for example, "4210cd8f584e6f6c".
|
||||||
|
* `async http.webhook.geturl(sourcename)`: Returns a URL that can be used as a webhook target/endpoint for third-party integrations. The `sourcename` is a unique identifier for the webhook. There is a limit on webhook payload size; large payloads over 500KB will be rejected by the server.
|
||||||
|
* `async http.webhook.poll(sourcename)`: Returns an array of webhook payloads received by the webhook URL generated by `geturl(sourcename)`.
|
||||||
|
* `async http.webhook.ack(webhookid)`: Acknowledge a webhook payload, clearing it from the list returned by `poll`.
|
||||||
|
|
||||||
|
##### Webhook poll result format:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: 123, // Unique ID. Used for ack(webhookid).
|
||||||
|
timestamp: 1234567890, // UNIX timestamp (in seconds) of when the data was received by the webhook URL.
|
||||||
|
source: "sourcename",
|
||||||
|
headers: "{'Content-Type': 'application/json'}", JSON string of all the HTTP headers sent to the webhook URL.
|
||||||
|
body: "", Entire HTTP request body sent to the webhook URL.
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user