TypeScript SDK
import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const endpoint = await client.webhooks.create({
url: "https://example.com/webhooks/ninjachat",
events: ["video.completed", "video.failed"],
});
console.log(endpoint.secret); // Store once, then redact it from logs.import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
endpoint = client.webhooks.create(
url="https://example.com/webhooks/ninjachat",
events=["video.completed", "video.failed"],
)
print(endpoint["secret"]) # Store once, then redact it from logs.curl --request POST \
--url https://www.ninjachat.ai/api/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>"
}
'{
"id": "<string>",
"url": "<string>",
"events": [
"video.completed"
],
"secret": "<string>",
"message": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Webhooks
Create a webhook
Register an HTTPS URL. NinjaChat POSTs signed JSON for video and pipeline completion, budget.alert (50/80/100% of a spend limit), and balance.low (prepaid 5/1). The signing secret is returned once. Console: https://www.ninjachat.ai/developers/webhooks
POST
/
webhooks
TypeScript SDK
import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const endpoint = await client.webhooks.create({
url: "https://example.com/webhooks/ninjachat",
events: ["video.completed", "video.failed"],
});
console.log(endpoint.secret); // Store once, then redact it from logs.import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
endpoint = client.webhooks.create(
url="https://example.com/webhooks/ninjachat",
events=["video.completed", "video.failed"],
)
print(endpoint["secret"]) # Store once, then redact it from logs.curl --request POST \
--url https://www.ninjachat.ai/api/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>"
}
'{
"id": "<string>",
"url": "<string>",
"events": [
"video.completed"
],
"secret": "<string>",
"message": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
Use an API key created in the NinjaChat developer console.
Body
application/json